update the copyright notice to 2010

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@18 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-03-15 16:19:18 +00:00
parent 4bea9a04da
commit 995bc139c4
34 changed files with 2247 additions and 2247 deletions

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** 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

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** 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

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -1,104 +1,104 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 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: EbmlSubHead.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_SUBHEAD_H
#define LIBEBML_SUBHEAD_H
#include <string>
#include "EbmlUInteger.h"
#include "EbmlString.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EVersion : public EbmlUInteger {
public:
EVersion() :EbmlUInteger(1) {}
EVersion(const EVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EVersion)
};
class EBML_DLL_API EReadVersion : public EbmlUInteger {
public:
EReadVersion() :EbmlUInteger(1) {}
EReadVersion(const EReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EReadVersion)
};
class EBML_DLL_API EMaxIdLength : public EbmlUInteger {
public:
EMaxIdLength() :EbmlUInteger(4) {}
EMaxIdLength(const EMaxIdLength & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EMaxIdLength)
};
class EBML_DLL_API EMaxSizeLength : public EbmlUInteger {
public:
EMaxSizeLength() :EbmlUInteger(8) {}
EMaxSizeLength(const EMaxSizeLength & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EMaxSizeLength)
};
class EBML_DLL_API EDocType : public EbmlString {
public:
EDocType() {}
EDocType(const EDocType & ElementToClone) : EbmlString(ElementToClone) {}
EBML_CONCRETE_CLASS(EDocType)
};
class EBML_DLL_API EDocTypeVersion : public EbmlUInteger {
public:
EDocTypeVersion() {}
EDocTypeVersion(const EDocTypeVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EDocTypeVersion)
};
class EBML_DLL_API EDocTypeReadVersion : public EbmlUInteger {
public:
EDocTypeReadVersion() {}
EDocTypeReadVersion(const EDocTypeReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EDocTypeReadVersion)
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_SUBHEAD_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: EbmlSubHead.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_SUBHEAD_H
#define LIBEBML_SUBHEAD_H
#include <string>
#include "EbmlUInteger.h"
#include "EbmlString.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EVersion : public EbmlUInteger {
public:
EVersion() :EbmlUInteger(1) {}
EVersion(const EVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EVersion)
};
class EBML_DLL_API EReadVersion : public EbmlUInteger {
public:
EReadVersion() :EbmlUInteger(1) {}
EReadVersion(const EReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EReadVersion)
};
class EBML_DLL_API EMaxIdLength : public EbmlUInteger {
public:
EMaxIdLength() :EbmlUInteger(4) {}
EMaxIdLength(const EMaxIdLength & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EMaxIdLength)
};
class EBML_DLL_API EMaxSizeLength : public EbmlUInteger {
public:
EMaxSizeLength() :EbmlUInteger(8) {}
EMaxSizeLength(const EMaxSizeLength & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EMaxSizeLength)
};
class EBML_DLL_API EDocType : public EbmlString {
public:
EDocType() {}
EDocType(const EDocType & ElementToClone) : EbmlString(ElementToClone) {}
EBML_CONCRETE_CLASS(EDocType)
};
class EBML_DLL_API EDocTypeVersion : public EbmlUInteger {
public:
EDocTypeVersion() {}
EDocTypeVersion(const EDocTypeVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EDocTypeVersion)
};
class EBML_DLL_API EDocTypeReadVersion : public EbmlUInteger {
public:
EDocTypeReadVersion() {}
EDocTypeReadVersion(const EDocTypeReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
EBML_CONCRETE_CLASS(EDocTypeReadVersion)
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_SUBHEAD_H

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -1,75 +1,75 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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: EbmlVoid.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_VOID_H
#define LIBEBML_VOID_H
#include "EbmlTypes.h"
#include "EbmlBinary.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EbmlVoid : public EbmlBinary {
public:
EbmlVoid();
EbmlVoid(const EbmlVoid & ElementToClone) :EbmlBinary(ElementToClone){}
bool ValidateSize() const {return true;} // any void element is accepted
/*!
\brief Set the size of the data (not the complete size of the element)
*/
void SetSize(uint64 aSize) {SetSize_(aSize);}
/*!
\note overwrite to write fake data
*/
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
/*!
\brief Replace the void element content (written) with this one
*/
uint64 ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
/*!
\brief Void the content of an element
*/
uint64 Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
EBML_CONCRETE_CLASS(EbmlVoid)
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_VOID_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: EbmlVoid.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_VOID_H
#define LIBEBML_VOID_H
#include "EbmlTypes.h"
#include "EbmlBinary.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EbmlVoid : public EbmlBinary {
public:
EbmlVoid();
EbmlVoid(const EbmlVoid & ElementToClone) :EbmlBinary(ElementToClone){}
bool ValidateSize() const {return true;} // any void element is accepted
/*!
\brief Set the size of the data (not the complete size of the element)
*/
void SetSize(uint64 aSize) {SetSize_(aSize);}
/*!
\note overwrite to write fake data
*/
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
/*!
\brief Replace the void element content (written) with this one
*/
uint64 ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
/*!
\brief Void the content of an element
*/
uint64 Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
EBML_CONCRETE_CLASS(EbmlVoid)
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_VOID_H

View File

@ -1,101 +1,101 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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.cpp 1112 2005-03-28 09:55:50Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlBinary.h"
START_LIBEBML_NAMESPACE
EbmlBinary::EbmlBinary()
:EbmlElement(0, false), Data(NULL)
{}
EbmlBinary::EbmlBinary(const EbmlBinary & ElementToClone)
:EbmlElement(ElementToClone)
{
if (ElementToClone.Data == NULL)
Data = NULL;
else {
Data = (binary *)malloc(GetSize() * sizeof(binary));
assert(Data != NULL);
memcpy(Data, ElementToClone.Data, GetSize());
}
}
EbmlBinary::~EbmlBinary(void) {
if(Data)
free(Data);
}
uint32 EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
output.writeFully(Data,GetSize());
return GetSize();
}
/*!
\note no Default binary value handled
*/
uint64 EbmlBinary::UpdateSize(bool bKeepIntact, bool bForceRender)
{
return GetSize();
}
uint64 EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (Data != NULL)
free(Data);
if (ReadFully == SCOPE_NO_DATA)
{
Data = NULL;
return GetSize();
}
Data = (binary *)malloc(GetSize() * sizeof(binary));
assert(Data != NULL);
SetValueIsSet();
return input.read(Data, GetSize());
}
bool EbmlBinary::operator==(const EbmlBinary & ElementToCompare) const
{
return ((GetSize() == ElementToCompare.GetSize()) && !memcmp(Data, ElementToCompare.Data, GetSize()));
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 1112 2005-03-28 09:55:50Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlBinary.h"
START_LIBEBML_NAMESPACE
EbmlBinary::EbmlBinary()
:EbmlElement(0, false), Data(NULL)
{}
EbmlBinary::EbmlBinary(const EbmlBinary & ElementToClone)
:EbmlElement(ElementToClone)
{
if (ElementToClone.Data == NULL)
Data = NULL;
else {
Data = (binary *)malloc(GetSize() * sizeof(binary));
assert(Data != NULL);
memcpy(Data, ElementToClone.Data, GetSize());
}
}
EbmlBinary::~EbmlBinary(void) {
if(Data)
free(Data);
}
uint32 EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
output.writeFully(Data,GetSize());
return GetSize();
}
/*!
\note no Default binary value handled
*/
uint64 EbmlBinary::UpdateSize(bool bKeepIntact, bool bForceRender)
{
return GetSize();
}
uint64 EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (Data != NULL)
free(Data);
if (ReadFully == SCOPE_NO_DATA)
{
Data = NULL;
return GetSize();
}
Data = (binary *)malloc(GetSize() * sizeof(binary));
assert(Data != NULL);
SetValueIsSet();
return input.read(Data, GetSize());
}
bool EbmlBinary::operator==(const EbmlBinary & ElementToCompare) const
{
return ((GetSize() == ElementToCompare.GetSize()) && !memcmp(Data, ElementToCompare.Data, GetSize()));
}
END_LIBEBML_NAMESPACE

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -1,80 +1,80 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlDate.h"
START_LIBEBML_NAMESPACE
const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
EbmlDate::EbmlDate(const EbmlDate & ElementToClone)
:EbmlElement(ElementToClone)
{
myDate = ElementToClone.myDate;
}
uint64 EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() != 0) {
assert(GetSize() == 8);
binary Buffer[8];
input.readFully(Buffer, GetSize());
big_int64 b64;
b64.Eval(Buffer);
myDate = b64;
SetValueIsSet();
}
}
return GetSize();
}
uint32 EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
if (GetSize() != 0) {
assert(GetSize() == 8);
big_int64 b64(myDate);
output.writeFully(&b64.endian(),GetSize());
}
return GetSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlDate.h"
START_LIBEBML_NAMESPACE
const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
EbmlDate::EbmlDate(const EbmlDate & ElementToClone)
:EbmlElement(ElementToClone)
{
myDate = ElementToClone.myDate;
}
uint64 EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() != 0) {
assert(GetSize() == 8);
binary Buffer[8];
input.readFully(Buffer, GetSize());
big_int64 b64;
b64.Eval(Buffer);
myDate = b64;
SetValueIsSet();
}
}
return GetSize();
}
uint32 EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
if (GetSize() != 0) {
assert(GetSize() == 8);
big_int64 b64(myDate);
output.writeFully(&b64.endian(),GetSize());
}
return GetSize();
}
END_LIBEBML_NAMESPACE

