vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / plugins / matroska / libebml / ebml / EbmlId.h
blob1ad297c14c2c7d00374e66b7f88ee2c52900f303
1 /****************************************************************************
2 ** libebml : parse EBML files, see http://embl.sourceforge.net/
3 **
4 ** <file/class description>
5 **
6 ** Copyright (C) 2002-2004 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
26 ** Contact license@matroska.org if any conditions of this licensing are
27 ** not clear to you.
29 **********************************************************************/
31 /*!
32 \file
33 \version \$Id: EbmlId.h 936 2004-11-10 20:46:28Z mosu $
34 \author Steve Lhomme <robux4 @ users.sf.net>
36 #ifndef LIBEBML_ID_H
37 #define LIBEBML_ID_H
39 #include "EbmlTypes.h"
41 START_LIBEBML_NAMESPACE
43 /*!
44 \class EbmlId
46 class EBML_DLL_API EbmlId {
47 public:
48 uint32 Value;
49 unsigned int Length;
51 EbmlId(const binary aValue[4], const unsigned int aLength)
52 :Length(aLength)
54 Value = 0;
55 unsigned int i;
56 for (i=0; i<aLength; i++) {
57 Value <<= 8;
58 Value += aValue[i];
62 EbmlId(const uint32 aValue, const unsigned int aLength)
63 :Value(aValue), Length(aLength) {}
65 inline bool operator==(const EbmlId & TestId) const
67 return ((TestId.Length == Length) && (TestId.Value == Value));
69 inline bool operator!=(const EbmlId & TestId) const
71 return !(*this == TestId);
74 inline void Fill(binary * Buffer) const {
75 unsigned int i;
76 for (i = 0; i<Length; i++) {
77 Buffer[i] = (Value >> (8*(Length-i-1))) & 0xFF;
82 END_LIBEBML_NAMESPACE
84 #endif // LIBEBML_ID_H