/src/vlc/contrib/x86_64-unknown-linux-gnu/include/ebml/EbmlId.h
Line | Count | Source |
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: EbmlId.h 936 2004-11-10 20:46:28Z mosu $ |
34 | | \author Steve Lhomme <robux4 @ users.sf.net> |
35 | | */ |
36 | | #ifndef LIBEBML_ID_H |
37 | | #define LIBEBML_ID_H |
38 | | |
39 | | #include "EbmlTypes.h" |
40 | | |
41 | | namespace libebml { |
42 | | |
43 | | |
44 | | #if defined(EBML_STRICT_API) |
45 | | #define EBML_ID_VALUE(id) (id).GetValue() |
46 | | #define EBML_ID_LENGTH(id) (id).GetLength() |
47 | | #else |
48 | | #define EBML_ID_VALUE(id) (id).Value |
49 | 4.79k | #define EBML_ID_LENGTH(id) (id).Length |
50 | | #endif |
51 | | |
52 | | /*! |
53 | | \class EbmlId |
54 | | */ |
55 | | class EBML_DLL_API EbmlId { |
56 | | public: |
57 | | EbmlId(const binary aValue[4], const unsigned int aLength) |
58 | 28.3k | :Length(aLength) |
59 | 28.3k | { |
60 | 28.3k | Value = 0; |
61 | 28.3k | unsigned int i; |
62 | 140k | for (i=0; i<aLength; i++) { |
63 | 111k | Value <<= 8; |
64 | 111k | Value += aValue[i]; |
65 | 111k | } |
66 | 28.3k | } |
67 | | |
68 | | EbmlId(const uint32 aValue, const unsigned int aLength) |
69 | 0 | :Value(aValue), Length(aLength) {} |
70 | | |
71 | | inline bool operator==(const EbmlId & TestId) const |
72 | 1.00M | { |
73 | 1.00M | return ((TestId.Length == Length) && (TestId.Value == Value)); |
74 | 1.00M | } |
75 | | inline bool operator!=(const EbmlId & TestId) const |
76 | 0 | { |
77 | 0 | return !(*this == TestId); |
78 | 0 | } |
79 | | |
80 | 0 | inline void Fill(binary * Buffer) const { |
81 | 0 | unsigned int i; |
82 | 0 | for (i = 0; i<Length; i++) { |
83 | 0 | Buffer[i] = (Value >> (8*(Length-i-1))) & 0xFF; |
84 | 0 | } |
85 | 0 | } |
86 | | |
87 | 2.75M | inline size_t GetLength() const { return Length; } |
88 | 1.19M | inline uint32 GetValue() const { return Value; } |
89 | | |
90 | | #if defined(EBML_STRICT_API) |
91 | | private: |
92 | | #endif |
93 | | uint32 Value; |
94 | | size_t Length; |
95 | | }; |
96 | | |
97 | | } // namespace libebml |
98 | | |
99 | | #endif // LIBEBML_ID_H |