View File

@ -1,45 +1,45 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 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.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlDummy.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
const EbmlId EbmlDummy::DummyRawId(0xFF, 1);
const EbmlSemanticContext EbmlDummy_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, &EBML_INFO(EbmlDummy));
const EbmlCallbacks EbmlDummy::ClassInfos(NULL, DummyRawId, "DummyElement", EbmlDummy_Context);
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlDummy.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
const EbmlId EbmlDummy::DummyRawId(0xFF, 1);
const EbmlSemanticContext EbmlDummy_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, &EBML_INFO(EbmlDummy));
const EbmlCallbacks EbmlDummy::ClassInfos(NULL, DummyRawId, "DummyElement", EbmlDummy_Context);
END_LIBEBML_NAMESPACE

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +1,128 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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.cpp 1243 2006-03-30 19:33:22Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlFloat.h"
START_LIBEBML_NAMESPACE
EbmlFloat::EbmlFloat(const EbmlFloat::Precision prec)
:EbmlElement(0, false)
{
SetPrecision(prec);
}
EbmlFloat::EbmlFloat(const double aDefaultValue, const EbmlFloat::Precision prec)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultIsSet();
SetPrecision(prec);
}
EbmlFloat::EbmlFloat(const EbmlFloat & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
\todo handle 10 bits precision
*/
uint32 EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
assert(GetSize() == 4 || GetSize() == 8);
if (GetSize() == 4) {
float val = Value;
int Tmp;
memcpy(&Tmp, &val, 4);
big_int32 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), GetSize());
} else if (GetSize() == 8) {
double val = Value;
int64 Tmp;
memcpy(&Tmp, &val, 8);
big_int64 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), GetSize());
}
return GetSize();
}
uint64 EbmlFloat::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
return GetSize();
}
/*!
\todo remove the hack for possible endianess pb (test on little & big endian)
*/
uint64 EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[20];
assert(GetSize() <= 20);
input.readFully(Buffer, GetSize());
if (GetSize() == 4) {
big_int32 TmpRead;
TmpRead.Eval(Buffer);
int32 tmpp = int32(TmpRead);
float val;
memcpy(&val, &tmpp, 4);
Value = val;
SetValueIsSet();
} else if (GetSize() == 8) {
big_int64 TmpRead;
TmpRead.Eval(Buffer);
int64 tmpp = int64(TmpRead);
double val;
memcpy(&val, &tmpp, 8);
Value = val;
SetValueIsSet();
}
}
return GetSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 1243 2006-03-30 19:33:22Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlFloat.h"
START_LIBEBML_NAMESPACE
EbmlFloat::EbmlFloat(const EbmlFloat::Precision prec)
:EbmlElement(0, false)
{
SetPrecision(prec);
}
EbmlFloat::EbmlFloat(const double aDefaultValue, const EbmlFloat::Precision prec)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultIsSet();
SetPrecision(prec);
}
EbmlFloat::EbmlFloat(const EbmlFloat & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
\todo handle 10 bits precision
*/
uint32 EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
assert(GetSize() == 4 || GetSize() == 8);
if (GetSize() == 4) {
float val = Value;
int Tmp;
memcpy(&Tmp, &val, 4);
big_int32 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), GetSize());
} else if (GetSize() == 8) {
double val = Value;
int64 Tmp;
memcpy(&Tmp, &val, 8);
big_int64 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), GetSize());
}
return GetSize();
}
uint64 EbmlFloat::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
return GetSize();
}
/*!
\todo remove the hack for possible endianess pb (test on little & big endian)
*/
uint64 EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[20];
assert(GetSize() <= 20);
input.readFully(Buffer, GetSize());
if (GetSize() == 4) {
big_int32 TmpRead;
TmpRead.Eval(Buffer);
int32 tmpp = int32(TmpRead);
float val;
memcpy(&val, &tmpp, 4);
Value = val;
SetValueIsSet();
} else if (GetSize() == 8) {
big_int64 TmpRead;
TmpRead.Eval(Buffer);
int64 tmpp = int64(TmpRead);
double val;
memcpy(&val, &tmpp, 8);
Value = val;
SetValueIsSet();
}
}
return GetSize();
}
END_LIBEBML_NAMESPACE

