libebml_ng
ebmlMasterElementType.h
Go to the documentation of this file.
1 #ifndef EBML_NG_MASTERELEMENTCLASS_H
2 #define EBML_NG_MASTERELEMENTCLASS_H
3 
4 #include "../../ebmlElementType.h"
5 #include "../../ebmlElementType.tpp"
6 #include "childTypeSpec.h"
7 #include "sizetree_t.h"
8 #include <vector>
9 
10 namespace ebml {
12 
13  typedef std::unordered_map<ebmlID_t, unsigned long> occur_d;
14 
57  class ebmlMasterElementType : public ebmlTypeCRTP<ebmlMasterElementType, ebmlMasterElement> {
58  friend class ebmlMasterElement;
59 
60  protected:
62 
63  public:
64  ebmlMasterElementType(const char*, const std::wstring&, const childTypeSpecArg_l &);
65  ebmlMasterElementType(ebmlID_t, const std::wstring&, const childTypeSpecArg_l &);
66  ebmlMasterElementType(const char*, const std::wstring&, const childTypeSpecArg_l &, const seekHelper_t* seekHelper);
67  ebmlMasterElementType(ebmlID_t, const std::wstring&, const childTypeSpecArg_l &, const seekHelper_t* seekHelper);
68 
69  protected:
70  ebmlMasterElementType(const char*, const std::wstring&);
71  ebmlMasterElementType(ebmlID_t, const std::wstring&);
72  ebmlMasterElementType(const char*, const std::wstring&, const seekHelper_t* seekHelper);
73  ebmlMasterElementType(ebmlID_t, const std::wstring&, const seekHelper_t* seekHelper);
74 
75  inline ebmlElement* _decodeChild(const parseString&) const;
76  inline ebmlElement* _decodeChild(const parseFile&) const;
77  inline ebmlElement* _cdecodeChild(const parseString&) const;
78  inline ebmlElement* _cdecodeChild(const parseFile&) const;
79 
80  public:
86  inline const childTypeSpec_t & childTypes() const {
87  return _childTypes;
88  };
89  };
90 
92  const ebmlElementType * childcls;
93 
94  try {
95  childcls = this->_childTypes[parsed.ebmlID];
96  } catch (ebmlNoChildMatch& e) {
97  e.erroroffset = parsed.offset;
98  throw;
99  }
100 
101  return childcls->_decode_nocheck(parsed);
102  }
103 
105  const ebmlElementType * childcls;
106 
107  try {
108  childcls = this->_childTypes[parsed.ebmlID];
109  } catch (ebmlNoChildMatch& e) {
110  e.erroroffset = parsed.offset;
111  throw;
112  }
113 
114  return childcls->_decode_nocheck(parsed);
115  }
116 
118  const ebmlElementType * childcls;
119  // std::cout << "E " << parsed.offset << " " << parsed.dataOffset() << " " << parsed.dataSize << std::endl;
120  std::cout << typeof(this) << "::_decodeChild(const parseFile&) const" << std::endl;
121 
122  try {
123  childcls = this->_childTypes[parsed.ebmlID];
124  } catch (ebmlNoChildMatch& e) {
125  e.erroroffset = parsed.offset;
126  throw;
127  }
128 
129  return childcls->_decode_nocheck(parsed);
130  }
131 
133  const ebmlElementType * childcls;
134 
135  try {
136  childcls = this->_childTypes[parsed.ebmlID];
137  } catch (ebmlNoChildMatch& e) {
138  e.offset = parsed.offset;
139  throw;
140  }
141 
142  // return childcls->mcdecode(parsed);
143  return childcls->_decode_nocheck(parsed);
144  }
145 
147 }
148 #endif
Helper class for creating and initializing seek data.
Definition: seekdata.h:195
Abstract base class for EBML Element Type objects.
Definition: ebmlElementType.h:106
childTypeSpec_t _childTypes
Definition: ebmlMasterElementType.h:61
std::list< childTypeSpecArg_t > childTypeSpecArg_l
Alias for a list of child type specification arguments.
Definition: childTypeSpec.h:39
ebmlElement * _decode_nocheck(const parseString &parsed) const
Decode element from ebml::parseString instance.
Definition: ebmlElementType.h:800
ebmlElement * _decodeChild(const parseString &) const
Definition: ebmlMasterElementType.h:91
off_t offset
Definition: string.h:43
Abstract base class for EBML master element instances.This class provides the functionality to manage...
Definition: ebmlMasterElement.h:19
Represents a parsed EBML string segment.
Definition: string.h:37
off_t offset
Definition: io.h:43
seekHelper_t seekHelper
Definition: seekdata.cpp:136
Represents a parsed EBML file segment.
Definition: io.h:32
ebmlElement * _cdecodeChild(const parseString &) const
Definition: ebmlMasterElementType.h:104
ebmlID_t ebmlID
Definition: io.h:39
off_t erroroffset
Definition: exceptions.h:51
Definition: basictypes.h:40
ebmlID_t ebmlID
Definition: string.h:39
std::string typeof(const T *inst)
Definition: typeof.h:10
uint64_t ebmlID_t
Definition: ebmlID_t.h:7
ebmlMasterElementType(const char *, const std::wstring &, const childTypeSpecArg_l &)
Definition: ebmlMasterElementType.cpp:24
Represents the base type for all EBML master elements.
Definition: ebmlMasterElementType.h:57
Abstract base class for EBML Element instances.
Definition: ebmlElement.h:79
const childTypeSpec_t & childTypes() const
Gets the child type specification.
Definition: ebmlMasterElementType.h:86
Specifies accepted child element types within a parent element.
Definition: childTypeSpec.h:76
std::unordered_map< ebmlID_t, unsigned long > occur_d
Definition: ebmlMasterElementType.h:11
Definition: exceptions.h:66
CRTP template for EBML Element Type objects.
Definition: ebmlElementType.h:454
off_t offset
Definition: exceptions.h:49