/src/vlc/contrib/x86_64-unknown-linux-gnu/include/ebml/EbmlBinary.h
Line | Count | Source (jump to first uncovered line) |
1 | | /**************************************************************************** |
2 | | ** libebml : parse EBML files, see http://embl.sourceforge.net/ |
3 | | ** |
4 | | ** <file/class description> |
5 | | ** |
6 | | ** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. |
7 | | ** |
8 | | ** This file is part of libebml. |
9 | | ** |
10 | | ** This library is free software; you can redistribute it and/or |
11 | | ** modify it under the terms of the GNU Lesser General Public |
12 | | ** License as published by the Free Software Foundation; either |
13 | | ** version 2.1 of the License, or (at your option) any later version. |
14 | | ** |
15 | | ** This library is distributed in the hope that it will be useful, |
16 | | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | | ** Lesser General Public License for more details. |
19 | | ** |
20 | | ** You should have received a copy of the GNU Lesser General Public |
21 | | ** License along with this library; if not, write to the Free Software |
22 | | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | | ** |
24 | | ** See http://www.gnu.org/licenses/lgpl-2.1.html for LGPL licensing information. |
25 | | ** |
26 | | ** Contact license@matroska.org if any conditions of this licensing are |
27 | | ** not clear to you. |
28 | | ** |
29 | | **********************************************************************/ |
30 | | |
31 | | /*! |
32 | | \file |
33 | | \version \$Id$ |
34 | | \author Steve Lhomme <robux4 @ users.sf.net> |
35 | | \author Julien Coloos <suiryc @ users.sf.net> |
36 | | */ |
37 | | #ifndef LIBEBML_BINARY_H |
38 | | #define LIBEBML_BINARY_H |
39 | | |
40 | | #include <cstdlib> |
41 | | #include <cstring> |
42 | | |
43 | | #include "EbmlTypes.h" |
44 | | #include "EbmlElement.h" |
45 | | |
46 | | // ----- Added 10/15/2003 by jcsston from Zen ----- |
47 | | #if defined (__BORLANDC__) //Maybe other compilers? |
48 | | #include <mem.h> |
49 | | #endif //__BORLANDC__ |
50 | | // ------------------------------------------------ |
51 | | |
52 | | namespace libebml { |
53 | | |
54 | | /*! |
55 | | \class EbmlBinary |
56 | | \brief Handle all operations on an EBML element that contains "unknown" binary data |
57 | | |
58 | | \todo handle fix sized elements (like UID of CodecID) |
59 | | */ |
60 | | class EBML_DLL_API EbmlBinary : public EbmlElement { |
61 | | public: |
62 | | EbmlBinary(); |
63 | | EbmlBinary(const EbmlBinary & ElementToClone); |
64 | | ~EbmlBinary() override; |
65 | | |
66 | 3.84k | bool ValidateSize() const override {return IsFiniteSize() && GetSize() < 0x7FFFFFFF;} // we don't mind about what's inside |
67 | | |
68 | | filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false) override; |
69 | | filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override; |
70 | | filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) override; |
71 | | |
72 | 0 | void SetBuffer(const binary *Buffer, const uint32 BufferSize) { |
73 | 0 | Data = const_cast<binary *>(Buffer); |
74 | 0 | SetSize_(BufferSize); |
75 | 0 | SetValueIsSet(); |
76 | 0 | } |
77 | | |
78 | 884 | binary *GetBuffer() const {return Data;} |
79 | | |
80 | 0 | void CopyBuffer(const binary *Buffer, const uint32 BufferSize) { |
81 | 0 | if (Data != nullptr) |
82 | 0 | free(Data); |
83 | 0 | Data = static_cast<binary *>(malloc(BufferSize * sizeof(binary))); |
84 | 0 | memcpy(Data, Buffer, BufferSize); |
85 | 0 | SetSize_(BufferSize); |
86 | 0 | SetValueIsSet(); |
87 | 0 | } |
88 | | |
89 | | operator const binary &() const; |
90 | | |
91 | 0 | bool IsDefaultValue() const override { |
92 | 0 | return false; |
93 | 0 | } |
94 | | |
95 | | bool operator==(const EbmlBinary & ElementToCompare) const; |
96 | | |
97 | | #if defined(EBML_STRICT_API) |
98 | | private: |
99 | | #else |
100 | | protected: |
101 | | #endif |
102 | | binary *Data{nullptr}; // the binary data inside the element |
103 | | }; |
104 | | |
105 | | } // namespace libebml |
106 | | |
107 | | #endif // LIBEBML_BINARY_H |