View File

@ -1,62 +1,62 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 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: EbmlHead.cpp 1096 2005-03-17 09:14:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlHead.h"
#include "ebml/EbmlSubHead.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
const EbmlSemantic EbmlHead_ContextList[] =
{
EbmlSemantic(true, true, EBML_INFO(EVersion)), ///< EBMLVersion
EbmlSemantic(true, true, EBML_INFO(EReadVersion)), ///< EBMLReadVersion
EbmlSemantic(true, true, EBML_INFO(EMaxIdLength)), ///< EBMLMaxIdLength
EbmlSemantic(true, true, EBML_INFO(EMaxSizeLength)), ///< EBMLMaxSizeLength
EbmlSemantic(true, true, EBML_INFO(EDocType)), ///< DocType
EbmlSemantic(true, true, EBML_INFO(EDocTypeVersion)), ///< DocTypeVersion
EbmlSemantic(true, true, EBML_INFO(EDocTypeReadVersion)), ///< DocTypeReadVersion
};
const EbmlSemanticContext EbmlHead_Context = EbmlSemanticContext(countof(EbmlHead_ContextList), EbmlHead_ContextList, NULL, *GetEbmlGlobal_Context, &EBML_INFO(EbmlHead));
EbmlId EbmlHead_TheId(0x1A45DFA3, 4);
const EbmlCallbacks EbmlHead::ClassInfos(EbmlHead::Create, EbmlHead_TheId, "EBMLHead\0ratamapaga", EbmlHead_Context);
EbmlHead::EbmlHead()
:EbmlMaster(EbmlHead_Context)
{}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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: EbmlHead.cpp 1096 2005-03-17 09:14:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlHead.h"
#include "ebml/EbmlSubHead.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
const EbmlSemantic EbmlHead_ContextList[] =
{
EbmlSemantic(true, true, EBML_INFO(EVersion)), ///< EBMLVersion
EbmlSemantic(true, true, EBML_INFO(EReadVersion)), ///< EBMLReadVersion
EbmlSemantic(true, true, EBML_INFO(EMaxIdLength)), ///< EBMLMaxIdLength
EbmlSemantic(true, true, EBML_INFO(EMaxSizeLength)), ///< EBMLMaxSizeLength
EbmlSemantic(true, true, EBML_INFO(EDocType)), ///< DocType
EbmlSemantic(true, true, EBML_INFO(EDocTypeVersion)), ///< DocTypeVersion
EbmlSemantic(true, true, EBML_INFO(EDocTypeReadVersion)), ///< DocTypeReadVersion
};
const EbmlSemanticContext EbmlHead_Context = EbmlSemanticContext(countof(EbmlHead_ContextList), EbmlHead_ContextList, NULL, *GetEbmlGlobal_Context, &EBML_INFO(EbmlHead));
EbmlId EbmlHead_TheId(0x1A45DFA3, 4);
const EbmlCallbacks EbmlHead::ClassInfos(EbmlHead::Create, EbmlHead_TheId, "EBMLHead\0ratamapaga", EbmlHead_Context);
EbmlHead::EbmlHead()
:EbmlMaster(EbmlHead_Context)
{}
END_LIBEBML_NAMESPACE

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -1,136 +1,136 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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: EbmlSInteger.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include "ebml/EbmlSInteger.h"
START_LIBEBML_NAMESPACE
EbmlSInteger::EbmlSInteger()
:EbmlElement(DEFAULT_INT_SIZE, false)
{}
EbmlSInteger::EbmlSInteger(int64 aDefaultValue)
:EbmlElement(DEFAULT_INT_SIZE, true), Value(aDefaultValue)
{
SetDefaultIsSet();
}
EbmlSInteger::EbmlSInteger(const EbmlSInteger & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
unsigned int i;
if (GetSizeLength() > 8)
return 0; // integer bigger coded on more than 64 bits are not supported
int64 TempValue = Value;
for (i=0; i<GetSize();i++) {
FinalData[GetSize()-i-1] = binary(TempValue & 0xFF);
TempValue >>= 8;
}
output.writeFully(FinalData,GetSize());
return GetSize();
}
uint64 EbmlSInteger::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value <= 0x7F && Value >= (-0x80)) {
SetSize_(1);
} else if (Value <= 0x7FFF && Value >= (-0x8000)) {
SetSize_(2);
} else if (Value <= 0x7FFFFF && Value >= (-0x800000)) {
SetSize_(3);
} else if (Value <= 0x7FFFFFFF && Value >= (-0x80000000)) {
SetSize_(4);
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x8000000000)) {
SetSize_(5);
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x800000000000)) {
SetSize_(6);
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x80000000000000)) {
SetSize_(7);
} else {
SetSize_(8);
}
if (GetDefaultSize() > GetSize()) {
SetSize_(GetDefaultSize());
}
return GetSize();
}
uint64 EbmlSInteger::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[8];
input.readFully(Buffer, GetSize());
if (Buffer[0] & 0x80)
Value = -1; // this is a negative value
else
Value = 0; // this is a positive value
for (unsigned int i=0; i<GetSize(); i++)
{
Value <<= 8;
Value |= Buffer[i];
}
SetValueIsSet();
}
return GetSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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: EbmlSInteger.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include "ebml/EbmlSInteger.h"
START_LIBEBML_NAMESPACE
EbmlSInteger::EbmlSInteger()
:EbmlElement(DEFAULT_INT_SIZE, false)
{}
EbmlSInteger::EbmlSInteger(int64 aDefaultValue)
:EbmlElement(DEFAULT_INT_SIZE, true), Value(aDefaultValue)
{
SetDefaultIsSet();
}
EbmlSInteger::EbmlSInteger(const EbmlSInteger & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
unsigned int i;
if (GetSizeLength() > 8)
return 0; // integer bigger coded on more than 64 bits are not supported
int64 TempValue = Value;
for (i=0; i<GetSize();i++) {
FinalData[GetSize()-i-1] = binary(TempValue & 0xFF);
TempValue >>= 8;
}
output.writeFully(FinalData,GetSize());
return GetSize();
}
uint64 EbmlSInteger::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value <= 0x7F && Value >= (-0x80)) {
SetSize_(1);
} else if (Value <= 0x7FFF && Value >= (-0x8000)) {
SetSize_(2);
} else if (Value <= 0x7FFFFF && Value >= (-0x800000)) {
SetSize_(3);
} else if (Value <= 0x7FFFFFFF && Value >= (-0x80000000)) {
SetSize_(4);
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x8000000000)) {
SetSize_(5);
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x800000000000)) {
SetSize_(6);
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x80000000000000)) {
SetSize_(7);
} else {
SetSize_(8);
}
if (GetDefaultSize() > GetSize()) {
SetSize_(GetDefaultSize());
}
return GetSize();
}
uint64 EbmlSInteger::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[8];
input.readFully(Buffer, GetSize());
if (Buffer[0] & 0x80)
Value = -1; // this is a negative value
else
Value = 0; // this is a positive value
for (unsigned int i=0; i<GetSize(); i++)
{
Value <<= 8;
Value |= Buffer[i];
}
SetValueIsSet();
}
return GetSize();
}
END_LIBEBML_NAMESPACE

