Commit bb209a33 authored by Steve Lhomme's avatar Steve Lhomme

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

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@123 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 82021dd1
......@@ -124,11 +124,11 @@ typedef struct ebml_element_vmt
bool_t (*ValidateSize)(void*);
err_t (*ReadData)(void*, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope);
#if defined(CONFIG_EBML_WRITING)
err_t (*RenderData)(void*, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered);
err_t (*RenderData)(void*, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered);
#endif
bool_t (*IsDefaultValue)(const void*);
bool_t (*DefaultIsSet)(const void*);
filepos_t (*UpdateSize)(void*, bool_t bKeepIntact, bool_t bForceRender);
filepos_t (*UpdateSize)(void*, bool_t bWithDefault, bool_t bForceRender);
int (*Cmp)(const void*, const void*);
// internal call only
......@@ -189,7 +189,7 @@ EBML_DLL ebml_element *EBML_FindNextId(stream *Input, const ebml_context *Contex
EBML_DLL ebml_element *EBML_FindNextElement(stream *Input, const ebml_parser_context *Context, int *UpperLevels, bool_t AllowDummy);
EBML_DLL int EBML_CodedSizeLength(filepos_t Length, uint8_t SizeLength, bool_t bSizeIsFinite);
EBML_DLL int EBML_CodedValueLength(filepos_t Length, size_t CodedSize, uint8_t *OutBuffer);
EBML_DLL filepos_t EBML_ElementFullSize(const ebml_element *Element, bool_t bKeepIntact);
EBML_DLL filepos_t EBML_ElementFullSize(const ebml_element *Element, bool_t bWithDefault);
EBML_DLL ebml_element *EBML_ElementSkipData(ebml_element *Element, stream *Input, const ebml_parser_context *Context, ebml_element *TestReadElt, bool_t AllowDummy);
EBML_DLL bool_t EBML_ElementIsFiniteSize(const ebml_element *Element);
......@@ -213,8 +213,8 @@ static INLINE filepos_t EBML_ElementPositionEnd(const ebml_element *Element)
#if defined(CONFIG_EBML_WRITING)
// TODO: replace the list of bools by flags
EBML_DLL err_t EBML_ElementRender(ebml_element *Element, stream *Output, bool_t bKeepIntact, bool_t bKeepPosition, bool_t bForceRender, filepos_t *Rendered);
EBML_DLL err_t EBML_ElementRenderHead(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, bool_t bKeepPosition, filepos_t *Rendered);
EBML_DLL err_t EBML_ElementRender(ebml_element *Element, stream *Output, bool_t bWithDefault, bool_t bKeepPosition, bool_t bForceRender, filepos_t *Rendered);
EBML_DLL err_t EBML_ElementRenderHead(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, bool_t bKeepPosition, filepos_t *Rendered);
#endif
// type specific routines
......@@ -242,7 +242,7 @@ EBML_DLL err_t EBML_BinarySetData(ebml_binary *Element, const uint8_t *Data, siz
#if defined(CONFIG_EBML_WRITING)
EBML_DLL void EBML_VoidSetSize(ebml_element *Void, filepos_t);
EBML_DLL filepos_t EBML_VoidReplaceWith(ebml_element *Void, ebml_element *Replaced, stream *Output, bool_t ComeBackAfterward, bool_t bKeepIntact);
EBML_DLL filepos_t EBML_VoidReplaceWith(ebml_element *Void, ebml_element *Replaced, stream *Output, bool_t ComeBackAfterward, bool_t bWithDefault);
#endif
#if defined(EBML_LEGACY_API)
......
......@@ -56,7 +56,7 @@ failed:
}
#if defined(CONFIG_EBML_WRITING)
static err_t RenderData(ebml_binary *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderData(ebml_binary *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
size_t Written;
err_t Err = Stream_Write(Output,ARRAYBEGIN(Element->Data,uint8_t),ARRAYCOUNT(Element->Data,uint8_t),&Written);
......@@ -85,7 +85,7 @@ static bool_t IsDefaultValue(const ebml_binary *Element)
return 0; // TODO: a default binary value needs a size too (use a structure to set the value in the structure)
}
static filepos_t UpdateSize(ebml_binary *Element, bool_t bKeepIntact, bool_t bForceRender)
static filepos_t UpdateSize(ebml_binary *Element, bool_t bWithDefault, bool_t bForceRender)
{
Element->Base.Size = ARRAYCOUNT(Element->Data,uint8_t);
......
......@@ -143,9 +143,9 @@ static size_t GetIdLength(fourcc_t Id)
return 4;
}
filepos_t EBML_ElementFullSize(const ebml_element *Element, bool_t bKeepIntact)
filepos_t EBML_ElementFullSize(const ebml_element *Element, bool_t bWithDefault)
{
if (!bKeepIntact && EBML_ElementIsDefaultValue(Element))
if (!bWithDefault && EBML_ElementIsDefaultValue(Element))
return INVALID_FILEPOS_T; // won't be saved
return Element->Size + GetIdLength(Element->Context->Id) + EBML_CodedSizeLength(Element->Size, Element->SizeLength, EBML_ElementIsFiniteSize(Element));
}
......@@ -174,7 +174,7 @@ bool_t EBML_ElementInfiniteForceSize(ebml_element *Element, filepos_t NewSize)
}
#if defined(CONFIG_EBML_WRITING)
err_t EBML_ElementRender(ebml_element *Element, stream *Output, bool_t bKeepIntact, bool_t bKeepPosition, bool_t bForceRender, filepos_t *Rendered)
err_t EBML_ElementRender(ebml_element *Element, stream *Output, bool_t bWithDefault, bool_t bKeepPosition, bool_t bForceRender, filepos_t *Rendered)
{
err_t Result;
filepos_t _Rendered,WrittenSize;
......@@ -186,20 +186,20 @@ err_t EBML_ElementRender(ebml_element *Element, stream *Output, bool_t bKeepInta
Rendered = &_Rendered;
*Rendered = 0;
assert(Element->bValueIsSet || (bKeepIntact && Element->bDefaultIsSet)); // an element is been rendered without a value set !!!
assert(Element->bValueIsSet || (bWithDefault && Element->bDefaultIsSet)); // an element is been rendered without a value set !!!
// it may be a mandatory element without a default value
if (!bKeepIntact && EBML_ElementIsDefaultValue(Element))
if (!bWithDefault && EBML_ElementIsDefaultValue(Element))
return ERR_INVALID_DATA;
#if !defined(NDEBUG)
SupposedSize = EBML_ElementUpdateSize(Element,bKeepIntact, bForceRender);
SupposedSize = EBML_ElementUpdateSize(Element,bWithDefault, bForceRender);
#endif
Result = EBML_ElementRenderHead(Element, Output, bForceRender, bKeepIntact, bKeepPosition, &WrittenSize);
Result = EBML_ElementRenderHead(Element, Output, bForceRender, bWithDefault, bKeepPosition, &WrittenSize);
*Rendered += WrittenSize;
if (Result != ERR_NONE)
return Result;
Result = EBML_ElementRenderData(Element, Output, bForceRender, bKeepIntact, &WrittenSize);
Result = EBML_ElementRenderData(Element, Output, bForceRender, bWithDefault, &WrittenSize);
#if !defined(NDEBUG)
if (SupposedSize != (0-1)) assert(WrittenSize == SupposedSize);
#endif
......@@ -239,9 +239,9 @@ static err_t MakeRenderHead(ebml_element *Element, stream *Output, bool_t bKeepP
return Err;
}
err_t EBML_ElementRenderHead(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, bool_t bKeepPosition, filepos_t *Rendered)
err_t EBML_ElementRenderHead(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, bool_t bKeepPosition, filepos_t *Rendered)
{
EBML_ElementUpdateSize(Element,bKeepIntact, bForceRender); // TODO: use a flag to tell wether the Size needs to be updated or not
EBML_ElementUpdateSize(Element,bWithDefault, bForceRender); // TODO: use a flag to tell wether the Size needs to be updated or not
return MakeRenderHead(Element, Output, bKeepPosition,Rendered);
}
......
......@@ -147,7 +147,7 @@ static bool_t CheckMandatory(const ebml_element *Element)
return 1;
}
filepos_t UpdateSize(ebml_element *Element, bool_t bKeepIntact, bool_t bForceRender)
filepos_t UpdateSize(ebml_element *Element, bool_t bWithDefault, bool_t bForceRender)
{
ebml_element *i;
......@@ -162,16 +162,16 @@ filepos_t UpdateSize(ebml_element *Element, bool_t bKeepIntact, bool_t bForceRen
for (i=EBML_MasterChildren(Element);i;i=EBML_MasterNext(i))
{
if (!bKeepIntact && EBML_ElementIsDefaultValue(i))
if (!bWithDefault && EBML_ElementIsDefaultValue(i))
continue;
EBML_ElementUpdateSize(i,bKeepIntact,bForceRender);
EBML_ElementUpdateSize(i,bWithDefault,bForceRender);
if (i->Size == INVALID_FILEPOS_T)
return INVALID_FILEPOS_T;
Element->Size += EBML_ElementFullSize(i,bKeepIntact);
Element->Size += EBML_ElementFullSize(i,bWithDefault);
}
#ifdef TODO
if (bChecksumUsed) {
Element->Size += EBML_ElementFullSize(Element->Checksum,bKeepIntact);
Element->Size += EBML_ElementFullSize(Element->Checksum,bWithDefault);
}
#endif
return Element->Size;
......@@ -261,7 +261,7 @@ processCrc:
}
#if defined(CONFIG_EBML_WRITING)
static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
ebml_element *i;
filepos_t _Rendered;
......@@ -281,9 +281,9 @@ static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRend
#endif
for (i=EBML_MasterChildren(Element);i;i=EBML_MasterNext(i))
{
if (!bKeepIntact && EBML_ElementIsDefaultValue(i))
if (!bWithDefault && EBML_ElementIsDefaultValue(i))
continue;
Err = EBML_ElementRender(i,Output, bKeepIntact, 0, bForceRender, &ItemRendered);
Err = EBML_ElementRender(i,Output, bWithDefault, 0, bForceRender, &ItemRendered);
if (Err!=ERR_NONE)
return Err;
*Rendered += ItemRendered;
......@@ -292,9 +292,9 @@ static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRend
} else { // new school: render in memory and compute the CRC
MemIOCallback TmpBuf(Size - 6);
for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue())
if (!bWithDefault && (ElementList[Index])->IsDefaultValue())
continue;
(ElementList[Index])->Render(TmpBuf, bKeepIntact, false ,bForceRender);
(ElementList[Index])->Render(TmpBuf, bWithDefault, false ,bForceRender);
}
Checksum.FillCRC32(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
Result += Checksum.Render(output, true, false ,bForceRender);
......
......@@ -99,7 +99,7 @@ failed:
}
#if defined(CONFIG_EBML_WRITING)
static err_t RenderDataSignedInt(ebml_integer *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderDataSignedInt(ebml_integer *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
uint8_t FinalData[8]; // we don't handle more than 64 bits integers
size_t i;
......@@ -124,7 +124,7 @@ static err_t RenderDataSignedInt(ebml_integer *Element, stream *Output, bool_t b
return Err;
}
static err_t RenderDataInt(ebml_integer *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderDataInt(ebml_integer *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
uint8_t FinalData[8]; // we don't handle more than 64 bits integers
size_t i;
......@@ -149,7 +149,7 @@ static err_t RenderDataInt(ebml_integer *Element, stream *Output, bool_t bForceR
return Err;
}
static err_t RenderDataFloat(ebml_float *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderDataFloat(ebml_float *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
err_t Err;
size_t i = 0;
......@@ -244,9 +244,9 @@ static bool_t IsDefaultValueFloat(const ebml_float *Element)
return Element->Base.Context->HasDefault && (!Element->Base.bValueIsSet || (Element->Value == (double)Element->Base.Context->DefaultValue));
}
static filepos_t UpdateSizeSignedInt(ebml_integer *Element, bool_t bKeepIntact, bool_t bForceRender)
static filepos_t UpdateSizeSignedInt(ebml_integer *Element, bool_t bWithDefault, bool_t bForceRender)
{
if (!bKeepIntact && IsDefaultValueInt(Element))
if (!bWithDefault && IsDefaultValueInt(Element))
return 0;
if (Element->Value <= 0x7F && Element->Value >= (-0x80)) {
......@@ -273,9 +273,9 @@ static filepos_t UpdateSizeSignedInt(ebml_integer *Element, bool_t bKeepIntact,
return Element->Base.Size;
}
static filepos_t UpdateSizeInt(ebml_integer *Element, bool_t bKeepIntact, bool_t bForceRender)
static filepos_t UpdateSizeInt(ebml_integer *Element, bool_t bWithDefault, bool_t bForceRender)
{
if (!bKeepIntact && IsDefaultValueInt(Element))
if (!bWithDefault && IsDefaultValueInt(Element))
return 0;
if (Element->Value <= 0xFF) {
......@@ -302,9 +302,9 @@ static filepos_t UpdateSizeInt(ebml_integer *Element, bool_t bKeepIntact, bool_t
return Element->Base.Size;
}
static filepos_t UpdateSizeFloat(ebml_float *Element, bool_t bKeepIntact, bool_t bForceRender)
static filepos_t UpdateSizeFloat(ebml_float *Element, bool_t bWithDefault, bool_t bForceRender)
{
if (!bKeepIntact && IsDefaultValueFloat(Element))
if (!bWithDefault && IsDefaultValueFloat(Element))
return 0;
return Element->Base.Size;
}
......
......@@ -85,7 +85,7 @@ failed:
}
#if defined(CONFIG_EBML_WRITING)
static err_t RenderData(ebml_string *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderData(ebml_string *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
size_t Written;
err_t Err = Stream_Write(Output,Element->Buffer,(size_t)Element->Base.Size,&Written);
......@@ -142,9 +142,9 @@ static void Delete(ebml_string *p)
free((char*)p->Buffer);
}
static filepos_t UpdateSize(ebml_string *Element, bool_t bKeepIntact, bool_t bForceRender)
static filepos_t UpdateSize(ebml_string *Element, bool_t bWithDefault, bool_t bForceRender)
{
if (!bKeepIntact && EBML_ElementIsDefaultValue(Element))
if (!bWithDefault && EBML_ElementIsDefaultValue(Element))
return 0;
Element->Base.Size = strlen(Element->Buffer);
......
......@@ -37,13 +37,13 @@ static bool_t IsDefaultValue(const ebml_element *Element)
return 0;
}
static filepos_t UpdateSize(ebml_element *Element, bool_t bKeepIntact, bool_t bForceRender)
static filepos_t UpdateSize(ebml_element *Element, bool_t bWithDefault, bool_t bForceRender)
{
return Element->Size;
}
#if defined(CONFIG_EBML_WRITING)
static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bKeepIntact, filepos_t *Rendered)
static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
size_t Written, Left = Element->Size;
err_t Err = ERR_NONE;
......@@ -77,12 +77,12 @@ void EBML_VoidSetSize(ebml_element *Void, filepos_t Size)
Void->bValueIsSet = 1;
}
filepos_t EBML_VoidReplaceWith(ebml_element *Void, ebml_element *ReplacedWith, stream *Output, bool_t ComeBackAfterward, bool_t bKeepIntact)
filepos_t EBML_VoidReplaceWith(ebml_element *Void, ebml_element *ReplacedWith, stream *Output, bool_t ComeBackAfterward, bool_t bWithDefault)
{
filepos_t CurrentPosition;
assert(Node_IsPartOf(Void,EBML_VOID_CLASS));
EBML_ElementUpdateSize(ReplacedWith,bKeepIntact,0);
EBML_ElementUpdateSize(ReplacedWith,bWithDefault,0);
if (EBML_ElementFullSize(Void,1) < EBML_ElementFullSize(ReplacedWith,1))
// the element can't be written here !
return INVALID_FILEPOS_T;
......@@ -93,7 +93,7 @@ filepos_t EBML_VoidReplaceWith(ebml_element *Void, ebml_element *ReplacedWith, s
CurrentPosition = Stream_Seek(Output,0,SEEK_CUR);
Stream_Seek(Output,Void->ElementPosition,SEEK_SET);
EBML_ElementRender(ReplacedWith,Output,bKeepIntact,0,1,NULL);
EBML_ElementRender(ReplacedWith,Output,bWithDefault,0,1,NULL);
if (EBML_ElementFullSize(Void,1) - EBML_ElementFullSize(ReplacedWith,1) > 1)
{
......
......@@ -278,16 +278,16 @@ namespace LIBEBML_NAMESPACE {
public:
virtual ~EbmlElement();
void SetSizeLength(size_t);
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 bool SetSizeInfinite(bool bIsInfinite = true);
filepos_t GetElementPosition() const;
size_t HeadSize() const;
filepos_t ElementSize(bool bKeepIntact = false) const;
filepos_t ElementSize(bool bWithDefault = false) const;
bool IsFiniteSize() const;
virtual filepos_t GetSize() const;
size_t GetSizeLength() const;
virtual operator const EbmlId () const = 0;
filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false); /// update the Size of the Data stored
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false); /// update the Size of the Data stored
virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
virtual EbmlElement * Clone() const = 0;
......
......@@ -73,7 +73,7 @@ namespace LIBEBML_NAMESPACE {
\brief Remove an element from the list of the master
*/
void Remove(size_t Index);
filepos_t WriteHead(IOCallback & output, size_t SizeLength, bool bKeepIntact = false);
filepos_t WriteHead(IOCallback & output, size_t SizeLength, bool bWithDefault = false);
EBML_MASTER_ITERATOR begin() const;
EBML_MASTER_ITERATOR end() const;
......
......@@ -38,7 +38,7 @@ DECLARE_EBML_VOID(EbmlVoid)
virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
void SetSize(filepos_t);
filepos_t ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
filepos_t ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bWithDefault = false);
};
};
......
......@@ -336,9 +336,9 @@ assert(0);
return NULL;
}
filepos_t EbmlElement::UpdateSize(bool bKeepIntact, bool bForceRender)
filepos_t EbmlElement::UpdateSize(bool bWithDefault, bool bForceRender)
{
return EBML_ElementUpdateSize(Node, bKeepIntact, bForceRender);
return EBML_ElementUpdateSize(Node, bWithDefault, bForceRender);
}
bool EbmlElement::IsFiniteSize() const
......@@ -402,9 +402,9 @@ size_t EbmlElement::HeadSize() const
return Result;
}
filepos_t EbmlElement::ElementSize(bool bKeepIntact) const
filepos_t EbmlElement::ElementSize(bool bWithDefault) const
{
return EBML_ElementFullSize(Node,bKeepIntact);
return EBML_ElementFullSize(Node,bWithDefault);
}
filepos_t EbmlElement::GetElementPosition() const
......@@ -412,10 +412,10 @@ filepos_t EbmlElement::GetElementPosition() const
return Node->ElementPosition;
}
filepos_t EbmlElement::Render(IOCallback & output, bool bKeepIntact, bool bKeepPosition, bool bForceRender)
filepos_t EbmlElement::Render(IOCallback & output, bool bWithDefault, bool bKeepPosition, bool bForceRender)
{
filepos_t Rendered = INVALID_FILEPOS_T;
if (EBML_ElementRender(Node, output.GetStream(), bKeepIntact, bKeepPosition, bForceRender, &Rendered)!=ERR_NONE)
if (EBML_ElementRender(Node, output.GetStream(), bWithDefault, bKeepPosition, bForceRender, &Rendered)!=ERR_NONE)
return INVALID_FILEPOS_T;
return Rendered;
}
......@@ -580,11 +580,11 @@ assert(0);
return INVALID_FILEPOS_T;
}
filepos_t EbmlMaster::WriteHead(IOCallback & output, size_t SizeLength, bool bKeepIntact)
filepos_t EbmlMaster::WriteHead(IOCallback & output, size_t SizeLength, bool bWithDefault)
{
filepos_t Rendered = INVALID_FILEPOS_T;
Node->SizeLength = (int8_t)SizeLength;
if (EBML_ElementRenderHead(Node, output.GetStream(), 1, bKeepIntact, 0, &Rendered)!=ERR_NONE)
if (EBML_ElementRenderHead(Node, output.GetStream(), 1, bWithDefault, 0, &Rendered)!=ERR_NONE)
return INVALID_FILEPOS_T;
return Rendered;
}
......@@ -1140,9 +1140,9 @@ filepos_t EbmlVoid::ReadData(IOCallback & input, ScopeMode ReadFully)
return 0;
}
filepos_t EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
filepos_t EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
{
return EBML_VoidReplaceWith(Node, EltToReplaceWith.GetNode(), output.GetStream(), ComeBackAfterward, bKeepIntact);
return EBML_VoidReplaceWith(Node, EltToReplaceWith.GetNode(), output.GetStream(), ComeBackAfterward, bWithDefault);
}
void EbmlVoid::SetSize(filepos_t Size)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment