libebml_ng
exceptions.h
Go to the documentation of this file.
1 #ifndef EBML_NG_EXCEPTIONS_H
2 #define EBML_NG_EXCEPTIONS_H
3 
4 #include <string>
5 
6 #include "ptrs.h"
7 
8 #define DECODE_ERR_SIG_DECL const std::string& message, const ebmlElementType* cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1
9 #define DECODE_ERR_SIG const std::string& message, const ebmlElementType* cls, off_t offset, unsigned char headSize, off_t erroroffset
10 #define DECODE_ERR_ARGS message, cls, offset, headSize, erroroffset
11 
12 // Supplies default arguments for cls, offset, and headSize in case thrown from inside an unpack function that may not have this information.
13 #define DECODE_ERR_DEFAULT nullptr, 0, 0
14 
15 
16 namespace ebml {
17  std::string make_exc_msg(const char* msg, unsigned int lineno, const char* file);
18 
19  class stopIteration : public std::exception {};
20 
21  class ebmlException : public std::exception {
22  private:
23  std::string _message;
24 
25  public:
26  ebmlException(const std::string& message);
27  const char* what() const noexcept override;
28  };
29 
31  public:
32  ebmlNotImplementedError(const std::string& message, const ebmlElementType* cls=nullptr);
34  };
35 
36  class ebmlEncodeError : public ebmlException {
37  private:
38  c_ebmlElement_sp _elem;
39 
40  public:
41  // ebmlEncodeError(const std::string& message);
42  ebmlEncodeError(const std::string& message, const c_ebmlElement_sp& elem=nullptr);
43  c_ebmlElement_sp& elem() const;
44  };
45 
46  class ebmlDecodeError : public ebmlException {
47  public:
49  off_t offset; // offset of element start (head)
50  unsigned char headSize;
51  off_t erroroffset; // offset of error.
53  virtual void add_to_offset(off_t);
54  };
55 
57  public:
59  };
60 
61  class ebmlNoMatch : public ebmlDecodeError {
62  public:
64  };
65 
67  public:
69  };
70 
71  // class ebmlBoundError : public ebmlDecodeError {
72  // private:
73  // public:
74  // ebmlBoundError(
75  // const std::string& message, off_t offset=-1,
76  // off_t parentstart=-1, off_t parentend=-1, off_t childstart=-1, off_t childend=-1,
77  // const ebmlElementType* cls=nullptr);
78  // void add_to_offset(off_t);
79  // off_t parentstart;
80  // off_t parentend;
81  // off_t childstart;
82  // off_t childend;
83  // };
84 
86  public:
88  };
89 
91  public:
93  };
94 
96  public:
98  };
99 
101  public:
102  unicodeDecodeError(DECODE_ERR_SIG_DECL, off_t end=-1, const std::string& object="");
103  std::string object;
104  off_t start;
105  off_t end;
106  };
107 
109  public:
110  unicodeEncodeError(const std::string& message, const std::wstring& object=L"", off_t start=-1, off_t end=-1, const c_ebmlElement_sp& elem=nullptr);
111  std::wstring object;
112  off_t start;
113  off_t end;
114  };
115 
116  class ebmlWriteError : public ebmlException {
117  public:
118  ebmlWriteError(const std::string&);
119  };
120 
122  public:
123  ebmlInsertionError(const std::string&, off_t, off_t, off_t, off_t, off_t);
124  ebmlInsertionError(const std::string&, off_t, off_t, off_t, off_t, off_t, const c_ebmlElement_sp&);
125  ebmlInsertionError(const std::string&, off_t, off_t, off_t, off_t, off_t, c_ebmlElement_sp&&);
126  off_t prevOffset;
127  off_t prevEnd;
128  off_t offset;
129  off_t endOffset;
130  off_t nextOffset;
132  };
133 
134  class ebmlMoveError : public ebmlWriteError {
135  public:
136  ebmlMoveError(const std::string&, off_t, off_t, off_t, off_t, off_t, off_t, off_t, off_t);
137  ebmlMoveError(const std::string&, off_t, off_t, off_t, off_t, off_t, off_t, off_t, off_t, const c_ebmlElement_sp&);
138  ebmlMoveError(const std::string&, off_t, off_t, off_t, off_t, off_t, off_t, off_t, off_t, c_ebmlElement_sp&&);
139  off_t prevEndOld;
140  off_t src_offset;
142  off_t prevOffset;
143  off_t prevEnd;
144  off_t dest_offset;
145  off_t endOffset;
146  off_t nextOffset;
148  };
149 
151  public:
152  ebmlResizeError(const std::string&, off_t, off_t, off_t, off_t, off_t);
153  ebmlResizeError(const std::string&, off_t, off_t, off_t, off_t, off_t, const c_ebmlElement_sp&);
154  ebmlResizeError(const std::string&, off_t, off_t, off_t, off_t, off_t, c_ebmlElement_sp&&);
155  off_t offset;
156  off_t endOffset;
161  };
162 }
163 #endif
off_t start
Definition: exceptions.h:112
const ebmlElementType * cls
Definition: exceptions.h:52
Definition: exceptions.h:19
ebmlInsertionError(const std::string &, off_t, off_t, off_t, off_t, off_t)
Definition: exceptions.cpp:76
ebmlNoMatch(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:39
unsigned char headSize
Definition: exceptions.h:50
Abstract base class for EBML Element Type objects.
Definition: ebmlElementType.h:106
c_ebmlElement_sp elem
Definition: exceptions.h:131
off_t nextOffset
Definition: exceptions.h:130
Definition: exceptions.h:121
off_t endOffset
Definition: exceptions.h:145
Definition: exceptions.h:85
ebmlInvalidVint(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:38
Definition: exceptions.h:134
ebmlResizeError(const std::string &, off_t, off_t, off_t, off_t, off_t)
Definition: exceptions.cpp:109
std::string object
Definition: exceptions.h:103
Definition: exceptions.h:61
ebmlMoveError(const std::string &, off_t, off_t, off_t, off_t, off_t, off_t, off_t, off_t)
Definition: exceptions.cpp:85
unicodeDecodeError(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1, off_t end=-1, const std::string &object="")
Definition: exceptions.cpp:62
off_t prevEnd
Definition: exceptions.h:127
Definition: exceptions.h:95
Definition: exceptions.h:90
ebmlDataContinues(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:42
off_t src_offset
Definition: exceptions.h:140
const ebmlElementType * cls
Definition: exceptions.h:33
unicodeEncodeError(const std::string &message, const std::wstring &object=L"", off_t start=-1, off_t end=-1, const c_ebmlElement_sp &elem=nullptr)
Definition: exceptions.cpp:67
off_t nextSiblingOffset
Definition: exceptions.h:159
const char * what() const noexcept override
Definition: exceptions.cpp:19
off_t nextOffsetOld
Definition: exceptions.h:141
Definition: exceptions.h:56
off_t lastChildEnd
Definition: exceptions.h:158
off_t dest_offset
Definition: exceptions.h:144
Definition: exceptions.h:150
ebmlWriteError(const std::string &)
Definition: exceptions.cpp:73
off_t erroroffset
Definition: exceptions.h:51
Definition: basictypes.h:40
A drop-in replacement for std::shared_ptr tailored for EBML objects.
Definition: ptrs.h:27
ebmlFormatError(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:43
ebmlNotImplementedError(const std::string &message, const ebmlElementType *cls=nullptr)
Definition: exceptions.cpp:23
Definition: exceptions.h:108
off_t endOffset
Definition: exceptions.h:129
ebmlException(const std::string &message)
Definition: exceptions.cpp:15
off_t end
Definition: exceptions.h:113
#define DECODE_ERR_SIG_DECL
Definition: exceptions.h:8
ebmlNoChildMatch(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:40
off_t prevOffset
Definition: exceptions.h:142
off_t start
Definition: exceptions.h:104
Definition: exceptions.h:100
c_ebmlElement_sp & elem() const
Definition: exceptions.h:36
off_t lastChildOffset
Definition: exceptions.h:157
off_t prevEndOld
Definition: exceptions.h:139
off_t offset
Definition: exceptions.h:155
ebmlEncodeError(const std::string &message, const c_ebmlElement_sp &elem=nullptr)
Definition: exceptions.cpp:27
Definition: exceptions.h:116
ebmlUnexpectedEndOfData(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:41
c_ebmlElement_sp elem
Definition: exceptions.h:160
off_t prevEnd
Definition: exceptions.h:143
virtual void add_to_offset(off_t)
Definition: exceptions.cpp:34
off_t nextOffset
Definition: exceptions.h:146
off_t end
Definition: exceptions.h:105
Definition: exceptions.h:46
std::wstring object
Definition: exceptions.h:111
Definition: exceptions.h:21
ebmlDecodeError(const std::string &message, const ebmlElementType *cls=nullptr, off_t offset=-1, unsigned char headSize=0, off_t erroroffset=-1)
Definition: exceptions.cpp:29
Definition: exceptions.h:30
Definition: exceptions.h:66
std::string make_exc_msg(const char *msg, unsigned int lineno, const char *file)
Definition: exceptions.cpp:8
off_t offset
Definition: exceptions.h:49
off_t endOffset
Definition: exceptions.h:156
c_ebmlElement_sp elem
Definition: exceptions.h:147
off_t offset
Definition: exceptions.h:128
off_t prevOffset
Definition: exceptions.h:126