View File

@ -1,57 +1,57 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 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.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlStream.h"
START_LIBEBML_NAMESPACE
EbmlStream::EbmlStream(IOCallback & DataStream)
:Stream(DataStream)
{}
EbmlStream::~EbmlStream()
{}
EbmlElement * EbmlStream::FindNextID(const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize)
{
return EbmlElement::FindNextID(Stream, ClassInfos, MaxDataSize);
}
EbmlElement * EbmlStream::FindNextElement(const EbmlSemanticContext & Context, int & UpperLevel, const uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel)
{
return EbmlElement::FindNextElement(Stream, Context, UpperLevel, MaxDataSize, AllowDummyElt, MaxLowerLevel);
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlStream.h"
START_LIBEBML_NAMESPACE
EbmlStream::EbmlStream(IOCallback & DataStream)
:Stream(DataStream)
{}
EbmlStream::~EbmlStream()
{}
EbmlElement * EbmlStream::FindNextID(const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize)
{
return EbmlElement::FindNextID(Stream, ClassInfos, MaxDataSize);
}
EbmlElement * EbmlStream::FindNextElement(const EbmlSemanticContext & Context, int & UpperLevel, const uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel)
{
return EbmlElement::FindNextElement(Stream, Context, UpperLevel, MaxDataSize, AllowDummyElt, MaxLowerLevel);
}
END_LIBEBML_NAMESPACE

View File

@ -1,149 +1,149 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlString.h"
START_LIBEBML_NAMESPACE
EbmlString::EbmlString()
:EbmlElement(0, false)
{
SetDefaultSize(0);
/* done automatically
SetSize_(Value.length());
if (GetDefaultSize() > GetSize())
SetSize_(GetDefaultSize());*/
}
EbmlString::EbmlString(const std::string & aDefaultValue)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultSize(0);
SetDefaultIsSet();
/* done automatically
SetSize_(Value.length());
if (GetDefaultSize() > GetSize())
SetSize_(GetDefaultSize());*/
}
/*!
\todo Cloning should be on the same exact type !
*/
EbmlString::EbmlString(const EbmlString & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result;
output.writeFully(Value.c_str(), Value.length());
Result = Value.length();
if (Result < GetDefaultSize()) {
// pad the rest with 0
binary *Pad = new binary[GetDefaultSize() - Result];
if (Pad == NULL)
{
return Result;
}
memset(Pad, 0x00, GetDefaultSize() - Result);
output.writeFully(Pad, GetDefaultSize() - Result);
Result = GetDefaultSize();
delete [] Pad;
}
return Result;
}
EbmlString & EbmlString::operator=(const std::string NewString)
{
Value = NewString;
SetValueIsSet();
/* done automatically
SetSize_(Value.length());
if (GetDefaultSize() > GetSize())
SetSize_(GetDefaultSize());*/
return *this;
}
uint64 EbmlString::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value.length() < GetDefaultSize()) {
SetSize_(GetDefaultSize());
} else {
SetSize_(Value.length());
}
return GetSize();
}
uint64 EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() == 0) {
Value = "";
SetValueIsSet();
} else {
char *Buffer = new char[GetSize() + 1];
if (Buffer == NULL) {
// unable to store the data, skip it
input.setFilePointer(GetSize(), seek_current);
} else {
input.readFully(Buffer, GetSize());
if (Buffer[GetSize()-1] != '\0') {
Buffer[GetSize()] = '\0';
}
Value = Buffer;
delete [] Buffer;
SetValueIsSet();
}
}
}
return GetSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlString.h"
START_LIBEBML_NAMESPACE
EbmlString::EbmlString()
:EbmlElement(0, false)
{
SetDefaultSize(0);
/* done automatically
SetSize_(Value.length());
if (GetDefaultSize() > GetSize())
SetSize_(GetDefaultSize());*/
}
EbmlString::EbmlString(const std::string & aDefaultValue)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultSize(0);
SetDefaultIsSet();
/* done automatically
SetSize_(Value.length());
if (GetDefaultSize() > GetSize())
SetSize_(GetDefaultSize());*/
}
/*!
\todo Cloning should be on the same exact type !
*/
EbmlString::EbmlString(const EbmlString & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result;
output.writeFully(Value.c_str(), Value.length());
Result = Value.length();
if (Result < GetDefaultSize()) {
// pad the rest with 0
binary *Pad = new binary[GetDefaultSize() - Result];
if (Pad == NULL)
{
return Result;
}
memset(Pad, 0x00, GetDefaultSize() - Result);
output.writeFully(Pad, GetDefaultSize() - Result);
Result = GetDefaultSize();
delete [] Pad;
}
return Result;
}
EbmlString & EbmlString::operator=(const std::string NewString)
{
Value = NewString;
SetValueIsSet();
/* done automatically
SetSize_(Value.length());
if (GetDefaultSize() > GetSize())
SetSize_(GetDefaultSize());*/
return *this;
}
uint64 EbmlString::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value.length() < GetDefaultSize()) {
SetSize_(GetDefaultSize());
} else {
SetSize_(Value.length());
}
return GetSize();
}
uint64 EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() == 0) {
Value = "";
SetValueIsSet();
} else {
char *Buffer = new char[GetSize() + 1];
if (Buffer == NULL) {
// unable to store the data, skip it
input.setFilePointer(GetSize(), seek_current);
} else {
input.readFully(Buffer, GetSize());
if (Buffer[GetSize()-1] != '\0') {
Buffer[GetSize()] = '\0';
}
Value = Buffer;
delete [] Buffer;
SetValueIsSet();
}
}
}
return GetSize();
}
END_LIBEBML_NAMESPACE

