libebml/libebml2: only Master elements can have an infinite/unknown size
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@270 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
parent
ece95ac6b7
commit
8f6b7a6fd9
@ -1,106 +1,106 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlBinary.h 1298 2008-02-21 22:14:18Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_BINARY_H
|
||||
#define LIBEBML_BINARY_H
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
// ----- Added 10/15/2003 by jcsston from Zen -----
|
||||
#if defined (__BORLANDC__) //Maybe other compilers?
|
||||
#include <mem.h>
|
||||
#endif //__BORLANDC__
|
||||
// ------------------------------------------------
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlBinary
|
||||
\brief Handle all operations on an EBML element that contains "unknown" binary data
|
||||
|
||||
\todo handle fix sized elements (like UID of CodecID)
|
||||
*/
|
||||
class EBML_DLL_API EbmlBinary : public EbmlElement {
|
||||
public:
|
||||
EbmlBinary();
|
||||
EbmlBinary(const EbmlBinary & ElementToClone);
|
||||
virtual ~EbmlBinary(void);
|
||||
|
||||
virtual bool ValidateSize() const {return true;} // we don't mind about what's inside
|
||||
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
||||
void SetBuffer(const binary *Buffer, const uint32 BufferSize) {
|
||||
Data = (binary *) Buffer;
|
||||
SetSize_(BufferSize);
|
||||
SetValueIsSet();
|
||||
}
|
||||
|
||||
binary *GetBuffer() const {return Data;}
|
||||
|
||||
void CopyBuffer(const binary *Buffer, const uint32 BufferSize) {
|
||||
if (Data != NULL)
|
||||
free(Data);
|
||||
Data = (binary *)malloc(BufferSize * sizeof(binary));
|
||||
memcpy(Data, Buffer, BufferSize);
|
||||
SetSize_(BufferSize);
|
||||
SetValueIsSet();
|
||||
}
|
||||
|
||||
operator const binary &() const {return *Data;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const EbmlBinary & ElementToCompare) const;
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
binary *Data; // the binary data inside the element
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_BINARY_H
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_BINARY_H
|
||||
#define LIBEBML_BINARY_H
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
// ----- Added 10/15/2003 by jcsston from Zen -----
|
||||
#if defined (__BORLANDC__) //Maybe other compilers?
|
||||
#include <mem.h>
|
||||
#endif //__BORLANDC__
|
||||
// ------------------------------------------------
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlBinary
|
||||
\brief Handle all operations on an EBML element that contains "unknown" binary data
|
||||
|
||||
\todo handle fix sized elements (like UID of CodecID)
|
||||
*/
|
||||
class EBML_DLL_API EbmlBinary : public EbmlElement {
|
||||
public:
|
||||
EbmlBinary();
|
||||
EbmlBinary(const EbmlBinary & ElementToClone);
|
||||
virtual ~EbmlBinary(void);
|
||||
|
||||
virtual bool ValidateSize() const {return IsFiniteSize() && GetSize() < INT_MAX;} // we don't mind about what's inside
|
||||
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
||||
void SetBuffer(const binary *Buffer, const uint32 BufferSize) {
|
||||
Data = (binary *) Buffer;
|
||||
SetSize_(BufferSize);
|
||||
SetValueIsSet();
|
||||
}
|
||||
|
||||
binary *GetBuffer() const {return Data;}
|
||||
|
||||
void CopyBuffer(const binary *Buffer, const uint32 BufferSize) {
|
||||
if (Data != NULL)
|
||||
free(Data);
|
||||
Data = (binary *)malloc(BufferSize * sizeof(binary));
|
||||
memcpy(Data, Buffer, BufferSize);
|
||||
SetSize_(BufferSize);
|
||||
SetValueIsSet();
|
||||
}
|
||||
|
||||
operator const binary &() const {return *Data;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const EbmlBinary & ElementToCompare) const;
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
binary *Data; // the binary data inside the element
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_BINARY_H
|
||||
|
312
ebml/EbmlCrc32.h
312
ebml/EbmlCrc32.h
@ -1,156 +1,156 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlCrc32.h 1326 2009-08-23 00:47:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Jory Stone <jcsston @ toughguy.net>
|
||||
*/
|
||||
#ifndef LIBEBML_CRC32_H
|
||||
#define LIBEBML_CRC32_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlBinary.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const uint32 CRC32_NEGL = 0xffffffffL;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define CRC32_INDEX(c) (c >> 24)
|
||||
# define CRC32_SHIFTED(c) (c << 8)
|
||||
#else
|
||||
# define CRC32_INDEX(c) (c & 0xff)
|
||||
# define CRC32_SHIFTED(c) (c >> 8)
|
||||
#endif
|
||||
|
||||
DECLARE_EBML_BINARY(EbmlCrc32)
|
||||
public:
|
||||
EbmlCrc32(const EbmlCrc32 & ElementToClone);
|
||||
virtual bool ValidateSize() const {return (GetSize() == 4);}
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
// filepos_t UpdateSize(bool bWithDefault = false);
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddElementCRC32(EbmlElement &ElementToCRC);
|
||||
bool CheckElementCRC32(EbmlElement &ElementToCRC);
|
||||
|
||||
/*!
|
||||
CRC Checksum Calculation
|
||||
*/
|
||||
enum {DIGESTSIZE = 4};
|
||||
|
||||
/*!
|
||||
Use this to quickly check a CRC32 with some data
|
||||
\return True if inputCRC matches CRC32 generated from input data
|
||||
*/
|
||||
static bool CheckCRC(uint32 inputCRC, const binary *input, uint32 length);
|
||||
/*!
|
||||
Calls Update() and Finalize(), use to create a CRC32 in one go
|
||||
*/
|
||||
void FillCRC32(const binary *input, uint32 length);
|
||||
/*!
|
||||
Add data to the CRC table, in other words process some data bit by bit
|
||||
*/
|
||||
void Update(const binary *input, uint32 length);
|
||||
/*!
|
||||
Use this with Update() to Finalize() or Complete the CRC32
|
||||
*/
|
||||
void Finalize();
|
||||
/*!
|
||||
Returns a uint32 that has the value of the CRC32
|
||||
*/
|
||||
uint32 GetCrc32() const {
|
||||
return m_crc_final;
|
||||
};
|
||||
|
||||
void ForceCrc32(uint32 NewValue) { m_crc_final = NewValue; SetValueIsSet();}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
void ResetCRC() {m_crc = CRC32_NEGL;}
|
||||
void UpdateByte(binary b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
|
||||
|
||||
static const uint32 m_tab[256];
|
||||
uint32 m_crc;
|
||||
uint32 m_crc_final;
|
||||
|
||||
EBML_CONCRETE_CLASS(EbmlCrc32)
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline unsigned int GetAlignment(T *dummy=NULL) // VC60 workaround
|
||||
{
|
||||
#if (_MSC_VER >= 1300)
|
||||
return __alignof(T);
|
||||
#elif defined(__GNUC__)
|
||||
return __alignof__(T);
|
||||
#else
|
||||
return sizeof(T);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsPowerOf2(T n)
|
||||
{
|
||||
return n > 0 && (n & (n-1)) == 0;
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline T2 ModPowerOf2(T1 a, T2 b)
|
||||
{
|
||||
assert(IsPowerOf2(b));
|
||||
return T2(a) & (b-1);
|
||||
}
|
||||
|
||||
inline bool IsAlignedOn(const void *p, unsigned int alignment)
|
||||
{
|
||||
return IsPowerOf2(alignment) ? ModPowerOf2((uintptr_t)p, alignment) == 0 : (uintptr_t)p % alignment == 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsAligned(const void *p, T *dummy=NULL) // VC60 workaround
|
||||
{
|
||||
return IsAlignedOn(p, GetAlignment<T>());
|
||||
}
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_CRC32_H
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Jory Stone <jcsston @ toughguy.net>
|
||||
*/
|
||||
#ifndef LIBEBML_CRC32_H
|
||||
#define LIBEBML_CRC32_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlBinary.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const uint32 CRC32_NEGL = 0xffffffffL;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define CRC32_INDEX(c) (c >> 24)
|
||||
# define CRC32_SHIFTED(c) (c << 8)
|
||||
#else
|
||||
# define CRC32_INDEX(c) (c & 0xff)
|
||||
# define CRC32_SHIFTED(c) (c >> 8)
|
||||
#endif
|
||||
|
||||
DECLARE_EBML_BINARY(EbmlCrc32)
|
||||
public:
|
||||
EbmlCrc32(const EbmlCrc32 & ElementToClone);
|
||||
virtual bool ValidateSize() const {return IsFiniteSize() && (GetSize() == 4);}
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
// filepos_t UpdateSize(bool bWithDefault = false);
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddElementCRC32(EbmlElement &ElementToCRC);
|
||||
bool CheckElementCRC32(EbmlElement &ElementToCRC);
|
||||
|
||||
/*!
|
||||
CRC Checksum Calculation
|
||||
*/
|
||||
enum {DIGESTSIZE = 4};
|
||||
|
||||
/*!
|
||||
Use this to quickly check a CRC32 with some data
|
||||
\return True if inputCRC matches CRC32 generated from input data
|
||||
*/
|
||||
static bool CheckCRC(uint32 inputCRC, const binary *input, uint32 length);
|
||||
/*!
|
||||
Calls Update() and Finalize(), use to create a CRC32 in one go
|
||||
*/
|
||||
void FillCRC32(const binary *input, uint32 length);
|
||||
/*!
|
||||
Add data to the CRC table, in other words process some data bit by bit
|
||||
*/
|
||||
void Update(const binary *input, uint32 length);
|
||||
/*!
|
||||
Use this with Update() to Finalize() or Complete the CRC32
|
||||
*/
|
||||
void Finalize();
|
||||
/*!
|
||||
Returns a uint32 that has the value of the CRC32
|
||||
*/
|
||||
uint32 GetCrc32() const {
|
||||
return m_crc_final;
|
||||
};
|
||||
|
||||
void ForceCrc32(uint32 NewValue) { m_crc_final = NewValue; SetValueIsSet();}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
void ResetCRC() {m_crc = CRC32_NEGL;}
|
||||
void UpdateByte(binary b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
|
||||
|
||||
static const uint32 m_tab[256];
|
||||
uint32 m_crc;
|
||||
uint32 m_crc_final;
|
||||
|
||||
EBML_CONCRETE_CLASS(EbmlCrc32)
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline unsigned int GetAlignment(T *dummy=NULL) // VC60 workaround
|
||||
{
|
||||
#if (_MSC_VER >= 1300)
|
||||
return __alignof(T);
|
||||
#elif defined(__GNUC__)
|
||||
return __alignof__(T);
|
||||
#else
|
||||
return sizeof(T);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsPowerOf2(T n)
|
||||
{
|
||||
return n > 0 && (n & (n-1)) == 0;
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline T2 ModPowerOf2(T1 a, T2 b)
|
||||
{
|
||||
assert(IsPowerOf2(b));
|
||||
return T2(a) & (b-1);
|
||||
}
|
||||
|
||||
inline bool IsAlignedOn(const void *p, unsigned int alignment)
|
||||
{
|
||||
return IsPowerOf2(alignment) ? ModPowerOf2((uintptr_t)p, alignment) == 0 : (uintptr_t)p % alignment == 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsAligned(const void *p, T *dummy=NULL) // VC60 workaround
|
||||
{
|
||||
return IsAlignedOn(p, GetAlignment<T>());
|
||||
}
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_CRC32_H
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlDate.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_DATE_H
|
||||
@ -60,7 +60,7 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
|
||||
*/
|
||||
int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
|
||||
|
||||
virtual bool ValidateSize() const {return ((GetSize() == 8) || (GetSize() == 0));}
|
||||
virtual bool ValidateSize() const {return IsFiniteSize() && ((GetSize() == 8) || (GetSize() == 0));}
|
||||
|
||||
/*!
|
||||
\note no Default date handled
|
||||
|
@ -456,6 +456,7 @@ class EBML_DLL_API EbmlElement {
|
||||
bool ValueIsSet() const {return bValueIsSet;}
|
||||
|
||||
inline uint64 GetEndPosition() const {
|
||||
assert(bSizeIsFinite); // we don't know where the end is
|
||||
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlSInteger.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
@ -64,7 +64,7 @@ class EBML_DLL_API EbmlSInteger : public EbmlElement {
|
||||
*/
|
||||
virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_INT_SIZE) {EbmlElement::SetDefaultSize(nDefaultSize); SetSize_(nDefaultSize);}
|
||||
|
||||
virtual bool ValidateSize() const {return (GetSize() <= 8);}
|
||||
virtual bool ValidateSize() const {return IsFiniteSize() && (GetSize() <= 8);}
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
@ -1,85 +1,85 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlString.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_STRING_H
|
||||
#define LIBEBML_STRING_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlString
|
||||
\brief Handle all operations on a printable string EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlString : public EbmlElement {
|
||||
public:
|
||||
EbmlString();
|
||||
EbmlString(const std::string & aDefaultValue);
|
||||
EbmlString(const EbmlString & ElementToClone);
|
||||
|
||||
virtual ~EbmlString() {}
|
||||
|
||||
virtual bool ValidateSize() const {return true;} // any size is possible
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
||||
EbmlString & operator=(const std::string &);
|
||||
operator const std::string &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(std::string &);
|
||||
|
||||
const std::string & DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
std::string Value; /// The actual value of the element
|
||||
std::string DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_STRING_H
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_STRING_H
|
||||
#define LIBEBML_STRING_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlString
|
||||
\brief Handle all operations on a printable string EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlString : public EbmlElement {
|
||||
public:
|
||||
EbmlString();
|
||||
EbmlString(const std::string & aDefaultValue);
|
||||
EbmlString(const EbmlString & ElementToClone);
|
||||
|
||||
virtual ~EbmlString() {}
|
||||
|
||||
virtual bool ValidateSize() const {return IsFiniteSize();} // any size is possible
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
||||
EbmlString & operator=(const std::string &);
|
||||
operator const std::string &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(std::string &);
|
||||
|
||||
const std::string & DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
std::string Value; /// The actual value of the element
|
||||
std::string DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_STRING_H
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlUInteger.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
@ -62,7 +62,7 @@ class EBML_DLL_API EbmlUInteger : public EbmlElement {
|
||||
*/
|
||||
virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_UINT_SIZE) {EbmlElement::SetDefaultSize(nDefaultSize); SetSize_(nDefaultSize);}
|
||||
|
||||
virtual bool ValidateSize() const {return (GetSize() <= 8);}
|
||||
virtual bool ValidateSize() const {return IsFiniteSize() && (GetSize() <= 8);}
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
@ -1,134 +1,134 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id: EbmlUnicodeString.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
\author Jory Stone <jcsston @ toughguy.net>
|
||||
*/
|
||||
#ifndef LIBEBML_UNICODE_STRING_H
|
||||
#define LIBEBML_UNICODE_STRING_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class UTFstring
|
||||
A class storing strings in a wchar_t (ie, in UCS-2 or UCS-4)
|
||||
\note inspired by wstring which is not available everywhere
|
||||
*/
|
||||
class EBML_DLL_API UTFstring {
|
||||
public:
|
||||
typedef wchar_t value_type;
|
||||
|
||||
UTFstring();
|
||||
UTFstring(const wchar_t *); // should be NULL terminated
|
||||
UTFstring(const UTFstring &);
|
||||
|
||||
virtual ~UTFstring();
|
||||
bool operator==(const UTFstring&) const;
|
||||
inline bool operator!=(const UTFstring &cmp) const
|
||||
{
|
||||
return !(*this == cmp);
|
||||
}
|
||||
UTFstring & operator=(const UTFstring &);
|
||||
UTFstring & operator=(const wchar_t *);
|
||||
UTFstring & operator=(wchar_t);
|
||||
|
||||
/// Return length of string
|
||||
size_t length() const {return _Length;}
|
||||
|
||||
operator const wchar_t*() const {return _Data;}
|
||||
const wchar_t* c_str() const {return _Data;}
|
||||
|
||||
const std::string & GetUTF8() const {return UTF8string;}
|
||||
void SetUTF8(const std::string &);
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
size_t _Length; ///< length of the UCS string excluding the \0
|
||||
wchar_t* _Data; ///< internal UCS representation
|
||||
std::string UTF8string;
|
||||
static bool wcscmp_internal(const wchar_t *str1, const wchar_t *str2);
|
||||
void UpdateFromUTF8();
|
||||
void UpdateFromUCS2();
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\class EbmlUnicodeString
|
||||
\brief Handle all operations on a Unicode string EBML element
|
||||
\note internally treated as a string made of wide characters (ie UCS-2 or UCS-4 depending on the machine)
|
||||
*/
|
||||
class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
|
||||
public:
|
||||
EbmlUnicodeString();
|
||||
EbmlUnicodeString(const UTFstring & DefaultValue);
|
||||
EbmlUnicodeString(const EbmlUnicodeString & ElementToClone);
|
||||
|
||||
virtual ~EbmlUnicodeString() {}
|
||||
|
||||
virtual bool ValidateSize() const {return true;} // any size is possible
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
||||
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
|
||||
operator const UTFstring &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(UTFstring &);
|
||||
|
||||
const UTFstring & DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
UTFstring Value; /// The actual value of the element
|
||||
UTFstring DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_UNICODE_STRING_H
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
**
|
||||
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
|
||||
**
|
||||
** Contact license@matroska.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version \$Id$
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
\author Jory Stone <jcsston @ toughguy.net>
|
||||
*/
|
||||
#ifndef LIBEBML_UNICODE_STRING_H
|
||||
#define LIBEBML_UNICODE_STRING_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class UTFstring
|
||||
A class storing strings in a wchar_t (ie, in UCS-2 or UCS-4)
|
||||
\note inspired by wstring which is not available everywhere
|
||||
*/
|
||||
class EBML_DLL_API UTFstring {
|
||||
public:
|
||||
typedef wchar_t value_type;
|
||||
|
||||
UTFstring();
|
||||
UTFstring(const wchar_t *); // should be NULL terminated
|
||||
UTFstring(const UTFstring &);
|
||||
|
||||
virtual ~UTFstring();
|
||||
bool operator==(const UTFstring&) const;
|
||||
inline bool operator!=(const UTFstring &cmp) const
|
||||
{
|
||||
return !(*this == cmp);
|
||||
}
|
||||
UTFstring & operator=(const UTFstring &);
|
||||
UTFstring & operator=(const wchar_t *);
|
||||
UTFstring & operator=(wchar_t);
|
||||
|
||||
/// Return length of string
|
||||
size_t length() const {return _Length;}
|
||||
|
||||
operator const wchar_t*() const {return _Data;}
|
||||
const wchar_t* c_str() const {return _Data;}
|
||||
|
||||
const std::string & GetUTF8() const {return UTF8string;}
|
||||
void SetUTF8(const std::string &);
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
size_t _Length; ///< length of the UCS string excluding the \0
|
||||
wchar_t* _Data; ///< internal UCS representation
|
||||
std::string UTF8string;
|
||||
static bool wcscmp_internal(const wchar_t *str1, const wchar_t *str2);
|
||||
void UpdateFromUTF8();
|
||||
void UpdateFromUCS2();
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\class EbmlUnicodeString
|
||||
\brief Handle all operations on a Unicode string EBML element
|
||||
\note internally treated as a string made of wide characters (ie UCS-2 or UCS-4 depending on the machine)
|
||||
*/
|
||||
class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
|
||||
public:
|
||||
EbmlUnicodeString();
|
||||
EbmlUnicodeString(const UTFstring & DefaultValue);
|
||||
EbmlUnicodeString(const EbmlUnicodeString & ElementToClone);
|
||||
|
||||
virtual ~EbmlUnicodeString() {}
|
||||
|
||||
virtual bool ValidateSize() const {return IsFiniteSize();} // any size is possible
|
||||
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
|
||||
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
|
||||
|
||||
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
|
||||
operator const UTFstring &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(UTFstring &);
|
||||
|
||||
const UTFstring & DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
UTFstring Value; /// The actual value of the element
|
||||
UTFstring DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_UNICODE_STRING_H
|
||||
|
Loading…
Reference in New Issue
Block a user