2
mkvmerge -- utility for splicing together matroska files
3
from component media subtypes
5
Distributed under the GPL
6
see the file COPYING for details
7
or visit http://www.gnu.org/copyleft/gpl.html
9
helper functions for AMF (Action Message Format) data
11
Written by Moritz Bunkus <moritz@bunkus.org>.
14
#ifndef MTX_COMMON_AMF_H
15
#define MTX_COMMON_AMF_H
17
#include "common/common_pch.h"
19
#include <unordered_map>
20
#include <boost/variant.hpp>
22
namespace mtx { namespace amf {
24
typedef boost::variant<double, bool, std::string> value_type_t;
25
typedef std::unordered_map<std::string, value_type_t> meta_data_t;
27
class value_to_string_c: public boost::static_visitor<std::string> {
29
std::string operator ()(double value) const {
30
return (boost::format("%1%") % value).str();
33
std::string operator ()(bool value) const {
34
return value ? "yes" : "no";
37
std::string operator ()(std::string const &value) const {
42
class script_parser_c {
49
TYPE_MOVIECLIP = 0x04,
51
TYPE_UNDEFINED = 0x06,
52
TYPE_REFERENCE = 0x07,
53
TYPE_ECMAARRAY = 0x08,
54
TYPE_OBJECT_END = 0x09,
57
TYPE_LONG_STRING = 0x0c,
61
memory_cptr m_data_mem;
63
meta_data_t m_meta_data;
70
script_parser_c(memory_cptr const &mem);
73
meta_data_t const &get_meta_data() const;
77
get_meta_data_value(std::string const &key) {
78
auto itr = m_meta_data.find(key);
79
if (m_meta_data.end() == itr)
82
return boost::get<T>(&itr->second);
86
std::string read_string(data_type_e type);
87
std::pair<value_type_t, bool> read_value();
88
void read_properties(std::unordered_map<std::string, value_type_t> &properties);
89
std::string level_spacer() const;
96
struct hash<mtx::amf::script_parser_c::data_type_e> {
97
size_t operator()(mtx::amf::script_parser_c::data_type_e value) const {
98
return hash<unsigned int>()(static_cast<unsigned int>(value));
103
#endif // MTX_COMMON_H