View File

@ -3,7 +3,7 @@
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**

View File

@ -1,130 +1,130 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include "ebml/EbmlUInteger.h"
START_LIBEBML_NAMESPACE
EbmlUInteger::EbmlUInteger()
:EbmlElement(DEFAULT_UINT_SIZE, false)
{}
EbmlUInteger::EbmlUInteger(uint64 aDefaultValue)
:EbmlElement(DEFAULT_UINT_SIZE, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultIsSet();
}
EbmlUInteger::EbmlUInteger(const EbmlUInteger & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
if (GetSizeLength() > 8)
return 0; // integer bigger coded on more than 64 bits are not supported
uint64 TempValue = Value;
for (unsigned int i=0; i<GetSize();i++) {
FinalData[GetSize()-i-1] = TempValue & 0xFF;
TempValue >>= 8;
}
output.writeFully(FinalData,GetSize());
return GetSize();
}
uint64 EbmlUInteger::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value <= 0xFF) {
SetSize_(1);
} else if (Value <= 0xFFFF) {
SetSize_(2);
} else if (Value <= 0xFFFFFF) {
SetSize_(3);
} else if (Value <= 0xFFFFFFFF) {
SetSize_(4);
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFF)) {
SetSize_(5);
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFF)) {
SetSize_(6);
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFF)) {
SetSize_(7);
} else {
SetSize_(8);
}
if (GetDefaultSize() > GetSize()) {
SetSize_(GetDefaultSize());
}
return GetSize();
}
uint64 EbmlUInteger::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[8];
input.readFully(Buffer, GetSize());
Value = 0;
for (unsigned int i=0; i<GetSize(); i++)
{
Value <<= 8;
Value |= Buffer[i];
}
SetValueIsSet();
}
return GetSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include "ebml/EbmlUInteger.h"
START_LIBEBML_NAMESPACE
EbmlUInteger::EbmlUInteger()
:EbmlElement(DEFAULT_UINT_SIZE, false)
{}
EbmlUInteger::EbmlUInteger(uint64 aDefaultValue)
:EbmlElement(DEFAULT_UINT_SIZE, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultIsSet();
}
EbmlUInteger::EbmlUInteger(const EbmlUInteger & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
if (GetSizeLength() > 8)
return 0; // integer bigger coded on more than 64 bits are not supported
uint64 TempValue = Value;
for (unsigned int i=0; i<GetSize();i++) {
FinalData[GetSize()-i-1] = TempValue & 0xFF;
TempValue >>= 8;
}
output.writeFully(FinalData,GetSize());
return GetSize();
}
uint64 EbmlUInteger::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value <= 0xFF) {
SetSize_(1);
} else if (Value <= 0xFFFF) {
SetSize_(2);
} else if (Value <= 0xFFFFFF) {
SetSize_(3);
} else if (Value <= 0xFFFFFFFF) {
SetSize_(4);
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFF)) {
SetSize_(5);
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFF)) {
SetSize_(6);
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFF)) {
SetSize_(7);
} else {
SetSize_(8);
}
if (GetDefaultSize() > GetSize()) {
SetSize_(GetDefaultSize());
}
return GetSize();
}
uint64 EbmlUInteger::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[8];
input.readFully(Buffer, GetSize());
Value = 0;
for (unsigned int i=0; i<GetSize(); i++)
{
Value <<= 8;
Value |= Buffer[i];
}
SetValueIsSet();
}
return GetSize();
}
END_LIBEBML_NAMESPACE

