move some of the <cassert> includes and assert() calls out of the include files
+ the DefaultValue() methods return const objects git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@25 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
parent
8b4a54c88f
commit
cd5d717fb9
@ -37,7 +37,6 @@
|
||||
#ifndef LIBEBML_BINARY_H
|
||||
#define LIBEBML_BINARY_H
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
|
@ -37,6 +37,8 @@
|
||||
#ifndef LIBEBML_CRC32_H
|
||||
#define LIBEBML_CRC32_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlBinary.h"
|
||||
|
||||
|
@ -34,8 +34,6 @@
|
||||
#ifndef LIBEBML_ELEMENT_H
|
||||
#define LIBEBML_ELEMENT_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "EbmlTypes.h"
|
||||
#include "EbmlId.h"
|
||||
#include "IOCallback.h"
|
||||
@ -144,13 +142,7 @@ class EbmlElement;
|
||||
*/
|
||||
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)
|
||||
{
|
||||
}
|
||||
EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext);
|
||||
|
||||
inline const EbmlId & ClassId() const { return GlobalId; }
|
||||
inline const EbmlSemanticContext & GetContext() const { return Context; }
|
||||
@ -233,7 +225,7 @@ class EBML_DLL_API EbmlSemanticContext {
|
||||
class EBML_DLL_API EbmlElement {
|
||||
public:
|
||||
EbmlElement(uint64 aDefaultSize, bool bValueSet = false);
|
||||
virtual ~EbmlElement() {assert(!bLocked);}
|
||||
virtual ~EbmlElement();
|
||||
|
||||
/// Set the minimum length that will be used to write the element size (-1 = optimal)
|
||||
void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;}
|
||||
|
@ -82,9 +82,9 @@ class EBML_DLL_API EbmlFloat : public EbmlElement {
|
||||
operator const float() const {return float(Value);}
|
||||
operator const double() const {return double(Value);}
|
||||
|
||||
void SetDefaultValue(double aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
void SetDefaultValue(double);
|
||||
|
||||
const double DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
const double DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
|
@ -63,9 +63,9 @@ class EBML_DLL_API EbmlString : public EbmlElement {
|
||||
EbmlString & operator=(const std::string);
|
||||
operator const std::string &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(std::string & aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
void SetDefaultValue(std::string &);
|
||||
|
||||
const std::string DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
const std::string & DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
|
147
ebml/EbmlTypes.h
147
ebml/EbmlTypes.h
@ -1,75 +1,72 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2004 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: EbmlTypes.h 639 2004-07-09 20:59:14Z mosu $
|
||||
*/
|
||||
#ifndef LIBEBML_TYPES_H
|
||||
#define LIBEBML_TYPES_H
|
||||
|
||||
#include <clocale>
|
||||
#include <string>
|
||||
|
||||
#include "ebml/c/libebml_t.h"
|
||||
#include "ebml/EbmlConfig.h"
|
||||
#include "EbmlEndian.h" // binary needs to be defined
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
typedef wchar_t utf16;
|
||||
typedef uint32 utf32;
|
||||
typedef char utf8;
|
||||
|
||||
typedef binary bits80[10];
|
||||
|
||||
typedef Endian<int16,little_endian> lil_int16;
|
||||
typedef Endian<int32,little_endian> lil_int32;
|
||||
typedef Endian<int64,little_endian> lil_int64;
|
||||
typedef Endian<uint16,little_endian> lil_uint16;
|
||||
typedef Endian<uint32,little_endian> lil_uint32;
|
||||
typedef Endian<uint64,little_endian> lil_uint64;
|
||||
typedef Endian<int16,big_endian> big_int16;
|
||||
typedef Endian<int32,big_endian> big_int32;
|
||||
typedef Endian<int64,big_endian> big_int64;
|
||||
typedef Endian<uint16,big_endian> big_uint16;
|
||||
typedef Endian<uint32,big_endian> big_uint32;
|
||||
typedef Endian<uint64,big_endian> big_uint64;
|
||||
typedef Endian<uint32,big_endian> checksum;
|
||||
typedef Endian<bits80,big_endian> big_80bits;
|
||||
|
||||
|
||||
enum ScopeMode {
|
||||
SCOPE_PARTIAL_DATA = 0,
|
||||
SCOPE_ALL_DATA,
|
||||
SCOPE_NO_DATA
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2004 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: EbmlTypes.h 639 2004-07-09 20:59:14Z mosu $
|
||||
*/
|
||||
#ifndef LIBEBML_TYPES_H
|
||||
#define LIBEBML_TYPES_H
|
||||
|
||||
#include "ebml/c/libebml_t.h"
|
||||
#include "ebml/EbmlConfig.h"
|
||||
#include "EbmlEndian.h" // binary needs to be defined
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
typedef wchar_t utf16;
|
||||
typedef uint32 utf32;
|
||||
typedef char utf8;
|
||||
|
||||
typedef binary bits80[10];
|
||||
|
||||
typedef Endian<int16,little_endian> lil_int16;
|
||||
typedef Endian<int32,little_endian> lil_int32;
|
||||
typedef Endian<int64,little_endian> lil_int64;
|
||||
typedef Endian<uint16,little_endian> lil_uint16;
|
||||
typedef Endian<uint32,little_endian> lil_uint32;
|
||||
typedef Endian<uint64,little_endian> lil_uint64;
|
||||
typedef Endian<int16,big_endian> big_int16;
|
||||
typedef Endian<int32,big_endian> big_int32;
|
||||
typedef Endian<int64,big_endian> big_int64;
|
||||
typedef Endian<uint16,big_endian> big_uint16;
|
||||
typedef Endian<uint32,big_endian> big_uint32;
|
||||
typedef Endian<uint64,big_endian> big_uint64;
|
||||
typedef Endian<uint32,big_endian> checksum;
|
||||
typedef Endian<bits80,big_endian> big_80bits;
|
||||
|
||||
|
||||
enum ScopeMode {
|
||||
SCOPE_PARTIAL_DATA = 0,
|
||||
SCOPE_ALL_DATA,
|
||||
SCOPE_NO_DATA
|
||||
};
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
@ -74,9 +74,9 @@ class EBML_DLL_API EbmlUInteger : public EbmlElement {
|
||||
operator uint32() const {return uint32(Value);}
|
||||
operator uint64() const {return Value;}
|
||||
|
||||
void SetDefaultValue(uint64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
void SetDefaultValue(uint64);
|
||||
|
||||
const uint64 DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
const uint64 DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
|
@ -112,9 +112,9 @@ class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
|
||||
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
|
||||
operator const UTFstring &() const {return Value;}
|
||||
|
||||
void SetDefaultValue(UTFstring & aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
|
||||
void SetDefaultValue(UTFstring &);
|
||||
|
||||
UTFstring DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
|
||||
const UTFstring & DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
|
@ -201,6 +201,18 @@ int64 ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uin
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
EbmlCallbacks::EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext)
|
||||
:Create(Creator)
|
||||
,GlobalId(aGlobalId)
|
||||
,DebugName(aDebugName)
|
||||
,Context(aContext)
|
||||
{
|
||||
assert(Create!=NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
EbmlElement::EbmlElement(uint64 aDefaultSize, bool bValueSet)
|
||||
:DefaultSize(aDefaultSize)
|
||||
,SizeLength(0) ///< write optimal size by default
|
||||
@ -227,6 +239,11 @@ EbmlElement::EbmlElement(const EbmlElement & ElementToClone)
|
||||
{
|
||||
}
|
||||
|
||||
EbmlElement::~EbmlElement()
|
||||
{
|
||||
assert(!bLocked);
|
||||
}
|
||||
|
||||
/*!
|
||||
\todo this method is deprecated and should be called FindThisID
|
||||
\todo replace the new RawElement with the appropriate class (when known)
|
||||
|
@ -60,6 +60,20 @@ EbmlFloat::EbmlFloat(const EbmlFloat & ElementToClone)
|
||||
{
|
||||
}
|
||||
|
||||
void EbmlFloat::SetDefaultValue(double aValue)
|
||||
{
|
||||
assert(!DefaultISset());
|
||||
DefaultValue = aValue;
|
||||
SetDefaultIsSet();
|
||||
}
|
||||
|
||||
const double EbmlFloat::DefaultVal() const
|
||||
{
|
||||
assert(DefaultISset());
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
\todo handle 10 bits precision
|
||||
|
@ -70,6 +70,20 @@ EbmlString::EbmlString(const EbmlString & ElementToClone)
|
||||
{
|
||||
}
|
||||
|
||||
void EbmlString::SetDefaultValue(std::string & aValue)
|
||||
{
|
||||
assert(!DefaultISset());
|
||||
DefaultValue = aValue;
|
||||
SetDefaultIsSet();
|
||||
}
|
||||
|
||||
const std::string & EbmlString::DefaultVal() const
|
||||
{
|
||||
assert(DefaultISset());
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
*/
|
||||
|
@ -57,6 +57,20 @@ EbmlUInteger::EbmlUInteger(const EbmlUInteger & ElementToClone)
|
||||
{
|
||||
}
|
||||
|
||||
void EbmlUInteger::SetDefaultValue(uint64 aValue)
|
||||
{
|
||||
assert(!DefaultISset());
|
||||
DefaultValue = aValue;
|
||||
SetDefaultIsSet();
|
||||
}
|
||||
|
||||
const uint64 EbmlUInteger::DefaultVal() const
|
||||
{
|
||||
assert(DefaultISset());
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
*/
|
||||
|
@ -224,6 +224,20 @@ EbmlUnicodeString::EbmlUnicodeString(const EbmlUnicodeString & ElementToClone)
|
||||
{
|
||||
}
|
||||
|
||||
void EbmlUnicodeString::SetDefaultValue(UTFstring & aValue)
|
||||
{
|
||||
assert(!DefaultISset());
|
||||
DefaultValue = aValue;
|
||||
SetDefaultIsSet();
|
||||
}
|
||||
|
||||
const UTFstring & EbmlUnicodeString::DefaultVal() const
|
||||
{
|
||||
assert(DefaultISset());
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\note limited to UCS-2
|
||||
\todo handle exception on errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user