3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / plugins / matroska / libebml / EbmlBinary.cpp
blobd23a88d4fb9b156f0bf91afba5bc632e9216845c
1 /****************************************************************************
2 ** libebml : parse EBML files, see http://embl.sourceforge.net/
3 **
4 ** <file/class description>
5 **
6 ** Copyright (C) 2002-2005 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: EbmlBinary.cpp 1112 2005-03-28 09:55:50Z mosu $
34 \author Steve Lhomme <robux4 @ users.sf.net>
35 \author Julien Coloos <suiryc @ users.sf.net>
37 #include <cassert>
39 #include "ebml/EbmlBinary.h"
41 START_LIBEBML_NAMESPACE
43 EbmlBinary::EbmlBinary()
44 :EbmlElement(0, false), Data(NULL)
47 EbmlBinary::EbmlBinary(const EbmlBinary & ElementToClone)
48 :EbmlElement(ElementToClone)
50 if (ElementToClone.Data == NULL)
51 Data = NULL;
52 else {
53 Data = (binary *)malloc(Size * sizeof(binary));
54 assert(Data != NULL);
55 memcpy(Data, ElementToClone.Data, Size);
59 EbmlBinary::~EbmlBinary(void) {
60 if(Data)
61 free(Data);
64 uint32 EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
66 output.writeFully(Data,Size);
68 return Size;
71 /*!
72 \note no Default binary value handled
74 uint64 EbmlBinary::UpdateSize(bool bKeepIntact, bool bForceRender)
76 return Size;
79 uint64 EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
81 if (Data != NULL)
82 free(Data);
84 if (ReadFully == SCOPE_NO_DATA)
86 Data = NULL;
87 return Size;
90 Data = (binary *)malloc(Size * sizeof(binary));
91 assert(Data != NULL);
92 bValueIsSet = true;
93 return input.read(Data, Size);
96 bool EbmlBinary::operator==(const EbmlBinary & ElementToCompare) const
98 return ((Size == ElementToCompare.Size) && !memcmp(Data, ElementToCompare.Data, Size));
101 END_LIBEBML_NAMESPACE