View File

@ -1,307 +1,307 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
*/
#include <cassert>
#if __GNUC__ == 2 && ! defined ( __OpenBSD__ )
#include <wchar.h>
#endif
#include "ebml/EbmlUnicodeString.h"
START_LIBEBML_NAMESPACE
// ===================== UTFstring class ===================
UTFstring::UTFstring()
:_Length(0)
,_Data(NULL)
{}
UTFstring::UTFstring(const wchar_t * _aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf;
}
UTFstring::~UTFstring()
{
delete [] _Data;
}
UTFstring::UTFstring(const UTFstring & _aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf.c_str();
}
UTFstring & UTFstring::operator=(const UTFstring & _aBuf)
{
*this = _aBuf.c_str();
return *this;
}
UTFstring & UTFstring::operator=(const wchar_t * _aBuf)
{
delete [] _Data;
if (_aBuf == NULL) {
_Data = new wchar_t[1];
_Data[0] = 0;
UpdateFromUCS2();
return *this;
}
size_t aLen;
for (aLen=0; _aBuf[aLen] != 0; aLen++);
_Length = aLen;
_Data = new wchar_t[_Length+1];
for (aLen=0; _aBuf[aLen] != 0; aLen++) {
_Data[aLen] = _aBuf[aLen];
}
_Data[aLen] = 0;
UpdateFromUCS2();
return *this;
}
UTFstring & UTFstring::operator=(wchar_t _aChar)
{
delete [] _Data;
_Data = new wchar_t[2];
_Length = 1;
_Data[0] = _aChar;
_Data[1] = 0;
UpdateFromUCS2();
return *this;
}
bool UTFstring::operator==(const UTFstring& _aStr) const
{
if ((_Data == NULL) && (_aStr._Data == NULL))
return true;
if ((_Data == NULL) || (_aStr._Data == NULL))
return false;
return wcscmp_internal(_Data, _aStr._Data);
}
void UTFstring::SetUTF8(const std::string & _aStr)
{
UTF8string = _aStr;
UpdateFromUTF8();
}
/*!
\see RFC 2279
*/
void UTFstring::UpdateFromUTF8()
{
delete [] _Data;
// find the size of the final UCS-2 string
size_t i;
for (_Length=0, i=0; i<UTF8string.length(); _Length++) {
if ((UTF8string[i] & 0x80) == 0) {
i++;
} else if ((UTF8string[i] & 0x20) == 0) {
i += 2;
} else if ((UTF8string[i] & 0x10) == 0) {
i += 3;
}
}
_Data = new wchar_t[_Length+1];
size_t j;
for (j=0, i=0; i<UTF8string.length(); j++) {
if ((UTF8string[i] & 0x80) == 0) {
_Data[j] = UTF8string[i];
i++;
} else if ((UTF8string[i] & 0x20) == 0) {
_Data[j] = ((UTF8string[i] & 0x1F) << 6) + (UTF8string[i+1] & 0x3F);
i += 2;
} else if ((UTF8string[i] & 0x10) == 0) {
_Data[j] = ((UTF8string[i] & 0x0F) << 12) + ((UTF8string[i+1] & 0x3F) << 6) + (UTF8string[i+2] & 0x3F);
i += 3;
}
}
_Data[j] = 0;
}
void UTFstring::UpdateFromUCS2()
{
// find the size of the final UTF-8 string
size_t i,Size=0;
for (i=0; i<_Length; i++)
{
if (_Data[i] < 0x80) {
Size++;
} else if (_Data[i] < 0x800) {
Size += 2;
} else if (_Data[i] < 0x10000) {
Size += 3;
}
}
std::string::value_type *tmpStr = new std::string::value_type[Size+1];
for (i=0, Size=0; i<_Length; i++)
{
if (_Data[i] < 0x80) {
tmpStr[Size++] = _Data[i];
} else if (_Data[i] < 0x800) {
tmpStr[Size++] = 0xC0 | (_Data[i] >> 6);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
} else if (_Data[i] < 0x10000) {
tmpStr[Size++] = 0xE0 | (_Data[i] >> 12);
tmpStr[Size++] = 0x80 | ((_Data[i] >> 6) & 0x3F);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
}
}
tmpStr[Size] = 0;
UTF8string = tmpStr; // implicit conversion
delete [] tmpStr;
}
bool UTFstring::wcscmp_internal(const wchar_t *str1, const wchar_t *str2)
{
size_t Index=0;
while (str1[Index] == str2[Index] && str1[Index] != 0) {
Index++;
}
return (str1[Index] == str2[Index]);
}
// ===================== EbmlUnicodeString class ===================
EbmlUnicodeString::EbmlUnicodeString()
:EbmlElement(0, false)
{
SetDefaultSize(0);
}
EbmlUnicodeString::EbmlUnicodeString(const UTFstring & aDefaultValue)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultSize(0);
SetDefaultIsSet();
}
EbmlUnicodeString::EbmlUnicodeString(const EbmlUnicodeString & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\note limited to UCS-2
\todo handle exception on errors
*/
uint32 EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result = Value.GetUTF8().length();
if (Result != 0) {
output.writeFully(Value.GetUTF8().c_str(), Result);
}
if (Result < GetDefaultSize()) {
// pad the rest with 0
binary *Pad = new binary[GetDefaultSize() - Result];
if (Pad != NULL) {
memset(Pad, 0x00, GetDefaultSize() - Result);
output.writeFully(Pad, GetDefaultSize() - Result);
Result = GetDefaultSize();
delete [] Pad;
}
}
return Result;
}
EbmlUnicodeString & EbmlUnicodeString::operator=(const UTFstring & NewString)
{
Value = NewString;
SetValueIsSet();
return *this;
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
SetSize_(Value.GetUTF8().length());
if (GetSize() < GetDefaultSize())
SetSize_(GetDefaultSize());
return GetSize();
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() == 0) {
Value = UTFstring::value_type(0);
SetValueIsSet();
} else {
char *Buffer = new char[GetSize()+1];
if (Buffer == NULL) {
// impossible to read, skip it
input.setFilePointer(GetSize(), seek_current);
} else {
input.readFully(Buffer, GetSize());
if (Buffer[GetSize()-1] != 0) {
Buffer[GetSize()] = 0;
}
Value.SetUTF8(Buffer); // implicit conversion to std::string
delete [] Buffer;
SetValueIsSet();
}
}
}
return GetSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
*/
#include <cassert>
#if __GNUC__ == 2 && ! defined ( __OpenBSD__ )
#include <wchar.h>
#endif
#include "ebml/EbmlUnicodeString.h"
START_LIBEBML_NAMESPACE
// ===================== UTFstring class ===================
UTFstring::UTFstring()
:_Length(0)
,_Data(NULL)
{}
UTFstring::UTFstring(const wchar_t * _aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf;
}
UTFstring::~UTFstring()
{
delete [] _Data;
}
UTFstring::UTFstring(const UTFstring & _aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf.c_str();
}
UTFstring & UTFstring::operator=(const UTFstring & _aBuf)
{
*this = _aBuf.c_str();
return *this;
}
UTFstring & UTFstring::operator=(const wchar_t * _aBuf)
{
delete [] _Data;
if (_aBuf == NULL) {
_Data = new wchar_t[1];
_Data[0] = 0;
UpdateFromUCS2();
return *this;
}
size_t aLen;
for (aLen=0; _aBuf[aLen] != 0; aLen++);
_Length = aLen;
_Data = new wchar_t[_Length+1];
for (aLen=0; _aBuf[aLen] != 0; aLen++) {
_Data[aLen] = _aBuf[aLen];
}
_Data[aLen] = 0;
UpdateFromUCS2();
return *this;
}
UTFstring & UTFstring::operator=(wchar_t _aChar)
{
delete [] _Data;
_Data = new wchar_t[2];
_Length = 1;
_Data[0] = _aChar;
_Data[1] = 0;
UpdateFromUCS2();
return *this;
}
bool UTFstring::operator==(const UTFstring& _aStr) const
{
if ((_Data == NULL) && (_aStr._Data == NULL))
return true;
if ((_Data == NULL) || (_aStr._Data == NULL))
return false;
return wcscmp_internal(_Data, _aStr._Data);
}
void UTFstring::SetUTF8(const std::string & _aStr)
{
UTF8string = _aStr;
UpdateFromUTF8();
}
/*!
\see RFC 2279
*/
void UTFstring::UpdateFromUTF8()
{
delete [] _Data;
// find the size of the final UCS-2 string
size_t i;
for (_Length=0, i=0; i<UTF8string.length(); _Length++) {
if ((UTF8string[i] & 0x80) == 0) {
i++;
} else if ((UTF8string[i] & 0x20) == 0) {
i += 2;
} else if ((UTF8string[i] & 0x10) == 0) {
i += 3;
}
}
_Data = new wchar_t[_Length+1];
size_t j;
for (j=0, i=0; i<UTF8string.length(); j++) {
if ((UTF8string[i] & 0x80) == 0) {
_Data[j] = UTF8string[i];
i++;
} else if ((UTF8string[i] & 0x20) == 0) {
_Data[j] = ((UTF8string[i] & 0x1F) << 6) + (UTF8string[i+1] & 0x3F);
i += 2;
} else if ((UTF8string[i] & 0x10) == 0) {
_Data[j] = ((UTF8string[i] & 0x0F) << 12) + ((UTF8string[i+1] & 0x3F) << 6) + (UTF8string[i+2] & 0x3F);
i += 3;
}
}
_Data[j] = 0;
}
void UTFstring::UpdateFromUCS2()
{
// find the size of the final UTF-8 string
size_t i,Size=0;
for (i=0; i<_Length; i++)
{
if (_Data[i] < 0x80) {
Size++;
} else if (_Data[i] < 0x800) {
Size += 2;
} else if (_Data[i] < 0x10000) {
Size += 3;
}
}
std::string::value_type *tmpStr = new std::string::value_type[Size+1];
for (i=0, Size=0; i<_Length; i++)
{
if (_Data[i] < 0x80) {
tmpStr[Size++] = _Data[i];
} else if (_Data[i] < 0x800) {
tmpStr[Size++] = 0xC0 | (_Data[i] >> 6);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
} else if (_Data[i] < 0x10000) {
tmpStr[Size++] = 0xE0 | (_Data[i] >> 12);
tmpStr[Size++] = 0x80 | ((_Data[i] >> 6) & 0x3F);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
}
}
tmpStr[Size] = 0;
UTF8string = tmpStr; // implicit conversion
delete [] tmpStr;
}
bool UTFstring::wcscmp_internal(const wchar_t *str1, const wchar_t *str2)
{
size_t Index=0;
while (str1[Index] == str2[Index] && str1[Index] != 0) {
Index++;
}
return (str1[Index] == str2[Index]);
}
// ===================== EbmlUnicodeString class ===================
EbmlUnicodeString::EbmlUnicodeString()
:EbmlElement(0, false)
{
SetDefaultSize(0);
}
EbmlUnicodeString::EbmlUnicodeString(const UTFstring & aDefaultValue)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
SetDefaultSize(0);
SetDefaultIsSet();
}
EbmlUnicodeString::EbmlUnicodeString(const EbmlUnicodeString & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\note limited to UCS-2
\todo handle exception on errors
*/
uint32 EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result = Value.GetUTF8().length();
if (Result != 0) {
output.writeFully(Value.GetUTF8().c_str(), Result);
}
if (Result < GetDefaultSize()) {
// pad the rest with 0
binary *Pad = new binary[GetDefaultSize() - Result];
if (Pad != NULL) {
memset(Pad, 0x00, GetDefaultSize() - Result);
output.writeFully(Pad, GetDefaultSize() - Result);
Result = GetDefaultSize();
delete [] Pad;
}
}
return Result;
}
EbmlUnicodeString & EbmlUnicodeString::operator=(const UTFstring & NewString)
{
Value = NewString;
SetValueIsSet();
return *this;
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
SetSize_(Value.GetUTF8().length());
if (GetSize() < GetDefaultSize())
SetSize_(GetDefaultSize());
return GetSize();
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() == 0) {
Value = UTFstring::value_type(0);
SetValueIsSet();
} else {
char *Buffer = new char[GetSize()+1];
if (Buffer == NULL) {
// impossible to read, skip it
input.setFilePointer(GetSize(), seek_current);
} else {
input.readFully(Buffer, GetSize());
if (Buffer[GetSize()-1] != 0) {
Buffer[GetSize()] = 0;
}
Value.SetUTF8(Buffer); // implicit conversion to std::string
delete [] Buffer;
SetValueIsSet();
}
}
}
return GetSize();
}
END_LIBEBML_NAMESPACE

