mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-23 19:31:44 +00:00
use std::variant instead of boost::variant
This commit is contained in:
parent
debdc919d2
commit
75cd193bea
3
NEWS.md
3
NEWS.md
@ -37,7 +37,8 @@
|
|||||||
library will be used if found via `pkg-config`. If it is found, support for
|
library will be used if found via `pkg-config`. If it is found, support for
|
||||||
reading chapters from DVDs will be enabled in `mkvmerge` and the MKVToolNix
|
reading chapters from DVDs will be enabled in `mkvmerge` and the MKVToolNix
|
||||||
GUI. Part of the implementation of #2808.
|
GUI. Part of the implementation of #2808.
|
||||||
* Boost's Date/Time, Range and Range Adaptors libraries are not used anymore.
|
* Boost's Date/Time, Range, Range Adaptors, Tri-Bool, Variant libraries are
|
||||||
|
not used anymore.
|
||||||
|
|
||||||
|
|
||||||
# Version 46.0.0 "No Deeper Escape" 2020-05-01
|
# Version 46.0.0 "No Deeper Escape" 2020-05-01
|
||||||
|
@ -96,8 +96,8 @@ programs and libraries you absolutely need are:
|
|||||||
- [zlib](http://www.zlib.net/) — a compression library
|
- [zlib](http://www.zlib.net/) — a compression library
|
||||||
|
|
||||||
- [Boost](http://www.boost.org/) — Several of Boost's libraries are
|
- [Boost](http://www.boost.org/) — Several of Boost's libraries are
|
||||||
used: `filesystem`, `system`, `math`, `operators`, `rational`,
|
used: `filesystem`, `system`, `math`, `operators`, `rational`. At
|
||||||
`variant`. At least v1.60.0 is required.
|
least v1.60.0 is required.
|
||||||
|
|
||||||
- [libxslt's xsltproc binary](http://xmlsoft.org/libxslt/) and
|
- [libxslt's xsltproc binary](http://xmlsoft.org/libxslt/) and
|
||||||
[DocBook XSL stylesheets](https://sourceforge.net/projects/docbook/files/docbook-xsl/)
|
[DocBook XSL stylesheets](https://sourceforge.net/projects/docbook/files/docbook-xsl/)
|
||||||
|
@ -26,7 +26,3 @@ AX_BOOST_CHECK_HEADERS([boost/lexical_cast.hpp],,[
|
|||||||
AX_BOOST_CHECK_HEADERS([boost/operators.hpp],,[
|
AX_BOOST_CHECK_HEADERS([boost/operators.hpp],,[
|
||||||
AC_MSG_ERROR([Boost's Operators library is required but wasn't found])
|
AC_MSG_ERROR([Boost's Operators library is required but wasn't found])
|
||||||
])
|
])
|
||||||
|
|
||||||
AX_BOOST_CHECK_HEADERS([boost/variant.hpp],,[
|
|
||||||
AC_MSG_ERROR([Boost's variant library is required but wasn't found])
|
|
||||||
])
|
|
||||||
|
@ -19,6 +19,24 @@
|
|||||||
|
|
||||||
namespace mtx::amf {
|
namespace mtx::amf {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::string
|
||||||
|
value_to_string(value_type_t const &value) {
|
||||||
|
if (std::holds_alternative<double>(value))
|
||||||
|
return fmt::format("{0}", std::get<double>(value));
|
||||||
|
|
||||||
|
if (std::holds_alternative<bool>(value))
|
||||||
|
return std::get<bool>(value) ? "yes" : "no";
|
||||||
|
|
||||||
|
if (std::holds_alternative<std::string>(value))
|
||||||
|
return std::get<std::string>(value);
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
script_parser_c::script_parser_c(memory_cptr const &mem)
|
script_parser_c::script_parser_c(memory_cptr const &mem)
|
||||||
: m_data_mem{mem}
|
: m_data_mem{mem}
|
||||||
, m_data{*mem.get()}
|
, m_data{*mem.get()}
|
||||||
@ -62,7 +80,7 @@ script_parser_c::read_properties(std::unordered_map<std::string, value_type_t> &
|
|||||||
auto key = read_string(TYPE_STRING);
|
auto key = read_string(TYPE_STRING);
|
||||||
auto value = read_value();
|
auto value = read_value();
|
||||||
|
|
||||||
mxdebug_if(m_debug, fmt::format("{0}Property key: {1}; value read: {2}; value: {3}\n", level_spacer(), key, value.second, boost::apply_visitor(value_to_string_c(), value.first)));
|
mxdebug_if(m_debug, fmt::format("{0}Property key: {1}; value read: {2}; value: {3}\n", level_spacer(), key, value.second, value_to_string(value.first)));
|
||||||
|
|
||||||
if (key.empty() || !value.second)
|
if (key.empty() || !value.second)
|
||||||
break;
|
break;
|
||||||
@ -99,7 +117,7 @@ script_parser_c::read_value() {
|
|||||||
|
|
||||||
else if ((TYPE_STRING == data_type) || (TYPE_LONG_STRING == data_type)) {
|
else if ((TYPE_STRING == data_type) || (TYPE_LONG_STRING == data_type)) {
|
||||||
value = read_string(data_type);
|
value = read_string(data_type);
|
||||||
m_in_meta_data = boost::get<std::string>(value) == "onMetaData";
|
m_in_meta_data = std::get<std::string>(value) == "onMetaData";
|
||||||
|
|
||||||
} else if (TYPE_OBJECT == data_type) {
|
} else if (TYPE_OBJECT == data_type) {
|
||||||
std::unordered_map<std::string, value_type_t> dummy;
|
std::unordered_map<std::string, value_type_t> dummy;
|
||||||
|
@ -16,30 +16,15 @@
|
|||||||
#include "common/common_pch.h"
|
#include "common/common_pch.h"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <boost/variant.hpp>
|
#include <variant>
|
||||||
|
|
||||||
#include "common/mm_mem_io.h"
|
#include "common/mm_mem_io.h"
|
||||||
|
|
||||||
namespace mtx::amf {
|
namespace mtx::amf {
|
||||||
|
|
||||||
using value_type_t = boost::variant<double, bool, std::string>;
|
using value_type_t = std::variant<double, bool, std::string>;
|
||||||
using meta_data_t = std::unordered_map<std::string, value_type_t>;
|
using meta_data_t = std::unordered_map<std::string, value_type_t>;
|
||||||
|
|
||||||
class value_to_string_c: public boost::static_visitor<std::string> {
|
|
||||||
public:
|
|
||||||
std::string operator ()(double value) const {
|
|
||||||
return fmt::format("{0}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string operator ()(bool value) const {
|
|
||||||
return value ? "yes" : "no";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string operator ()(std::string const &value) const {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class script_parser_c {
|
class script_parser_c {
|
||||||
public:
|
public:
|
||||||
enum data_type_e {
|
enum data_type_e {
|
||||||
@ -74,13 +59,13 @@ public:
|
|||||||
meta_data_t const &get_meta_data() const;
|
meta_data_t const &get_meta_data() const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T const *
|
std::optional<T>
|
||||||
get_meta_data_value(std::string const &key) {
|
get_meta_data_value(std::string const &key) {
|
||||||
auto itr = m_meta_data.find(key);
|
auto itr = m_meta_data.find(key);
|
||||||
if (m_meta_data.end() == itr)
|
if (m_meta_data.end() == itr)
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
return boost::get<T>(&itr->second);
|
return std::get<T>(itr->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -680,7 +680,7 @@ flv_reader_c::process_script_tag() {
|
|||||||
mtx::amf::script_parser_c parser{m_in->read(m_tag.m_data_size)};
|
mtx::amf::script_parser_c parser{m_in->read(m_tag.m_data_size)};
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
|
||||||
double const *number;
|
std::optional<double> number;
|
||||||
|
|
||||||
if ((number = parser.get_meta_data_value<double>("framerate"))) {
|
if ((number = parser.get_meta_data_value<double>("framerate"))) {
|
||||||
m_tracks[m_video_track_idx]->m_v_frame_rate = *number;
|
m_tracks[m_video_track_idx]->m_v_frame_rate = *number;
|
||||||
|
Loading…
Reference in New Issue
Block a user