v1/v2: rename bKeepIntact to bWithDefault for more clarity in the API

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@123 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-04-15 14:54:49 +00:00
parent be6a37df06
commit 769a6c3ab7
22 changed files with 410 additions and 410 deletions

View File

@ -64,9 +64,9 @@ class EBML_DLL_API EbmlBinary : public EbmlElement {
virtual bool ValidateSize() const {return true;} // we don't mind about what's inside virtual bool ValidateSize() const {return true;} // we don't mind about what's inside
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
void SetBuffer(const binary *Buffer, const uint32 BufferSize) { void SetBuffer(const binary *Buffer, const uint32 BufferSize) {
Data = (binary *) Buffer; Data = (binary *) Buffer;

View File

@ -58,9 +58,9 @@ DECLARE_EBML_BINARY(EbmlCrc32)
public: public:
EbmlCrc32(const EbmlCrc32 & ElementToClone); EbmlCrc32(const EbmlCrc32 & ElementToClone);
virtual bool ValidateSize() const {return (GetSize() == 4);} virtual bool ValidateSize() const {return (GetSize() == 4);}
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
// filepos_t UpdateSize(bool bKeepIntact = false); // filepos_t UpdateSize(bool bWithDefault = false);
bool IsDefaultValue() const { bool IsDefaultValue() const {
return false; return false;

View File

@ -65,7 +65,7 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
/*! /*!
\note no Default date handled \note no Default date handled
*/ */
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false) { filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) {
if(!ValueIsSet()) if(!ValueIsSet())
SetSize_(0); SetSize_(0);
else else
@ -86,7 +86,7 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
#else #else
protected: protected:
#endif #endif
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
int64 myDate; ///< internal format of the date int64 myDate; ///< internal format of the date

View File

@ -384,11 +384,11 @@ class EBML_DLL_API EbmlElement {
return ElementPosition; return ElementPosition;
} }
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing uint64 ElementSize(bool bWithDefault = false) const; /// return the size of the header+data, before writing
filepos_t Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false); filepos_t Render(IOCallback & output, bool bWithDefault = false, bool bKeepPosition = false, bool bForceRender = false);
virtual filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored virtual filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) = 0; /// update the Size of the Data stored
virtual filepos_t GetSize() const {return Size;} /// return the size of the data stored in the element, on reading virtual filepos_t GetSize() const {return Size;} /// return the size of the data stored in the element, on reading
virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0; virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
@ -421,7 +421,7 @@ class EBML_DLL_API EbmlElement {
/*! /*!
\brief void the content of the element (replace by EbmlVoid) \brief void the content of the element (replace by EbmlVoid)
*/ */
uint32 VoidMe(IOCallback & output, bool bKeepIntact = false); uint32 VoidMe(IOCallback & output, bool bWithDefault = false);
bool DefaultISset() const {return DefaultIsSet;} bool DefaultISset() const {return DefaultIsSet;}
virtual bool IsDefaultValue() const = 0; virtual bool IsDefaultValue() const = 0;
@ -445,13 +445,13 @@ class EBML_DLL_API EbmlElement {
*/ */
static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1); static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1);
filepos_t RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false); filepos_t RenderHead(IOCallback & output, bool bForceRender, bool bWithDefault = false, bool bKeepPosition = false);
filepos_t MakeRenderHead(IOCallback & output, bool bKeepPosition); filepos_t MakeRenderHead(IOCallback & output, bool bKeepPosition);
/*! /*!
\brief prepare the data before writing them (in case it's not already done by default) \brief prepare the data before writing them (in case it's not already done by default)
*/ */
virtual filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0; virtual filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false) = 0;
/*! /*!
\brief special constructor for cloning \brief special constructor for cloning

View File

@ -61,9 +61,9 @@ class EBML_DLL_API EbmlFloat : public EbmlElement {
return (GetSize() == 4 || GetSize() == 8); return (GetSize() == 4 || GetSize() == 8);
} }
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
void SetPrecision(const EbmlFloat::Precision prec = FLOAT_32) void SetPrecision(const EbmlFloat::Precision prec = FLOAT_32)
{ {

View File

@ -63,9 +63,9 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
*/ */
virtual ~EbmlMaster(); virtual ~EbmlMaster();
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = 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) \brief Set wether the size is finite (size is known in advance when writing, or infinite size is not known on writing)
@ -150,7 +150,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
\brief facility for Master elements to write only the head and force the size later \brief facility for Master elements to write only the head and force the size later
\warning \warning
*/ */
filepos_t WriteHead(IOCallback & output, int SizeLength, bool bKeepIntact = false); filepos_t WriteHead(IOCallback & output, int SizeLength, bool bWithDefault = false);
void EnableChecksum(bool bIsEnabled = true) { bChecksumUsed = bIsEnabled; } void EnableChecksum(bool bIsEnabled = true) { bChecksumUsed = bIsEnabled; }
bool HasChecksum() const {return bChecksumUsed;} bool HasChecksum() const {return bChecksumUsed;}

