disable access to internal values when EBML_STRICT_API is defined
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@20 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
parent
c331b9b443
commit
66f1b56fba
@ -1,103 +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 <string>
|
||||
#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);
|
||||
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = 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;
|
||||
|
||||
protected:
|
||||
binary *GetData() const {return Data;}
|
||||
|
||||
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: 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 <string>
|
||||
#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);
|
||||
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = 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;
|
||||
|
||||
protected:
|
||||
binary *GetData() const {return Data;}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#endif
|
||||
binary *Data; // the binary data inside the element
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_BINARY_H
|
||||
|
306
ebml/EbmlCrc32.h
306
ebml/EbmlCrc32.h
@ -1,151 +1,155 @@
|
||||
/****************************************************************************
|
||||
** 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 "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
|
||||
|
||||
class EBML_DLL_API EbmlCrc32 : public EbmlBinary {
|
||||
public:
|
||||
EbmlCrc32();
|
||||
EbmlCrc32(const EbmlCrc32 & ElementToClone);
|
||||
bool ValidateSize() const {return (GetSize() == 4);}
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
// uint64 UpdateSize(bool bKeepIntact = 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();}
|
||||
|
||||
protected:
|
||||
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: 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 "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
|
||||
|
||||
class EBML_DLL_API EbmlCrc32 : public EbmlBinary {
|
||||
public:
|
||||
EbmlCrc32();
|
||||
EbmlCrc32(const EbmlCrc32 & ElementToClone);
|
||||
bool ValidateSize() const {return (GetSize() == 4);}
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
// uint64 UpdateSize(bool bKeepIntact = 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
|
||||
|
192
ebml/EbmlDate.h
192
ebml/EbmlDate.h
@ -1,94 +1,98 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** 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: EbmlDate.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_DATE_H
|
||||
#define LIBEBML_DATE_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlDate
|
||||
\brief Handle all operations related to an EBML date
|
||||
*/
|
||||
class EBML_DLL_API EbmlDate : public EbmlElement {
|
||||
public:
|
||||
EbmlDate() :EbmlElement(8, false), myDate(0) {}
|
||||
EbmlDate(const EbmlDate & ElementToClone);
|
||||
|
||||
/*!
|
||||
\brief set the date with a UNIX/C/EPOCH form
|
||||
\param NewDate UNIX/C date in UTC (no timezone)
|
||||
*/
|
||||
void SetEpochDate(int32 NewDate) {myDate = int64(NewDate - UnixEpochDelay) * 1000000000; SetValueIsSet();}
|
||||
|
||||
/*!
|
||||
\brief get the date with a UNIX/C/EPOCH form
|
||||
\note the date is in UTC (no timezone)
|
||||
*/
|
||||
int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
|
||||
|
||||
bool ValidateSize() const {return ((GetSize() == 8) || (GetSize() == 0));}
|
||||
|
||||
/*!
|
||||
\note no Default date handled
|
||||
*/
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) {
|
||||
if(!ValueIsSet())
|
||||
SetSize_(0);
|
||||
else
|
||||
SetSize_(8);
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
bool operator<(const EbmlDate & EltCmp) const {return myDate < EltCmp.myDate;}
|
||||
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
|
||||
int64 myDate; ///< internal format of the date
|
||||
|
||||
static const uint64 UnixEpochDelay;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_DATE_H
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** 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: EbmlDate.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_DATE_H
|
||||
#define LIBEBML_DATE_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlDate
|
||||
\brief Handle all operations related to an EBML date
|
||||
*/
|
||||
class EBML_DLL_API EbmlDate : public EbmlElement {
|
||||
public:
|
||||
EbmlDate() :EbmlElement(8, false), myDate(0) {}
|
||||
EbmlDate(const EbmlDate & ElementToClone);
|
||||
|
||||
/*!
|
||||
\brief set the date with a UNIX/C/EPOCH form
|
||||
\param NewDate UNIX/C date in UTC (no timezone)
|
||||
*/
|
||||
void SetEpochDate(int32 NewDate) {myDate = int64(NewDate - UnixEpochDelay) * 1000000000; SetValueIsSet();}
|
||||
|
||||
/*!
|
||||
\brief get the date with a UNIX/C/EPOCH form
|
||||
\note the date is in UTC (no timezone)
|
||||
*/
|
||||
int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
|
||||
|
||||
bool ValidateSize() const {return ((GetSize() == 8) || (GetSize() == 0));}
|
||||
|
||||
/*!
|
||||
\note no Default date handled
|
||||
*/
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) {
|
||||
if(!ValueIsSet())
|
||||
SetSize_(0);
|
||||
else
|
||||
SetSize_(8);
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
bool operator<(const EbmlDate & EltCmp) const {return myDate < EltCmp.myDate;}
|
||||
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
|
||||
int64 myDate; ///< internal format of the date
|
||||
|
||||
static const uint64 UnixEpochDelay;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_DATE_H
|
||||
|
128
ebml/EbmlDummy.h
128
ebml/EbmlDummy.h
@ -1,62 +1,66 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlDummy.h 639 2004-07-09 20:59:14Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_DUMMY_H
|
||||
#define LIBEBML_DUMMY_H
|
||||
|
||||
#include "EbmlBinary.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
class EBML_DLL_API EbmlDummy : public EbmlBinary {
|
||||
public:
|
||||
EbmlDummy() :DummyId(DummyRawId) {}
|
||||
EbmlDummy(const EbmlId & aId) :EbmlBinary(), DummyId(aId) {}
|
||||
EbmlDummy(const EbmlDummy & ElementToClone):EbmlBinary(ElementToClone), DummyId(ElementToClone.DummyId) {}
|
||||
|
||||
bool ValidateSize() const {return true;}
|
||||
bool IsDummy() const {return true;}
|
||||
bool IsDefaultValue() const {return true;}
|
||||
|
||||
protected:
|
||||
const EbmlId DummyId;
|
||||
static const EbmlId DummyRawId;
|
||||
|
||||
EBML_CONCRETE_CLASS(EbmlDummy)
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_DUMMY_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: EbmlDummy.h 639 2004-07-09 20:59:14Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_DUMMY_H
|
||||
#define LIBEBML_DUMMY_H
|
||||
|
||||
#include "EbmlBinary.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
class EBML_DLL_API EbmlDummy : public EbmlBinary {
|
||||
public:
|
||||
EbmlDummy() :DummyId(DummyRawId) {}
|
||||
EbmlDummy(const EbmlId & aId) :EbmlBinary(), DummyId(aId) {}
|
||||
EbmlDummy(const EbmlDummy & ElementToClone):EbmlBinary(ElementToClone), DummyId(ElementToClone.DummyId) {}
|
||||
|
||||
bool ValidateSize() const {return true;}
|
||||
bool IsDummy() const {return true;}
|
||||
bool IsDefaultValue() const {return true;}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
const EbmlId DummyId;
|
||||
static const EbmlId DummyRawId;
|
||||
|
||||
EBML_CONCRETE_CLASS(EbmlDummy)
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_DUMMY_H
|
||||
|
@ -1,301 +1,329 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** 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: EbmlElement.h 1232 2005-10-15 15:56:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_ELEMENT_H
|
||||
#define LIBEBML_ELEMENT_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlId.h"
|
||||
#include "IOCallback.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\brief The size of the EBML-coded length
|
||||
*/
|
||||
int EBML_DLL_API CodedSizeLength(uint64 Length, unsigned int SizeLength, bool bSizeIsFinite = true);
|
||||
|
||||
/*!
|
||||
\brief The coded value of the EBML-coded length
|
||||
\note The size of OutBuffer must be 8 octets at least
|
||||
*/
|
||||
int EBML_DLL_API CodedValueLength(uint64 Length, int CodedSize, binary * OutBuffer);
|
||||
|
||||
/*!
|
||||
\brief Read an EBML-coded value from a buffer
|
||||
\return the value read
|
||||
*/
|
||||
uint64 EBML_DLL_API ReadCodedSizeValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
|
||||
|
||||
/*!
|
||||
\brief The size of the EBML-coded signed length
|
||||
*/
|
||||
int EBML_DLL_API CodedSizeLengthSigned(int64 Length, unsigned int SizeLength);
|
||||
|
||||
/*!
|
||||
\brief The coded value of the EBML-coded signed length
|
||||
\note the size of OutBuffer must be 8 octets at least
|
||||
*/
|
||||
int EBML_DLL_API CodedValueLengthSigned(int64 Length, int CodedSize, binary * OutBuffer);
|
||||
|
||||
/*!
|
||||
\brief Read a signed EBML-coded value from a buffer
|
||||
\return the value read
|
||||
*/
|
||||
int64 EBML_DLL_API ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
|
||||
|
||||
class EbmlStream;
|
||||
class EbmlSemanticContext;
|
||||
class EbmlElement;
|
||||
|
||||
// functions for generic handling of data (should be static to all classes)
|
||||
/*!
|
||||
\todo Handle default value
|
||||
*/
|
||||
class EBML_DLL_API EbmlCallbacks {
|
||||
public:
|
||||
EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext)
|
||||
:Create(Creator)
|
||||
,GlobalId(aGlobalId)
|
||||
,DebugName(aDebugName)
|
||||
,Context(aContext)
|
||||
{}
|
||||
|
||||
EbmlElement & (*Create)();
|
||||
const EbmlId & GlobalId;
|
||||
const char * DebugName;
|
||||
const EbmlSemanticContext & Context;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief contains the semantic informations for a given level and all sublevels
|
||||
\todo move the ID in the element class
|
||||
*/
|
||||
class EBML_DLL_API EbmlSemantic {
|
||||
public:
|
||||
EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks)
|
||||
:Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {}
|
||||
|
||||
bool Mandatory; ///< wether the element is mandatory in the context or not
|
||||
bool Unique;
|
||||
const EbmlCallbacks & GetCallbacks;
|
||||
};
|
||||
|
||||
typedef const class EbmlSemanticContext & (*_GetSemanticContext)();
|
||||
|
||||
/*!
|
||||
Context of the element
|
||||
\todo allow more than one parent ?
|
||||
*/
|
||||
class EBML_DLL_API EbmlSemanticContext {
|
||||
public:
|
||||
EbmlSemanticContext(unsigned int aSize,
|
||||
const EbmlSemantic *aMyTable,
|
||||
const EbmlSemanticContext *aUpTable,
|
||||
const _GetSemanticContext aGetGlobalContext,
|
||||
const EbmlCallbacks *aMasterElt)
|
||||
:Size(aSize), MyTable(aMyTable), UpTable(aUpTable),
|
||||
GetGlobalContext(aGetGlobalContext), MasterElt(aMasterElt) {}
|
||||
|
||||
bool operator!=(const EbmlSemanticContext & aElt) const {
|
||||
return ((Size != aElt.Size) || (MyTable != aElt.MyTable) ||
|
||||
(UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) |
|
||||
(MasterElt != aElt.MasterElt));
|
||||
}
|
||||
|
||||
|
||||
unsigned int Size; ///< number of elements in the table
|
||||
const EbmlSemantic *MyTable; ///< First element in the table
|
||||
const EbmlSemanticContext *UpTable; ///< Parent element
|
||||
/// \todo replace with the global context directly
|
||||
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
|
||||
const EbmlCallbacks *MasterElt;
|
||||
};
|
||||
|
||||
#define EBML_CONCRETE_CLASS(Type) \
|
||||
public: \
|
||||
virtual const EbmlCallbacks & Generic() const {return ClassInfos;} \
|
||||
virtual operator const EbmlId &() const {return ClassInfos.GlobalId;} \
|
||||
virtual EbmlElement & CreateElement() const {return Create();} \
|
||||
virtual EbmlElement * Clone() const { return new Type(*this); } \
|
||||
static EbmlElement & Create() {return *(new Type);} \
|
||||
static const EbmlCallbacks ClassInfos; \
|
||||
|
||||
#define EBML_INFO(ref) ref::ClassInfos
|
||||
#define EBML_ID(ref) ref::ClassInfos.GlobalId
|
||||
#define EBML_CONTEXT(e) e->Generic().Context
|
||||
#define EBML_NAME(e) e->Generic().DebugName
|
||||
|
||||
/*!
|
||||
\class EbmlElement
|
||||
\brief Hold basic informations about an EBML element (ID + length)
|
||||
*/
|
||||
class EBML_DLL_API EbmlElement {
|
||||
public:
|
||||
EbmlElement(uint64 aDefaultSize, bool bValueSet = false);
|
||||
virtual ~EbmlElement() {assert(!bLocked);}
|
||||
|
||||
/// Set the minimum length that will be used to write the element size (-1 = optimal)
|
||||
void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;}
|
||||
int GetSizeLength() const {return SizeLength;}
|
||||
|
||||
static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
|
||||
static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
|
||||
|
||||
/*!
|
||||
\brief find the next element with the same ID
|
||||
*/
|
||||
EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize);
|
||||
|
||||
EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false);
|
||||
|
||||
/*!
|
||||
\brief Give a copy of the element, all data inside the element is copied
|
||||
\return NULL if there is not enough memory
|
||||
*/
|
||||
virtual EbmlElement * Clone() const = 0;
|
||||
|
||||
virtual operator const EbmlId &() const = 0;
|
||||
/// return the generic callback to monitor a derived class
|
||||
virtual const EbmlCallbacks & Generic() const = 0;
|
||||
virtual EbmlElement & CreateElement() const = 0;
|
||||
|
||||
// by default only allow to set element as finite (override when needed)
|
||||
virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;}
|
||||
|
||||
virtual bool ValidateSize() const = 0;
|
||||
|
||||
uint64 GetElementPosition() const {
|
||||
return ElementPosition;
|
||||
}
|
||||
|
||||
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing
|
||||
|
||||
uint32 Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false);
|
||||
|
||||
virtual uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored
|
||||
virtual uint64 GetSize() const {return Size;} /// return the size of the data stored in the element, on reading
|
||||
|
||||
virtual uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
|
||||
virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
|
||||
bool IsLocked() const {return bLocked;}
|
||||
void Lock(bool bLock = true) { bLocked = bLock;}
|
||||
|
||||
/*!
|
||||
\brief default comparison for elements that can't be compared
|
||||
*/
|
||||
virtual bool operator<(const EbmlElement & EltB) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CompareElements(const EbmlElement *A, const EbmlElement *B);
|
||||
|
||||
virtual bool IsDummy() const {return false;}
|
||||
virtual bool IsMaster() const {return false;}
|
||||
|
||||
uint8 HeadSize() const {
|
||||
return EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
|
||||
} /// return the size of the head, on reading/writing
|
||||
|
||||
/*!
|
||||
\brief Force the size of an element
|
||||
\warning only possible if the size is "undefined"
|
||||
*/
|
||||
bool ForceSize(uint64 NewSize);
|
||||
|
||||
uint32 OverwriteHead(IOCallback & output, bool bKeepPosition = false);
|
||||
|
||||
/*!
|
||||
\brief void the content of the element (replace by EbmlVoid)
|
||||
*/
|
||||
uint32 VoidMe(IOCallback & output, bool bKeepIntact = false);
|
||||
|
||||
bool DefaultISset() const {return DefaultIsSet;}
|
||||
virtual bool IsDefaultValue() const = 0;
|
||||
bool IsFiniteSize() const {return bSizeIsFinite;}
|
||||
|
||||
/*!
|
||||
\brief set the default size of an element
|
||||
*/
|
||||
virtual void SetDefaultSize(uint64 aDefaultSize) {DefaultSize = aDefaultSize;}
|
||||
|
||||
bool ValueIsSet() const {return bValueIsSet;}
|
||||
|
||||
inline uint64 GetEndPosition() const {
|
||||
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
|
||||
}
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief find any element in the stream
|
||||
\return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed
|
||||
*/
|
||||
static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1);
|
||||
|
||||
uint32 RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false);
|
||||
uint32 MakeRenderHead(IOCallback & output, bool bKeepPosition);
|
||||
|
||||
/*!
|
||||
\brief prepare the data before writing them (in case it's not already done by default)
|
||||
*/
|
||||
virtual uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0;
|
||||
|
||||
/*!
|
||||
\brief special constructor for cloning
|
||||
*/
|
||||
EbmlElement(const EbmlElement & ElementToClone);
|
||||
|
||||
inline uint64 GetDefaultSize() const {return DefaultSize;}
|
||||
inline void SetSize_(uint64 aSize) {Size = aSize;}
|
||||
inline void SetValueIsSet(bool Set = true) {bValueIsSet = Set;}
|
||||
inline void SetDefaultIsSet(bool Set = true) {DefaultIsSet = Set;}
|
||||
inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;}
|
||||
inline uint64 GetSizePosition() const {return SizePosition;}
|
||||
|
||||
uint64 Size; ///< the size of the data to write
|
||||
uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal)
|
||||
int SizeLength; /// the minimum size on which the size will be written (0 = optimal)
|
||||
bool bSizeIsFinite;
|
||||
uint64 ElementPosition;
|
||||
uint64 SizePosition;
|
||||
bool bValueIsSet;
|
||||
bool DefaultIsSet;
|
||||
bool bLocked;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_ELEMENT_H
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** 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: EbmlElement.h 1232 2005-10-15 15:56:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_ELEMENT_H
|
||||
#define LIBEBML_ELEMENT_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlId.h"
|
||||
#include "IOCallback.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\brief The size of the EBML-coded length
|
||||
*/
|
||||
int EBML_DLL_API CodedSizeLength(uint64 Length, unsigned int SizeLength, bool bSizeIsFinite = true);
|
||||
|
||||
/*!
|
||||
\brief The coded value of the EBML-coded length
|
||||
\note The size of OutBuffer must be 8 octets at least
|
||||
*/
|
||||
int EBML_DLL_API CodedValueLength(uint64 Length, int CodedSize, binary * OutBuffer);
|
||||
|
||||
/*!
|
||||
\brief Read an EBML-coded value from a buffer
|
||||
\return the value read
|
||||
*/
|
||||
uint64 EBML_DLL_API ReadCodedSizeValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
|
||||
|
||||
/*!
|
||||
\brief The size of the EBML-coded signed length
|
||||
*/
|
||||
int EBML_DLL_API CodedSizeLengthSigned(int64 Length, unsigned int SizeLength);
|
||||
|
||||
/*!
|
||||
\brief The coded value of the EBML-coded signed length
|
||||
\note the size of OutBuffer must be 8 octets at least
|
||||
*/
|
||||
int EBML_DLL_API CodedValueLengthSigned(int64 Length, int CodedSize, binary * OutBuffer);
|
||||
|
||||
/*!
|
||||
\brief Read a signed EBML-coded value from a buffer
|
||||
\return the value read
|
||||
*/
|
||||
int64 EBML_DLL_API ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
|
||||
|
||||
class EbmlStream;
|
||||
class EbmlSemanticContext;
|
||||
class EbmlElement;
|
||||
|
||||
// functions for generic handling of data (should be static to all classes)
|
||||
/*!
|
||||
\todo Handle default value
|
||||
*/
|
||||
class EBML_DLL_API EbmlCallbacks {
|
||||
public:
|
||||
EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext)
|
||||
:Create(Creator)
|
||||
,GlobalId(aGlobalId)
|
||||
,DebugName(aDebugName)
|
||||
,Context(aContext)
|
||||
{}
|
||||
|
||||
EbmlElement & (*Create)();
|
||||
const EbmlId & GlobalId;
|
||||
const char * DebugName;
|
||||
const EbmlSemanticContext & Context;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief contains the semantic informations for a given level and all sublevels
|
||||
\todo move the ID in the element class
|
||||
*/
|
||||
class EBML_DLL_API EbmlSemantic {
|
||||
public:
|
||||
EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks)
|
||||
:Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {}
|
||||
|
||||
bool Mandatory; ///< wether the element is mandatory in the context or not
|
||||
bool Unique;
|
||||
const EbmlCallbacks & GetCallbacks;
|
||||
};
|
||||
|
||||
typedef const class EbmlSemanticContext & (*_GetSemanticContext)();
|
||||
|
||||
/*!
|
||||
Context of the element
|
||||
\todo allow more than one parent ?
|
||||
*/
|
||||
class EBML_DLL_API EbmlSemanticContext {
|
||||
public:
|
||||
EbmlSemanticContext(unsigned int aSize,
|
||||
const EbmlSemantic *aMyTable,
|
||||
const EbmlSemanticContext *aUpTable,
|
||||
const _GetSemanticContext aGetGlobalContext,
|
||||
const EbmlCallbacks *aMasterElt)
|
||||
:Size(aSize), MyTable(aMyTable), UpTable(aUpTable),
|
||||
GetGlobalContext(aGetGlobalContext), MasterElt(aMasterElt) {}
|
||||
|
||||
bool operator!=(const EbmlSemanticContext & aElt) const {
|
||||
return ((Size != aElt.Size) || (MyTable != aElt.MyTable) ||
|
||||
(UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) |
|
||||
(MasterElt != aElt.MasterElt));
|
||||
}
|
||||
|
||||
|
||||
unsigned int Size; ///< number of elements in the table
|
||||
const EbmlSemantic *MyTable; ///< First element in the table
|
||||
const EbmlSemanticContext *UpTable; ///< Parent element
|
||||
/// \todo replace with the global context directly
|
||||
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
|
||||
const EbmlCallbacks *MasterElt;
|
||||
};
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
#define EBML_CONCRETE_CLASS(Type) \
|
||||
public: \
|
||||
virtual const EbmlSemanticContext &Context() const {return ClassInfos.Context;} \
|
||||
virtual const char *DebugName() const {return ClassInfos.DebugName;} \
|
||||
virtual operator const EbmlId &() const {return ClassInfos.GlobalId;} \
|
||||
virtual EbmlElement & CreateElement() const {return Create();} \
|
||||
virtual EbmlElement * Clone() const { return new Type(*this); } \
|
||||
static EbmlElement & Create() {return *(new Type);} \
|
||||
static const EbmlCallbacks & ClassInfo() {return ClassInfos;} \
|
||||
static const EbmlId & ClassId() {return ClassInfos.GlobalId;} \
|
||||
private: \
|
||||
static const EbmlCallbacks ClassInfos; \
|
||||
|
||||
#define EBML_INFO(ref) ref::ClassInfo()
|
||||
#define EBML_ID(ref) ref::ClassId()
|
||||
#define EBML_CONTEXT(e) e->Context()
|
||||
#define EBML_NAME(e) e->DebugName()
|
||||
#else
|
||||
#define EBML_CONCRETE_CLASS(Type) \
|
||||
public: \
|
||||
virtual const EbmlCallbacks & Generic() const {return ClassInfos;} \
|
||||
virtual operator const EbmlId &() const {return ClassInfos.GlobalId;} \
|
||||
virtual EbmlElement & CreateElement() const {return Create();} \
|
||||
virtual EbmlElement * Clone() const { return new Type(*this); } \
|
||||
static EbmlElement & Create() {return *(new Type);} \
|
||||
static const EbmlCallbacks ClassInfos; \
|
||||
|
||||
#define EBML_INFO(ref) ref::ClassInfos
|
||||
#define EBML_ID(ref) ref::ClassInfos.GlobalId
|
||||
#define EBML_CONTEXT(e) e->Generic().Context
|
||||
#define EBML_NAME(e) e->Generic().DebugName
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class EbmlElement
|
||||
\brief Hold basic informations about an EBML element (ID + length)
|
||||
*/
|
||||
class EBML_DLL_API EbmlElement {
|
||||
public:
|
||||
EbmlElement(uint64 aDefaultSize, bool bValueSet = false);
|
||||
virtual ~EbmlElement() {assert(!bLocked);}
|
||||
|
||||
/// Set the minimum length that will be used to write the element size (-1 = optimal)
|
||||
void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;}
|
||||
int GetSizeLength() const {return SizeLength;}
|
||||
|
||||
static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
|
||||
static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
|
||||
|
||||
/*!
|
||||
\brief find the next element with the same ID
|
||||
*/
|
||||
EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize);
|
||||
|
||||
EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false);
|
||||
|
||||
/*!
|
||||
\brief Give a copy of the element, all data inside the element is copied
|
||||
\return NULL if there is not enough memory
|
||||
*/
|
||||
virtual EbmlElement * Clone() const = 0;
|
||||
|
||||
virtual operator const EbmlId &() const = 0;
|
||||
#if defined(EBML_STRICT_API)
|
||||
virtual const char *DebugName() const = 0;
|
||||
virtual const EbmlSemanticContext &Context() const = 0;
|
||||
#else
|
||||
/// return the generic callback to monitor a derived class
|
||||
virtual const EbmlCallbacks & Generic() const = 0;
|
||||
#endif
|
||||
virtual EbmlElement & CreateElement() const = 0;
|
||||
|
||||
// by default only allow to set element as finite (override when needed)
|
||||
virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;}
|
||||
|
||||
virtual bool ValidateSize() const = 0;
|
||||
|
||||
uint64 GetElementPosition() const {
|
||||
return ElementPosition;
|
||||
}
|
||||
|
||||
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing
|
||||
|
||||
uint32 Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false);
|
||||
|
||||
virtual uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored
|
||||
virtual uint64 GetSize() const {return Size;} /// return the size of the data stored in the element, on reading
|
||||
|
||||
virtual uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
|
||||
virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
|
||||
bool IsLocked() const {return bLocked;}
|
||||
void Lock(bool bLock = true) { bLocked = bLock;}
|
||||
|
||||
/*!
|
||||
\brief default comparison for elements that can't be compared
|
||||
*/
|
||||
virtual bool operator<(const EbmlElement & EltB) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CompareElements(const EbmlElement *A, const EbmlElement *B);
|
||||
|
||||
virtual bool IsDummy() const {return false;}
|
||||
virtual bool IsMaster() const {return false;}
|
||||
|
||||
uint8 HeadSize() const {
|
||||
return EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
|
||||
} /// return the size of the head, on reading/writing
|
||||
|
||||
/*!
|
||||
\brief Force the size of an element
|
||||
\warning only possible if the size is "undefined"
|
||||
*/
|
||||
bool ForceSize(uint64 NewSize);
|
||||
|
||||
uint32 OverwriteHead(IOCallback & output, bool bKeepPosition = false);
|
||||
|
||||
/*!
|
||||
\brief void the content of the element (replace by EbmlVoid)
|
||||
*/
|
||||
uint32 VoidMe(IOCallback & output, bool bKeepIntact = false);
|
||||
|
||||
bool DefaultISset() const {return DefaultIsSet;}
|
||||
virtual bool IsDefaultValue() const = 0;
|
||||
bool IsFiniteSize() const {return bSizeIsFinite;}
|
||||
|
||||
/*!
|
||||
\brief set the default size of an element
|
||||
*/
|
||||
virtual void SetDefaultSize(uint64 aDefaultSize) {DefaultSize = aDefaultSize;}
|
||||
|
||||
bool ValueIsSet() const {return bValueIsSet;}
|
||||
|
||||
inline uint64 GetEndPosition() const {
|
||||
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
|
||||
}
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief find any element in the stream
|
||||
\return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed
|
||||
*/
|
||||
static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1);
|
||||
|
||||
uint32 RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false);
|
||||
uint32 MakeRenderHead(IOCallback & output, bool bKeepPosition);
|
||||
|
||||
/*!
|
||||
\brief prepare the data before writing them (in case it's not already done by default)
|
||||
*/
|
||||
virtual uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0;
|
||||
|
||||
/*!
|
||||
\brief special constructor for cloning
|
||||
*/
|
||||
EbmlElement(const EbmlElement & ElementToClone);
|
||||
|
||||
inline uint64 GetDefaultSize() const {return DefaultSize;}
|
||||
inline void SetSize_(uint64 aSize) {Size = aSize;}
|
||||
inline void SetValueIsSet(bool Set = true) {bValueIsSet = Set;}
|
||||
inline void SetDefaultIsSet(bool Set = true) {DefaultIsSet = Set;}
|
||||
inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;}
|
||||
inline uint64 GetSizePosition() const {return SizePosition;}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#endif
|
||||
uint64 Size; ///< the size of the data to write
|
||||
uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal)
|
||||
int SizeLength; /// the minimum size on which the size will be written (0 = optimal)
|
||||
bool bSizeIsFinite;
|
||||
uint64 ElementPosition;
|
||||
uint64 SizePosition;
|
||||
bool bValueIsSet;
|
||||
bool DefaultIsSet;
|
||||
bool bLocked;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_ELEMENT_H
|
||||
|
@ -1,120 +1,124 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlEndian.h 1298 2008-02-21 22:14:18Z mosu $
|
||||
\author Ingo Ralf Blum <ingoralfblum @ users.sf.net>
|
||||
\author Lasse Kärkkäinen <tronic @ users.sf.net>
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_ENDIAN_H
|
||||
#define LIBEBML_ENDIAN_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "EbmlConfig.h" // contains _ENDIANESS_
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
enum endianess {
|
||||
big_endian, ///< PowerPC, Alpha, 68000
|
||||
little_endian ///< Intel x86 platforms
|
||||
};
|
||||
|
||||
/*!
|
||||
\class Endian
|
||||
\brief general class to handle endian-specific buffers
|
||||
\note don't forget to define/undefine _ENDIANESS_ to BIG_ENDIAN depending on your machine
|
||||
*/
|
||||
template<class TYPE, endianess ENDIAN> class Endian
|
||||
{
|
||||
public:
|
||||
Endian() {}
|
||||
|
||||
Endian(const TYPE value)
|
||||
{
|
||||
memcpy(&platform_value, &value, sizeof(TYPE));
|
||||
process_endian();
|
||||
}
|
||||
|
||||
inline Endian & Eval(const binary *endian_buffer)
|
||||
{
|
||||
//endian_value = *(TYPE *)(endian_buffer);
|
||||
memcpy(&endian_value, endian_buffer, sizeof(TYPE)); // Some (all?) RISC processors do not allow reading objects bigger than 1 byte from non-aligned addresses, and endian_buffer may point to a non-aligned address.
|
||||
process_platform();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Fill(binary *endian_buffer) const
|
||||
{
|
||||
//*(TYPE*)endian_buffer = endian_value;
|
||||
memcpy(endian_buffer, &endian_value, sizeof(TYPE)); // See above.
|
||||
}
|
||||
|
||||
inline operator const TYPE&() const { return platform_value; }
|
||||
// inline TYPE endian() const { return endian_value; }
|
||||
inline const TYPE &endian() const { return endian_value; }
|
||||
inline size_t size() const { return sizeof(TYPE); }
|
||||
inline bool operator!=(const binary *buffer) const {return *((TYPE*)buffer) == platform_value;}
|
||||
|
||||
protected:
|
||||
TYPE platform_value;
|
||||
TYPE endian_value;
|
||||
|
||||
inline void process_endian()
|
||||
{
|
||||
endian_value = platform_value;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (ENDIAN == little_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&endian_value),reinterpret_cast<uint8*>(&endian_value+1));
|
||||
#else // _ENDIANESS_
|
||||
if (ENDIAN == big_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&endian_value),reinterpret_cast<uint8*>(&endian_value+1));
|
||||
#endif // _ENDIANESS_
|
||||
}
|
||||
|
||||
inline void process_platform()
|
||||
{
|
||||
platform_value = endian_value;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (ENDIAN == little_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&platform_value),reinterpret_cast<uint8*>(&platform_value+1));
|
||||
#else // _ENDIANESS_
|
||||
if (ENDIAN == big_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&platform_value),reinterpret_cast<uint8*>(&platform_value+1));
|
||||
#endif // _ENDIANESS_
|
||||
}
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_ENDIAN_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: EbmlEndian.h 1298 2008-02-21 22:14:18Z mosu $
|
||||
\author Ingo Ralf Blum <ingoralfblum @ users.sf.net>
|
||||
\author Lasse Kärkkäinen <tronic @ users.sf.net>
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_ENDIAN_H
|
||||
#define LIBEBML_ENDIAN_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "EbmlConfig.h" // contains _ENDIANESS_
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
enum endianess {
|
||||
big_endian, ///< PowerPC, Alpha, 68000
|
||||
little_endian ///< Intel x86 platforms
|
||||
};
|
||||
|
||||
/*!
|
||||
\class Endian
|
||||
\brief general class to handle endian-specific buffers
|
||||
\note don't forget to define/undefine _ENDIANESS_ to BIG_ENDIAN depending on your machine
|
||||
*/
|
||||
template<class TYPE, endianess ENDIAN> class Endian
|
||||
{
|
||||
public:
|
||||
Endian() {}
|
||||
|
||||
Endian(const TYPE value)
|
||||
{
|
||||
memcpy(&platform_value, &value, sizeof(TYPE));
|
||||
process_endian();
|
||||
}
|
||||
|
||||
inline Endian & Eval(const binary *endian_buffer)
|
||||
{
|
||||
//endian_value = *(TYPE *)(endian_buffer);
|
||||
memcpy(&endian_value, endian_buffer, sizeof(TYPE)); // Some (all?) RISC processors do not allow reading objects bigger than 1 byte from non-aligned addresses, and endian_buffer may point to a non-aligned address.
|
||||
process_platform();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Fill(binary *endian_buffer) const
|
||||
{
|
||||
//*(TYPE*)endian_buffer = endian_value;
|
||||
memcpy(endian_buffer, &endian_value, sizeof(TYPE)); // See above.
|
||||
}
|
||||
|
||||
inline operator const TYPE&() const { return platform_value; }
|
||||
// inline TYPE endian() const { return endian_value; }
|
||||
inline const TYPE &endian() const { return endian_value; }
|
||||
inline size_t size() const { return sizeof(TYPE); }
|
||||
inline bool operator!=(const binary *buffer) const {return *((TYPE*)buffer) == platform_value;}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
TYPE platform_value;
|
||||
TYPE endian_value;
|
||||
|
||||
inline void process_endian()
|
||||
{
|
||||
endian_value = platform_value;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (ENDIAN == little_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&endian_value),reinterpret_cast<uint8*>(&endian_value+1));
|
||||
#else // _ENDIANESS_
|
||||
if (ENDIAN == big_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&endian_value),reinterpret_cast<uint8*>(&endian_value+1));
|
||||
#endif // _ENDIANESS_
|
||||
}
|
||||
|
||||
inline void process_platform()
|
||||
{
|
||||
platform_value = endian_value;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (ENDIAN == little_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&platform_value),reinterpret_cast<uint8*>(&platform_value+1));
|
||||
#else // _ENDIANESS_
|
||||
if (ENDIAN == big_endian)
|
||||
std::reverse(reinterpret_cast<uint8*>(&platform_value),reinterpret_cast<uint8*>(&platform_value+1));
|
||||
#endif // _ENDIANESS_
|
||||
}
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_ENDIAN_H
|
||||
|
204
ebml/EbmlFloat.h
204
ebml/EbmlFloat.h
@ -1,100 +1,104 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlFloat.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_FLOAT_H
|
||||
#define LIBEBML_FLOAT_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlFloat
|
||||
\brief Handle all operations on a float EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlFloat : public EbmlElement {
|
||||
public:
|
||||
enum Precision {
|
||||
FLOAT_32
|
||||
,FLOAT_64
|
||||
};
|
||||
|
||||
EbmlFloat(const Precision prec = FLOAT_32);
|
||||
EbmlFloat(const double DefaultValue, const Precision prec = FLOAT_32);
|
||||
EbmlFloat(const EbmlFloat & ElementToClone);
|
||||
|
||||
bool ValidateSize() const
|
||||
{
|
||||
return (GetSize() == 4 || GetSize() == 8);
|
||||
}
|
||||
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
void SetPrecision(const EbmlFloat::Precision prec = FLOAT_32)
|
||||
{
|
||||
if (prec == FLOAT_64)
|
||||
SetSize_(8);
|
||||
else
|
||||
SetSize_(4); // default size
|
||||
}
|
||||
|
||||
|
||||
// EbmlFloat & operator=(const float NewValue) { Value = NewValue; return *this;}
|
||||
EbmlFloat & operator=(const double NewValue) { Value = NewValue; SetValueIsSet(); return *this;}
|
||||
|
||||
bool operator<(const EbmlFloat & EltCmp) const {return Value < EltCmp.Value;}
|
||||
|
||||
operator const float() const {return float(Value);}
|
||||
operator const double() const {return double(Value);}
|
||||
|
||||
void SetDefaultValue(double aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
const double DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
double Value; /// The actual value of the element
|
||||
double DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_FLOAT_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: EbmlFloat.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_FLOAT_H
|
||||
#define LIBEBML_FLOAT_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlFloat
|
||||
\brief Handle all operations on a float EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlFloat : public EbmlElement {
|
||||
public:
|
||||
enum Precision {
|
||||
FLOAT_32
|
||||
,FLOAT_64
|
||||
};
|
||||
|
||||
EbmlFloat(const Precision prec = FLOAT_32);
|
||||
EbmlFloat(const double DefaultValue, const Precision prec = FLOAT_32);
|
||||
EbmlFloat(const EbmlFloat & ElementToClone);
|
||||
|
||||
bool ValidateSize() const
|
||||
{
|
||||
return (GetSize() == 4 || GetSize() == 8);
|
||||
}
|
||||
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
void SetPrecision(const EbmlFloat::Precision prec = FLOAT_32)
|
||||
{
|
||||
if (prec == FLOAT_64)
|
||||
SetSize_(8);
|
||||
else
|
||||
SetSize_(4); // default size
|
||||
}
|
||||
|
||||
|
||||
// EbmlFloat & operator=(const float NewValue) { Value = NewValue; return *this;}
|
||||
EbmlFloat & operator=(const double NewValue) { Value = NewValue; SetValueIsSet(); return *this;}
|
||||
|
||||
bool operator<(const EbmlFloat & EltCmp) const {return Value < EltCmp.Value;}
|
||||
|
||||
operator const float() const {return float(Value);}
|
||||
operator const double() const {return double(Value);}
|
||||
|
||||
void SetDefaultValue(double aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
const double DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
double Value; /// The actual value of the element
|
||||
double DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_FLOAT_H
|
||||
|
188
ebml/EbmlId.h
188
ebml/EbmlId.h
@ -1,89 +1,99 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlId.h 936 2004-11-10 20:46:28Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_ID_H
|
||||
#define LIBEBML_ID_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
#define EBML_ID_VALUE(id) id.Value
|
||||
#define EBML_ID_LENGTH(id) id.Length
|
||||
/*!
|
||||
\class EbmlId
|
||||
*/
|
||||
class EBML_DLL_API EbmlId {
|
||||
public:
|
||||
EbmlId(const binary aValue[4], const unsigned int aLength)
|
||||
:Length(aLength)
|
||||
{
|
||||
Value = 0;
|
||||
unsigned int i;
|
||||
for (i=0; i<aLength; i++) {
|
||||
Value <<= 8;
|
||||
Value += aValue[i];
|
||||
}
|
||||
}
|
||||
|
||||
EbmlId(const uint32 aValue, const unsigned int aLength)
|
||||
:Value(aValue), Length(aLength) {}
|
||||
|
||||
inline bool operator==(const EbmlId & TestId) const
|
||||
{
|
||||
return ((TestId.Length == Length) && (TestId.Value == Value));
|
||||
}
|
||||
inline bool operator!=(const EbmlId & TestId) const
|
||||
{
|
||||
return !(*this == TestId);
|
||||
}
|
||||
|
||||
inline void Fill(binary * Buffer) const {
|
||||
unsigned int i;
|
||||
for (i = 0; i<Length; i++) {
|
||||
Buffer[i] = (Value >> (8*(Length-i-1))) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
inline size_t GetLength() const { return Length; }
|
||||
inline uint32 GetValue() const { return Value; }
|
||||
|
||||
uint32 Value;
|
||||
size_t Length;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_ID_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: EbmlId.h 936 2004-11-10 20:46:28Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_ID_H
|
||||
#define LIBEBML_ID_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
#define EBML_ID_VALUE(id) id.GetValue()
|
||||
#define EBML_ID_LENGTH(id) id.GetLength()
|
||||
#else
|
||||
#define EBML_ID_VALUE(id) id.Value
|
||||
#define EBML_ID_LENGTH(id) id.Length
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class EbmlId
|
||||
*/
|
||||
class EBML_DLL_API EbmlId {
|
||||
public:
|
||||
EbmlId(const binary aValue[4], const unsigned int aLength)
|
||||
:Length(aLength)
|
||||
{
|
||||
Value = 0;
|
||||
unsigned int i;
|
||||
for (i=0; i<aLength; i++) {
|
||||
Value <<= 8;
|
||||
Value += aValue[i];
|
||||
}
|
||||
}
|
||||
|
||||
EbmlId(const uint32 aValue, const unsigned int aLength)
|
||||
:Value(aValue), Length(aLength) {}
|
||||
|
||||
inline bool operator==(const EbmlId & TestId) const
|
||||
{
|
||||
return ((TestId.Length == Length) && (TestId.Value == Value));
|
||||
}
|
||||
inline bool operator!=(const EbmlId & TestId) const
|
||||
{
|
||||
return !(*this == TestId);
|
||||
}
|
||||
|
||||
inline void Fill(binary * Buffer) const {
|
||||
unsigned int i;
|
||||
for (i = 0; i<Length; i++) {
|
||||
Buffer[i] = (Value >> (8*(Length-i-1))) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
inline size_t GetLength() const { return Length; }
|
||||
inline uint32 GetValue() const { return Value; }
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#endif
|
||||
uint32 Value;
|
||||
size_t Length;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_ID_H
|
||||
|
@ -1,211 +1,215 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlMaster.h 1232 2005-10-15 15:56:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_MASTER_H
|
||||
#define LIBEBML_MASTER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
#include "EbmlCrc32.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const bool bChecksumUsedByDefault = false;
|
||||
|
||||
/*!
|
||||
\class EbmlMaster
|
||||
\brief Handle all operations on an EBML element that contains other EBML elements
|
||||
*/
|
||||
class EBML_DLL_API EbmlMaster : public EbmlElement {
|
||||
public:
|
||||
EbmlMaster(const EbmlSemanticContext & aContext, bool bSizeIsKnown = true);
|
||||
EbmlMaster(const EbmlMaster & ElementToClone);
|
||||
bool ValidateSize() const {return true;}
|
||||
/*!
|
||||
\warning be carefull to clear the memory allocated in the ElementList elsewhere
|
||||
*/
|
||||
virtual ~EbmlMaster();
|
||||
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
/*!
|
||||
\brief Set wether the size is finite (size is known in advance when writing, or infinite size is not known on writing)
|
||||
*/
|
||||
bool SetSizeInfinite(bool aIsInfinite = true) {SetSizeIsFinite(!aIsInfinite); return true;}
|
||||
|
||||
bool PushElement(EbmlElement & element);
|
||||
uint64 GetSize() const {
|
||||
if (IsFiniteSize())
|
||||
return GetSize();
|
||||
else
|
||||
return (0-1);
|
||||
}
|
||||
|
||||
uint64 GetDataStart() const {
|
||||
return GetElementPosition() + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize());
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief find the element corresponding to the ID of the element, NULL if not found
|
||||
*/
|
||||
EbmlElement *FindElt(const EbmlCallbacks & Callbacks) const;
|
||||
/*!
|
||||
\brief find the first element corresponding to the ID of the element
|
||||
*/
|
||||
EbmlElement *FindFirstElt(const EbmlCallbacks & Callbacks, bool bCreateIfNull);
|
||||
EbmlElement *FindFirstElt(const EbmlCallbacks & Callbacks) const;
|
||||
|
||||
/*!
|
||||
\brief find the element of the same type of PasElt following in the list of elements
|
||||
*/
|
||||
EbmlElement *FindNextElt(const EbmlElement & PastElt, bool bCreateIfNull);
|
||||
EbmlElement *FindNextElt(const EbmlElement & PastElt) const;
|
||||
EbmlElement *AddNewElt(const EbmlCallbacks & Callbacks);
|
||||
|
||||
/*!
|
||||
\brief add an element at a specified location
|
||||
*/
|
||||
bool InsertElement(EbmlElement & element, size_t position = 0);
|
||||
bool InsertElement(EbmlElement & element, const EbmlElement & before);
|
||||
|
||||
/*!
|
||||
\brief Read the data and keep the known children
|
||||
*/
|
||||
void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
|
||||
/*!
|
||||
\brief sort Data when they can
|
||||
*/
|
||||
void Sort();
|
||||
|
||||
size_t ListSize() const {return ElementList.size();}
|
||||
|
||||
inline std::vector<EbmlElement *>::const_iterator begin() {return ElementList.begin();}
|
||||
inline std::vector<EbmlElement *>::const_iterator end() {return ElementList.end();}
|
||||
|
||||
EbmlElement * operator[](unsigned int position) {return ElementList[position];}
|
||||
const EbmlElement * operator[](unsigned int position) const {return ElementList[position];}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (ElementList.size() == 0);
|
||||
}
|
||||
virtual bool IsMaster() const {return true;}
|
||||
|
||||
/*!
|
||||
\brief verify that all mandatory elements are present
|
||||
\note usefull after reading or before writing
|
||||
*/
|
||||
bool CheckMandatory() const;
|
||||
|
||||
/*!
|
||||
\brief Remove an element from the list of the master
|
||||
*/
|
||||
void Remove(size_t Index);
|
||||
|
||||
/*!
|
||||
\brief remove all elements, even the mandatory ones
|
||||
*/
|
||||
void RemoveAll() {ElementList.clear();}
|
||||
|
||||
/*!
|
||||
\brief facility for Master elements to write only the head and force the size later
|
||||
\warning
|
||||
*/
|
||||
uint32 WriteHead(IOCallback & output, int SizeLength, bool bKeepIntact = false);
|
||||
|
||||
void EnableChecksum(bool bIsEnabled = true) { bChecksumUsed = bIsEnabled; }
|
||||
bool HasChecksum() const {return bChecksumUsed;}
|
||||
bool VerifyChecksum() const;
|
||||
uint32 GetCrc32() const {return Checksum.GetCrc32();}
|
||||
void ForceChecksum(uint32 NewChecksum) {
|
||||
Checksum.ForceCrc32(NewChecksum);
|
||||
bChecksumUsed = true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief drill down all sub-elements, finding any missing elements
|
||||
*/
|
||||
std::vector<std::string> FindAllMissingElements();
|
||||
|
||||
protected:
|
||||
std::vector<EbmlElement *> ElementList;
|
||||
|
||||
const EbmlSemanticContext & Context;
|
||||
|
||||
bool bChecksumUsed;
|
||||
EbmlCrc32 Checksum;
|
||||
|
||||
private:
|
||||
/*!
|
||||
\brief Add all the mandatory elements to the list
|
||||
*/
|
||||
bool ProcessMandatory();
|
||||
};
|
||||
|
||||
///< \todo add a restriction to only elements legal in the context
|
||||
template <typename Type>
|
||||
Type & GetChild(EbmlMaster & Master)
|
||||
{
|
||||
return *(static_cast<Type *>(Master.FindFirstElt(EBML_INFO(Type), true)));
|
||||
}
|
||||
// call with
|
||||
// MyDocType = GetChild<EDocType>(TestHead);
|
||||
|
||||
template <typename Type>
|
||||
Type * FindChild(EbmlMaster & Master)
|
||||
{
|
||||
return static_cast<Type *>(Master.FindFirstElt(EBML_INFO(Type), false));
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
Type & GetNextChild(EbmlMaster & Master, const Type & PastElt)
|
||||
{
|
||||
return *(static_cast<Type *>(Master.FindNextElt(PastElt, true)));
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
Type & AddNewChild(EbmlMaster & Master)
|
||||
{
|
||||
return *(static_cast<Type *>(Master.AddNewElt(EBML_INFO(Type))));
|
||||
}
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_MASTER_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: EbmlMaster.h 1232 2005-10-15 15:56:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_MASTER_H
|
||||
#define LIBEBML_MASTER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
#include "EbmlCrc32.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const bool bChecksumUsedByDefault = false;
|
||||
|
||||
/*!
|
||||
\class EbmlMaster
|
||||
\brief Handle all operations on an EBML element that contains other EBML elements
|
||||
*/
|
||||
class EBML_DLL_API EbmlMaster : public EbmlElement {
|
||||
public:
|
||||
EbmlMaster(const EbmlSemanticContext & aContext, bool bSizeIsKnown = true);
|
||||
EbmlMaster(const EbmlMaster & ElementToClone);
|
||||
bool ValidateSize() const {return true;}
|
||||
/*!
|
||||
\warning be carefull to clear the memory allocated in the ElementList elsewhere
|
||||
*/
|
||||
virtual ~EbmlMaster();
|
||||
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
/*!
|
||||
\brief Set wether the size is finite (size is known in advance when writing, or infinite size is not known on writing)
|
||||
*/
|
||||
bool SetSizeInfinite(bool aIsInfinite = true) {SetSizeIsFinite(!aIsInfinite); return true;}
|
||||
|
||||
bool PushElement(EbmlElement & element);
|
||||
uint64 GetSize() const {
|
||||
if (IsFiniteSize())
|
||||
return GetSize();
|
||||
else
|
||||
return (0-1);
|
||||
}
|
||||
|
||||
uint64 GetDataStart() const {
|
||||
return GetElementPosition() + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize());
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief find the element corresponding to the ID of the element, NULL if not found
|
||||
*/
|
||||
EbmlElement *FindElt(const EbmlCallbacks & Callbacks) const;
|
||||
/*!
|
||||
\brief find the first element corresponding to the ID of the element
|
||||
*/
|
||||
EbmlElement *FindFirstElt(const EbmlCallbacks & Callbacks, bool bCreateIfNull);
|
||||
EbmlElement *FindFirstElt(const EbmlCallbacks & Callbacks) const;
|
||||
|
||||
/*!
|
||||
\brief find the element of the same type of PasElt following in the list of elements
|
||||
*/
|
||||
EbmlElement *FindNextElt(const EbmlElement & PastElt, bool bCreateIfNull);
|
||||
EbmlElement *FindNextElt(const EbmlElement & PastElt) const;
|
||||
EbmlElement *AddNewElt(const EbmlCallbacks & Callbacks);
|
||||
|
||||
/*!
|
||||
\brief add an element at a specified location
|
||||
*/
|
||||
bool InsertElement(EbmlElement & element, size_t position = 0);
|
||||
bool InsertElement(EbmlElement & element, const EbmlElement & before);
|
||||
|
||||
/*!
|
||||
\brief Read the data and keep the known children
|
||||
*/
|
||||
void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
|
||||
/*!
|
||||
\brief sort Data when they can
|
||||
*/
|
||||
void Sort();
|
||||
|
||||
size_t ListSize() const {return ElementList.size();}
|
||||
|
||||
inline std::vector<EbmlElement *>::const_iterator begin() {return ElementList.begin();}
|
||||
inline std::vector<EbmlElement *>::const_iterator end() {return ElementList.end();}
|
||||
|
||||
EbmlElement * operator[](unsigned int position) {return ElementList[position];}
|
||||
const EbmlElement * operator[](unsigned int position) const {return ElementList[position];}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (ElementList.size() == 0);
|
||||
}
|
||||
virtual bool IsMaster() const {return true;}
|
||||
|
||||
/*!
|
||||
\brief verify that all mandatory elements are present
|
||||
\note usefull after reading or before writing
|
||||
*/
|
||||
bool CheckMandatory() const;
|
||||
|
||||
/*!
|
||||
\brief Remove an element from the list of the master
|
||||
*/
|
||||
void Remove(size_t Index);
|
||||
|
||||
/*!
|
||||
\brief remove all elements, even the mandatory ones
|
||||
*/
|
||||
void RemoveAll() {ElementList.clear();}
|
||||
|
||||
/*!
|
||||
\brief facility for Master elements to write only the head and force the size later
|
||||
\warning
|
||||
*/
|
||||
uint32 WriteHead(IOCallback & output, int SizeLength, bool bKeepIntact = false);
|
||||
|
||||
void EnableChecksum(bool bIsEnabled = true) { bChecksumUsed = bIsEnabled; }
|
||||
bool HasChecksum() const {return bChecksumUsed;}
|
||||
bool VerifyChecksum() const;
|
||||
uint32 GetCrc32() const {return Checksum.GetCrc32();}
|
||||
void ForceChecksum(uint32 NewChecksum) {
|
||||
Checksum.ForceCrc32(NewChecksum);
|
||||
bChecksumUsed = true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief drill down all sub-elements, finding any missing elements
|
||||
*/
|
||||
std::vector<std::string> FindAllMissingElements();
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
std::vector<EbmlElement *> ElementList;
|
||||
|
||||
const EbmlSemanticContext & Context;
|
||||
|
||||
bool bChecksumUsed;
|
||||
EbmlCrc32 Checksum;
|
||||
|
||||
private:
|
||||
/*!
|
||||
\brief Add all the mandatory elements to the list
|
||||
*/
|
||||
bool ProcessMandatory();
|
||||
};
|
||||
|
||||
///< \todo add a restriction to only elements legal in the context
|
||||
template <typename Type>
|
||||
Type & GetChild(EbmlMaster & Master)
|
||||
{
|
||||
return *(static_cast<Type *>(Master.FindFirstElt(EBML_INFO(Type), true)));
|
||||
}
|
||||
// call with
|
||||
// MyDocType = GetChild<EDocType>(TestHead);
|
||||
|
||||
template <typename Type>
|
||||
Type * FindChild(EbmlMaster & Master)
|
||||
{
|
||||
return static_cast<Type *>(Master.FindFirstElt(EBML_INFO(Type), false));
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
Type & GetNextChild(EbmlMaster & Master, const Type & PastElt)
|
||||
{
|
||||
return *(static_cast<Type *>(Master.FindNextElt(PastElt, true)));
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
Type & AddNewChild(EbmlMaster & Master)
|
||||
{
|
||||
return *(static_cast<Type *>(Master.AddNewElt(EBML_INFO(Type))));
|
||||
}
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_MASTER_H
|
||||
|
@ -1,92 +1,96 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlSInteger.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
*/
|
||||
#ifndef LIBEBML_SINTEGER_H
|
||||
#define LIBEBML_SINTEGER_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const int DEFAULT_INT_SIZE = 1; ///< optimal size stored
|
||||
|
||||
/*!
|
||||
\class EbmlSInteger
|
||||
\brief Handle all operations on a signed integer EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlSInteger : public EbmlElement {
|
||||
public:
|
||||
EbmlSInteger();
|
||||
EbmlSInteger(int64 DefaultValue);
|
||||
EbmlSInteger(const EbmlSInteger & ElementToClone);
|
||||
|
||||
EbmlSInteger & operator = (int64 NewValue) {Value = NewValue; SetValueIsSet(); return *this;}
|
||||
|
||||
/*!
|
||||
Set the default size of the integer (usually 1,2,4 or 8)
|
||||
*/
|
||||
void SetDefaultSize(int nDefaultSize = DEFAULT_INT_SIZE) {SetSize_(nDefaultSize);}
|
||||
|
||||
bool ValidateSize() const {return (GetSize() <= 8);}
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
bool operator<(const EbmlSInteger & EltCmp) const {return Value < EltCmp.Value;}
|
||||
|
||||
operator int8() {return int8(Value);}
|
||||
operator int16() {return int16(Value);}
|
||||
operator int32() {return int32(Value);}
|
||||
operator int64() {return Value;}
|
||||
|
||||
void SetDefaultValue(int64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
int64 DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
int64 Value; /// The actual value of the element
|
||||
int64 DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_SINTEGER_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: EbmlSInteger.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
*/
|
||||
#ifndef LIBEBML_SINTEGER_H
|
||||
#define LIBEBML_SINTEGER_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const int DEFAULT_INT_SIZE = 1; ///< optimal size stored
|
||||
|
||||
/*!
|
||||
\class EbmlSInteger
|
||||
\brief Handle all operations on a signed integer EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlSInteger : public EbmlElement {
|
||||
public:
|
||||
EbmlSInteger();
|
||||
EbmlSInteger(int64 DefaultValue);
|
||||
EbmlSInteger(const EbmlSInteger & ElementToClone);
|
||||
|
||||
EbmlSInteger & operator = (int64 NewValue) {Value = NewValue; SetValueIsSet(); return *this;}
|
||||
|
||||
/*!
|
||||
Set the default size of the integer (usually 1,2,4 or 8)
|
||||
*/
|
||||
void SetDefaultSize(int nDefaultSize = DEFAULT_INT_SIZE) {SetSize_(nDefaultSize);}
|
||||
|
||||
bool ValidateSize() const {return (GetSize() <= 8);}
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
bool operator<(const EbmlSInteger & EltCmp) const {return Value < EltCmp.Value;}
|
||||
|
||||
operator int8() {return int8(Value);}
|
||||
operator int16() {return int16(Value);}
|
||||
operator int32() {return int32(Value);}
|
||||
operator int64() {return Value;}
|
||||
|
||||
void SetDefaultValue(int64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
int64 DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
int64 Value; /// The actual value of the element
|
||||
int64 DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_SINTEGER_H
|
||||
|
@ -1,72 +1,76 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlStream.h 639 2004-07-09 20:59:14Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_STREAM_H
|
||||
#define LIBEBML_STREAM_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "IOCallback.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlStream
|
||||
\brief Handle an input/output stream of EBML elements
|
||||
*/
|
||||
class EBML_DLL_API EbmlStream {
|
||||
public:
|
||||
EbmlStream(IOCallback & output);
|
||||
~EbmlStream();
|
||||
|
||||
/*!
|
||||
\brief Find a possible next ID in the data stream
|
||||
\param MaxDataSize The maximum possible of the data in the element (for sanity checks)
|
||||
\note the user will have to delete that element later
|
||||
*/
|
||||
EbmlElement * FindNextID(const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
|
||||
|
||||
EbmlElement * FindNextElement(const EbmlSemanticContext & Context, int & UpperLevel, const uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
|
||||
|
||||
inline IOCallback & I_O() {return Stream;}
|
||||
operator IOCallback &() {return Stream;}
|
||||
|
||||
protected:
|
||||
IOCallback & Stream;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_STREAM_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: EbmlStream.h 639 2004-07-09 20:59:14Z mosu $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#ifndef LIBEBML_STREAM_H
|
||||
#define LIBEBML_STREAM_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "IOCallback.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class EbmlStream
|
||||
\brief Handle an input/output stream of EBML elements
|
||||
*/
|
||||
class EBML_DLL_API EbmlStream {
|
||||
public:
|
||||
EbmlStream(IOCallback & output);
|
||||
~EbmlStream();
|
||||
|
||||
/*!
|
||||
\brief Find a possible next ID in the data stream
|
||||
\param MaxDataSize The maximum possible of the data in the element (for sanity checks)
|
||||
\note the user will have to delete that element later
|
||||
*/
|
||||
EbmlElement * FindNextID(const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
|
||||
|
||||
EbmlElement * FindNextElement(const EbmlSemanticContext & Context, int & UpperLevel, const uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
|
||||
|
||||
inline IOCallback & I_O() {return Stream;}
|
||||
operator IOCallback &() {return Stream;}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
IOCallback & Stream;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_STREAM_H
|
||||
|
@ -1,81 +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() {}
|
||||
|
||||
bool ValidateSize() const {return true;} // any size is possible
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
EbmlString & operator=(const std::string);
|
||||
operator const std::string &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(std::string & aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
const std::string DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
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: 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() {}
|
||||
|
||||
bool ValidateSize() const {return true;} // any size is possible
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
EbmlString & operator=(const std::string);
|
||||
operator const std::string &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(std::string & aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
const std::string DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
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
|
||||
|
@ -1,92 +1,96 @@
|
||||
/****************************************************************************
|
||||
** 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: EbmlUInteger.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
*/
|
||||
#ifndef LIBEBML_UINTEGER_H
|
||||
#define LIBEBML_UINTEGER_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const int DEFAULT_UINT_SIZE = 0; ///< optimal size stored
|
||||
|
||||
/*!
|
||||
\class EbmlUInteger
|
||||
\brief Handle all operations on an unsigned integer EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlUInteger : public EbmlElement {
|
||||
public:
|
||||
EbmlUInteger();
|
||||
EbmlUInteger(uint64 DefaultValue);
|
||||
EbmlUInteger(const EbmlUInteger & ElementToClone);
|
||||
|
||||
EbmlUInteger & operator=(uint64 NewValue) {Value = NewValue; SetValueIsSet(); return *this;}
|
||||
|
||||
/*!
|
||||
Set the default size of the integer (usually 1,2,4 or 8)
|
||||
*/
|
||||
void SetDefaultSize(int nDefaultSize = DEFAULT_UINT_SIZE) {SetSize_(nDefaultSize);}
|
||||
|
||||
bool ValidateSize() const {return (GetSize() <= 8);}
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
bool operator<(const EbmlUInteger & EltCmp) const {return Value < EltCmp.Value;}
|
||||
|
||||
operator uint8() const {return uint8(Value); }
|
||||
operator uint16() const {return uint16(Value);}
|
||||
operator uint32() const {return uint32(Value);}
|
||||
operator uint64() const {return Value;}
|
||||
|
||||
void SetDefaultValue(uint64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
const uint64 DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
uint64 Value; /// The actual value of the element
|
||||
uint64 DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_UINTEGER_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: EbmlUInteger.h 1079 2005-03-03 13:18:14Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
\author Julien Coloos <suiryc @ users.sf.net>
|
||||
\author Moritz Bunkus <moritz @ bunkus.org>
|
||||
*/
|
||||
#ifndef LIBEBML_UINTEGER_H
|
||||
#define LIBEBML_UINTEGER_H
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlElement.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
const int DEFAULT_UINT_SIZE = 0; ///< optimal size stored
|
||||
|
||||
/*!
|
||||
\class EbmlUInteger
|
||||
\brief Handle all operations on an unsigned integer EBML element
|
||||
*/
|
||||
class EBML_DLL_API EbmlUInteger : public EbmlElement {
|
||||
public:
|
||||
EbmlUInteger();
|
||||
EbmlUInteger(uint64 DefaultValue);
|
||||
EbmlUInteger(const EbmlUInteger & ElementToClone);
|
||||
|
||||
EbmlUInteger & operator=(uint64 NewValue) {Value = NewValue; SetValueIsSet(); return *this;}
|
||||
|
||||
/*!
|
||||
Set the default size of the integer (usually 1,2,4 or 8)
|
||||
*/
|
||||
void SetDefaultSize(int nDefaultSize = DEFAULT_UINT_SIZE) {SetSize_(nDefaultSize);}
|
||||
|
||||
bool ValidateSize() const {return (GetSize() <= 8);}
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
bool operator<(const EbmlUInteger & EltCmp) const {return Value < EltCmp.Value;}
|
||||
|
||||
operator uint8() const {return uint8(Value); }
|
||||
operator uint16() const {return uint16(Value);}
|
||||
operator uint32() const {return uint32(Value);}
|
||||
operator uint64() const {return Value;}
|
||||
|
||||
void SetDefaultValue(uint64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
const uint64 DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
#if defined(EBML_STRICT_API)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
uint64 Value; /// The actual value of the element
|
||||
uint64 DefaultValue;
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif // LIBEBML_UINTEGER_H
|
||||
|
@ -1,126 +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 &);
|
||||
|
||||
protected:
|
||||
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() {}
|
||||
|
||||
bool ValidateSize() const {return true;} // any size is possible
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
|
||||
operator const UTFstring &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(UTFstring & aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
UTFstring DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
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: 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() {}
|
||||
|
||||
bool ValidateSize() const {return true;} // any size is possible
|
||||
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
|
||||
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
|
||||
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
|
||||
|
||||
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
|
||||
operator const UTFstring &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(UTFstring & aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
|
||||
UTFstring DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
|
||||
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
|
||||
|
@ -6,6 +6,7 @@ LIB ebml
|
||||
|
||||
INCLUDE .
|
||||
EXPINCLUDE .
|
||||
EXPDEFINE(USE_EBML_STRICT_API) EBML_STRICT_API
|
||||
|
||||
// OPTIMIZE_GLOBALLY .
|
||||
FAVOR_MAX_SPEED .
|
||||
|
Loading…
Reference in New Issue
Block a user