View File

@ -1,41 +1,41 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 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: EbmlVersion.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlVersion.h"
START_LIBEBML_NAMESPACE
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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: EbmlVersion.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlVersion.h"
START_LIBEBML_NAMESPACE
END_LIBEBML_NAMESPACE

View File

@ -1,139 +1,139 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 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: EbmlVoid.cpp 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlVoid.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
EbmlId EbmlVoid_TheId(0xEC, 1);
const EbmlCallbacks EbmlVoid::ClassInfos(EbmlVoid::Create, EbmlVoid_TheId, "EBMLVoid", EbmlVoid_Context);
EbmlVoid::EbmlVoid()
{
SetValueIsSet();
}
uint32 EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
// write dummy data by 4KB chunks
static binary DummyBuf[4*1024];
uint64 SizeToWrite = GetSize();
while (SizeToWrite > 4*1024)
{
output.writeFully(DummyBuf, 4*1024);
SizeToWrite -= 4*1024;
}
output.writeFully(DummyBuf, SizeToWrite);
return GetSize();
}
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
{
EltToReplaceWith.UpdateSize(bKeepIntact);
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here !
return 0;
}
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
// there is not enough space to put a filling element
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bKeepIntact);
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
// fill the rest with another void element
EbmlVoid aTmp;
aTmp.SetSize_(HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
int HeadBefore = aTmp.HeadSize();
aTmp.SetSize_(aTmp.GetSize() - CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()));
int HeadAfter = aTmp.HeadSize();
if (HeadBefore != HeadAfter) {
aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
}
aTmp.RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return GetSize() + HeadSize();
}
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
{
// EltToVoid.UpdateSize(bKeepIntact);
if (EltToVoid.GetElementPosition() == 0) {
// this element has never been written
return 0;
}
if (EltToVoid.GetSize() + EltToVoid.HeadSize() <2) {
// the element can't be written here !
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(EltToVoid.GetElementPosition());
// compute the size of the voided data based on the original one
SetSize(EltToVoid.GetSize() + EltToVoid.HeadSize() - 1); // 1 for the ID
SetSize(GetSize() - CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()));
// make sure we handle even the strange cases
//uint32 A1 = GetSize() + HeadSize();
//uint32 A2 = EltToVoid.GetSize() + EltToVoid.HeadSize();
if (GetSize() + HeadSize() != EltToVoid.GetSize() + EltToVoid.HeadSize()) {
SetSize(GetSize()-1);
SetSizeLength(CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()) + 1);
}
if (GetSize() != 0) {
RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return EltToVoid.GetSize() + EltToVoid.HeadSize();
}
END_LIBEBML_NAMESPACE
/****************************************************************************
** 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: EbmlVoid.cpp 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlVoid.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
EbmlId EbmlVoid_TheId(0xEC, 1);
const EbmlCallbacks EbmlVoid::ClassInfos(EbmlVoid::Create, EbmlVoid_TheId, "EBMLVoid", EbmlVoid_Context);
EbmlVoid::EbmlVoid()
{
SetValueIsSet();
}
uint32 EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
// write dummy data by 4KB chunks
static binary DummyBuf[4*1024];
uint64 SizeToWrite = GetSize();
while (SizeToWrite > 4*1024)
{
output.writeFully(DummyBuf, 4*1024);
SizeToWrite -= 4*1024;
}
output.writeFully(DummyBuf, SizeToWrite);
return GetSize();
}
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
{
EltToReplaceWith.UpdateSize(bKeepIntact);
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here !
return 0;
}
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
// there is not enough space to put a filling element
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bKeepIntact);
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
// fill the rest with another void element
EbmlVoid aTmp;
aTmp.SetSize_(HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
int HeadBefore = aTmp.HeadSize();
aTmp.SetSize_(aTmp.GetSize() - CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()));
int HeadAfter = aTmp.HeadSize();
if (HeadBefore != HeadAfter) {
aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
}
aTmp.RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return GetSize() + HeadSize();
}
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
{
// EltToVoid.UpdateSize(bKeepIntact);
if (EltToVoid.GetElementPosition() == 0) {
// this element has never been written
return 0;
}
if (EltToVoid.GetSize() + EltToVoid.HeadSize() <2) {
// the element can't be written here !
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(EltToVoid.GetElementPosition());
// compute the size of the voided data based on the original one
SetSize(EltToVoid.GetSize() + EltToVoid.HeadSize() - 1); // 1 for the ID
SetSize(GetSize() - CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()));
// make sure we handle even the strange cases
//uint32 A1 = GetSize() + HeadSize();
//uint32 A2 = EltToVoid.GetSize() + EltToVoid.HeadSize();
if (GetSize() + HeadSize() != EltToVoid.GetSize() + EltToVoid.HeadSize()) {
SetSize(GetSize()-1);
SetSizeLength(CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()) + 1);
}
if (GetSize() != 0) {
RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return EltToVoid.GetSize() + EltToVoid.HeadSize();
}
END_LIBEBML_NAMESPACE