View File

@ -65,9 +65,9 @@ class EBML_DLL_API EbmlSInteger : public EbmlElement {
virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_INT_SIZE) {SetSize_(nDefaultSize);} virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_INT_SIZE) {SetSize_(nDefaultSize);}
virtual bool ValidateSize() const {return (GetSize() <= 8);} virtual bool ValidateSize() const {return (GetSize() <= 8);}
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
virtual bool IsSmallerThan(const EbmlElement *Cmp) const; virtual bool IsSmallerThan(const EbmlElement *Cmp) const;

View File

@ -56,9 +56,9 @@ class EBML_DLL_API EbmlString : public EbmlElement {
virtual ~EbmlString() {} virtual ~EbmlString() {}
virtual bool ValidateSize() const {return true;} // any size is possible virtual bool ValidateSize() const {return true;} // any size is possible
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
EbmlString & operator=(const std::string &); EbmlString & operator=(const std::string &);
operator const std::string &() const {return Value;} operator const std::string &() const {return Value;}

View File

@ -63,9 +63,9 @@ class EBML_DLL_API EbmlUInteger : public EbmlElement {
virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_UINT_SIZE) {SetSize_(nDefaultSize);} virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_UINT_SIZE) {SetSize_(nDefaultSize);}
virtual bool ValidateSize() const {return (GetSize() <= 8);} virtual bool ValidateSize() const {return (GetSize() <= 8);}
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
virtual bool IsSmallerThan(const EbmlElement *Cmp) const; virtual bool IsSmallerThan(const EbmlElement *Cmp) const;

View File

@ -105,9 +105,9 @@ class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
virtual ~EbmlUnicodeString() {} virtual ~EbmlUnicodeString() {}
virtual bool ValidateSize() const {return true;} // any size is possible virtual bool ValidateSize() const {return true;} // any size is possible
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA); filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
operator const UTFstring &() const {return Value;} operator const UTFstring &() const {return Value;}

View File

@ -53,17 +53,17 @@ DECLARE_EBML_BINARY(EbmlVoid)
/*! /*!
\note overwrite to write fake data \note overwrite to write fake data
*/ */
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
/*! /*!
\brief Replace the void element content (written) with this one \brief Replace the void element content (written) with this one
*/ */
uint64 ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false); uint64 ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bWithDefault = false);
/*! /*!
\brief Void the content of an element \brief Void the content of an element
*/ */
uint64 Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false); uint64 Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward = true, bool bWithDefault = false);
EBML_CONCRETE_CLASS(EbmlVoid) EBML_CONCRETE_CLASS(EbmlVoid)
}; };

View File

@ -61,7 +61,7 @@ EbmlBinary::~EbmlBinary(void) {
free(Data); free(Data);
} }
filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
output.writeFully(Data,GetSize()); output.writeFully(Data,GetSize());
@ -71,7 +71,7 @@ filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bK
/*! /*!
\note no Default binary value handled \note no Default binary value handled
*/ */
uint64 EbmlBinary::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlBinary::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
return GetSize(); return GetSize();
} }

View File

@ -187,7 +187,7 @@ bool EbmlCrc32::CheckElementCRC32(EbmlElement &ElementToCRC)
return CheckCRC(m_crc_final, memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize()); return CheckCRC(m_crc_final, memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize());
}; };
filepos_t EbmlCrc32::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlCrc32::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
filepos_t Result = DIGESTSIZE; filepos_t Result = DIGESTSIZE;

View File

@ -65,7 +65,7 @@ filepos_t EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
return GetSize(); return GetSize();
} }
filepos_t EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
if (GetSize() != 0) { if (GetSize() != 0) {
assert(GetSize() == 8); assert(GetSize() == 8);

View File

@ -573,19 +573,19 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb
/*! /*!
\todo verify that the size written is the same as the data written \todo verify that the size written is the same as the data written
*/ */
filepos_t EbmlElement::Render(IOCallback & output, bool bKeepIntact, bool bKeepPosition, bool bForceRender) filepos_t EbmlElement::Render(IOCallback & output, bool bWithDefault, bool bKeepPosition, bool bForceRender)
{ {
assert(bValueIsSet || (bKeepIntact && DefaultISset())); // an element is been rendered without a value set !!! assert(bValueIsSet || (bWithDefault && DefaultISset())); // an element is been rendered without a value set !!!
// it may be a mandatory element without a default value // it may be a mandatory element without a default value
try { try {
if (!bKeepIntact && IsDefaultValue()) { if (!bWithDefault && IsDefaultValue()) {
return 0; return 0;
} }
#if defined(_DEBUG) || defined(DEBUG) #if defined(_DEBUG) || defined(DEBUG)
uint64 SupposedSize = UpdateSize(bKeepIntact, bForceRender); uint64 SupposedSize = UpdateSize(bWithDefault, bForceRender);
#endif // _DEBUG #endif // _DEBUG
filepos_t result = RenderHead(output, bForceRender, bKeepIntact, bKeepPosition); filepos_t result = RenderHead(output, bForceRender, bWithDefault, bKeepPosition);
uint64 WrittenSize = RenderData(output, bForceRender, bKeepIntact); uint64 WrittenSize = RenderData(output, bForceRender, bWithDefault);
#if defined(_DEBUG) || defined(DEBUG) #if defined(_DEBUG) || defined(DEBUG)
if (SupposedSize != (0-1)) assert(WrittenSize == SupposedSize); if (SupposedSize != (0-1)) assert(WrittenSize == SupposedSize);
#endif // DEBUG #endif // DEBUG
@ -603,12 +603,12 @@ filepos_t EbmlElement::Render(IOCallback & output, bool bKeepIntact, bool bKeepP
\todo handle exceptions on errors \todo handle exceptions on errors
\todo handle CodeSize bigger than 5 bytes \todo handle CodeSize bigger than 5 bytes
*/ */
filepos_t EbmlElement::RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact, bool bKeepPosition) filepos_t EbmlElement::RenderHead(IOCallback & output, bool bForceRender, bool bWithDefault, bool bKeepPosition)
{ {
if (EBML_ID_LENGTH(EbmlId(*this)) <= 0 || EBML_ID_LENGTH(EbmlId(*this)) > 4) if (EBML_ID_LENGTH(EbmlId(*this)) <= 0 || EBML_ID_LENGTH(EbmlId(*this)) > 4)
return 0; return 0;
UpdateSize(bKeepIntact, bForceRender); UpdateSize(bWithDefault, bForceRender);
return MakeRenderHead(output, bKeepPosition); return MakeRenderHead(output, bKeepPosition);
} }
@ -634,9 +634,9 @@ filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)
return FinalHeadSize; return FinalHeadSize;
} }
uint64 EbmlElement::ElementSize(bool bKeepIntact) const uint64 EbmlElement::ElementSize(bool bWithDefault) const
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bWithDefault && IsDefaultValue())
return 0; // won't be saved return 0; // won't be saved
return Size + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); return Size + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
} }
@ -692,14 +692,14 @@ filepos_t EbmlElement::OverwriteHead(IOCallback & output, bool bKeepPosition)
return Result; return Result;
} }
uint32 EbmlElement::VoidMe(IOCallback & output, bool bKeepIntact) uint32 EbmlElement::VoidMe(IOCallback & output, bool bWithDefault)
{ {
if (ElementPosition == 0) { if (ElementPosition == 0) {
return 0; // the element has not been written return 0; // the element has not been written
} }
EbmlVoid Dummy; EbmlVoid Dummy;
return Dummy.Overwrite(*this, output, bKeepIntact); return Dummy.Overwrite(*this, output, bWithDefault);
} }
END_LIBEBML_NAMESPACE END_LIBEBML_NAMESPACE

View File

@ -78,7 +78,7 @@ const double EbmlFloat::DefaultVal() const
\todo handle exception on errors \todo handle exception on errors
\todo handle 10 bits precision \todo handle 10 bits precision
*/ */
filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
assert(GetSize() == 4 || GetSize() == 8); assert(GetSize() == 4 || GetSize() == 8);
@ -99,9 +99,9 @@ filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bKe
return GetSize(); return GetSize();
} }
uint64 EbmlFloat::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlFloat::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bWithDefault && IsDefaultValue())
return 0; return 0;
return GetSize(); return GetSize();
} }

View File

@ -87,7 +87,7 @@ EbmlMaster::~EbmlMaster()
\todo handle exception on errors \todo handle exception on errors
\todo write all the Mandatory elements in the Context, otherwise assert \todo write all the Mandatory elements in the Context, otherwise assert
*/ */
filepos_t EbmlMaster::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlMaster::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
filepos_t Result = 0; filepos_t Result = 0;
size_t Index; size_t Index;
@ -98,16 +98,16 @@ filepos_t EbmlMaster::RenderData(IOCallback & output, bool bForceRender, bool bK
if (!bChecksumUsed) { // old school if (!bChecksumUsed) { // old school
for (Index = 0; Index < ElementList.size(); Index++) { for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue()) if (!bWithDefault && (ElementList[Index])->IsDefaultValue())
continue; continue;
Result += (ElementList[Index])->Render(output, bKeepIntact, false ,bForceRender); Result += (ElementList[Index])->Render(output, bWithDefault, false ,bForceRender);
} }
} else { // new school } else { // new school
MemIOCallback TmpBuf(GetSize() - 6); MemIOCallback TmpBuf(GetSize() - 6);
for (Index = 0; Index < ElementList.size(); Index++) { for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue()) if (!bWithDefault && (ElementList[Index])->IsDefaultValue())
continue; continue;
(ElementList[Index])->Render(TmpBuf, bKeepIntact, false ,bForceRender); (ElementList[Index])->Render(TmpBuf, bWithDefault, false ,bForceRender);
} }
Checksum.FillCRC32(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize()); Checksum.FillCRC32(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
Result += Checksum.Render(output, true, false ,bForceRender); Result += Checksum.Render(output, true, false ,bForceRender);
@ -127,7 +127,7 @@ bool EbmlMaster::PushElement(EbmlElement & element)
return true; return true;
} }
uint64 EbmlMaster::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlMaster::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
SetSize_(0); SetSize_(0);
@ -141,10 +141,10 @@ uint64 EbmlMaster::UpdateSize(bool bKeepIntact, bool bForceRender)
size_t Index; size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) { for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue()) if (!bWithDefault && (ElementList[Index])->IsDefaultValue())
continue; continue;
(ElementList[Index])->UpdateSize(bKeepIntact, bForceRender); (ElementList[Index])->UpdateSize(bWithDefault, bForceRender);
uint64 SizeToAdd = (ElementList[Index])->ElementSize(bKeepIntact); uint64 SizeToAdd = (ElementList[Index])->ElementSize(bWithDefault);
#if defined(_DEBUG) || defined(DEBUG) #if defined(_DEBUG) || defined(DEBUG)
if (SizeToAdd == (0-1)) if (SizeToAdd == (0-1))
return (0-1); return (0-1);
@ -158,10 +158,10 @@ uint64 EbmlMaster::UpdateSize(bool bKeepIntact, bool bForceRender)
return GetSize(); return GetSize();
} }
filepos_t EbmlMaster::WriteHead(IOCallback & output, int nSizeLength, bool bKeepIntact) filepos_t EbmlMaster::WriteHead(IOCallback & output, int nSizeLength, bool bWithDefault)
{ {
SetSizeLength(nSizeLength); SetSizeLength(nSizeLength);
return RenderHead(output, false, bKeepIntact); return RenderHead(output, false, bWithDefault);
} }
/*! /*!

View File

@ -58,7 +58,7 @@ EbmlSInteger::EbmlSInteger(const EbmlSInteger & ElementToClone)
/*! /*!
\todo handle exception on errors \todo handle exception on errors
*/ */
filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
binary FinalData[8]; // we don't handle more than 64 bits integers binary FinalData[8]; // we don't handle more than 64 bits integers
unsigned int i; unsigned int i;
@ -77,9 +77,9 @@ filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool
return GetSize(); return GetSize();
} }
uint64 EbmlSInteger::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlSInteger::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bWithDefault && IsDefaultValue())
return 0; return 0;
if (Value <= 0x7F && Value >= (-0x80)) { if (Value <= 0x7F && Value >= (-0x80)) {

View File

@ -87,7 +87,7 @@ const std::string & EbmlString::DefaultVal() const
/*! /*!
\todo handle exception on errors \todo handle exception on errors
*/ */
filepos_t EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
filepos_t Result; filepos_t Result;
output.writeFully(Value.c_str(), Value.length()); output.writeFully(Value.c_str(), Value.length());
@ -120,9 +120,9 @@ EbmlString & EbmlString::operator=(const std::string & NewString)
return *this; return *this;
} }
uint64 EbmlString::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlString::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bWithDefault && IsDefaultValue())
return 0; return 0;
if (Value.length() < GetDefaultSize()) { if (Value.length() < GetDefaultSize()) {

View File

@ -74,7 +74,7 @@ const uint64 EbmlUInteger::DefaultVal() const
/*! /*!
\todo handle exception on errors \todo handle exception on errors
*/ */
filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
binary FinalData[8]; // we don't handle more than 64 bits integers binary FinalData[8]; // we don't handle more than 64 bits integers
@ -92,9 +92,9 @@ filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool
return GetSize(); return GetSize();
} }
uint64 EbmlUInteger::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlUInteger::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bWithDefault && IsDefaultValue())
return 0; return 0;
if (Value <= 0xFF) { if (Value <= 0xFF) {

View File

@ -242,7 +242,7 @@ const UTFstring & EbmlUnicodeString::DefaultVal() const
\note limited to UCS-2 \note limited to UCS-2
\todo handle exception on errors \todo handle exception on errors
*/ */
filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
uint32 Result = Value.GetUTF8().length(); uint32 Result = Value.GetUTF8().length();
@ -275,9 +275,9 @@ EbmlUnicodeString & EbmlUnicodeString::operator=(const UTFstring & NewString)
/*! /*!
\note limited to UCS-2 \note limited to UCS-2
*/ */
uint64 EbmlUnicodeString::UpdateSize(bool bKeepIntact, bool bForceRender) uint64 EbmlUnicodeString::UpdateSize(bool bWithDefault, bool bForceRender)
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bWithDefault && IsDefaultValue())
return 0; return 0;
SetSize_(Value.GetUTF8().length()); SetSize_(Value.GetUTF8().length());

View File

@ -45,7 +45,7 @@ EbmlVoid::EbmlVoid()
SetValueIsSet(); SetValueIsSet();
} }
filepos_t EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact) filepos_t EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
// write dummy data by 4KB chunks // write dummy data by 4KB chunks
static binary DummyBuf[4*1024]; static binary DummyBuf[4*1024];
@ -60,9 +60,9 @@ filepos_t EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bKee
return GetSize(); return GetSize();
} }
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact) uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
{ {
EltToReplaceWith.UpdateSize(bKeepIntact); EltToReplaceWith.UpdateSize(bWithDefault);
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) { if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here ! // the element can't be written here !
return INVALID_FILEPOS_T; return INVALID_FILEPOS_T;
@ -75,7 +75,7 @@ uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output
uint64 CurrentPosition = output.getFilePointer(); uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition()); output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bKeepIntact); EltToReplaceWith.Render(output, bWithDefault);
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) { if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
// fill the rest with another void element // fill the rest with another void element
@ -87,7 +87,7 @@ uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output
if (HeadBefore != HeadAfter) { if (HeadBefore != HeadAfter) {
aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore)); aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
} }
aTmp.RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten aTmp.RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
} }
if (ComeBackAfterward) { if (ComeBackAfterward) {
@ -97,9 +97,9 @@ uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output
return GetSize() + HeadSize(); return GetSize() + HeadSize();
} }
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact) uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
{ {
// EltToVoid.UpdateSize(bKeepIntact); // EltToVoid.UpdateSize(bWithDefault);
if (EltToVoid.GetElementPosition() == 0) { if (EltToVoid.GetElementPosition() == 0) {
// this element has never been written // this element has never been written
return 0; return 0;
@ -125,7 +125,7 @@ uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, b
} }
if (GetSize() != 0) { if (GetSize() != 0) {
RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
} }
if (ComeBackAfterward) { if (ComeBackAfterward) {