20 Commits

Author SHA1 Message Date
Moritz Bunkus
cd33ce4fe6 Remove debian build files 2013-03-19 19:42:58 +01:00
Moritz Bunkus
f8d29fb6bd Update ChangeLog and Debian changelog 2013-03-19 18:34:18 +01:00
Moritz Bunkus
f13ccea959 Update ChangeLog 2013-03-19 18:24:07 +01:00
Moritz Bunkus
5a4d4c3c8c Ignore files built during compilation 2013-03-19 12:08:22 +01:00
Moritz Bunkus
8e41fbbfce Fix wrong date calculation introduced in r841
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@871 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-12-13 10:34:27 +00:00
Moritz Bunkus
bf398fcd94 More version number bumping/setting; add ChangeLog message
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@850 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-22 22:31:39 +00:00
Moritz Bunkus
7dd909bef7 Add std::wstring constructor for UTFstring
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@844 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-05 20:21:59 +00:00
Moritz Bunkus
5805445834 Provide direct access to an EbmlMaster's vector storage
This facilitates using algorithms from the stdlib and other C++
libraries like Boost.

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@842 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-04 07:37:29 +00:00
Moritz Bunkus
0312461091 Provide Get-/SetValue()/Get-/SetValueUTF8() for Ebml(Unicode)String; make Date values use 64bit ints
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@841 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-04 07:37:12 +00:00
Moritz Bunkus
b95a4104aa Provide GetValue() and SetValue() functions for EbmlFloat/SInteger/UInteger
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@840 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-04 07:36:48 +00:00
Moritz Bunkus
c2ab2859ac Make int conversion operators const
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@839 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-04 07:36:24 +00:00
Moritz Bunkus
d5f30db3c6 Bump version number to 1.3.0
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@838 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2012-09-04 07:36:04 +00:00
Moritz Bunkus
edb58336a9 Add -Wextra to warning flags
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@824 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-11-25 21:26:16 +00:00
Moritz Bunkus
88cdc30938 Fix several gcc warnings occurring with -Wextra
Warnings fixed are:

- warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
- warning: unused parameter ... [-Wunused-parameter]
- warning: comparison is always true due to limited range of data type [-Wtype-limits]



git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@822 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-11-25 21:01:45 +00:00
Steve Lhomme
ffeea955a0 libebml: fix some compilation warnings in mingw
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@821 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-10-18 16:55:49 +00:00
Moritz Bunkus
f9489f1f80 changelog update, version number updates
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@811 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-09-23 11:26:59 +00:00
Moritz Bunkus
9a31b3864c Move definition of EbmlCodeVersion into the library
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@803 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-09-11 09:03:43 +00:00
Steve Lhomme
2490c80ad1 libebml: fix the Debug class use
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@796 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-09-09 04:00:42 +00:00
Steve Lhomme
5eea000814 libebml: also update the coremake project
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@789 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-07-15 13:40:26 +00:00
Steve Lhomme
527f98c367 libebml: only use the test element to read once in the loop
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@788 a6f86f6d-0131-4f8e-9e7b-e335508773d5
2011-07-15 13:31:03 +00:00
39 changed files with 344 additions and 574 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.[ao]

View File

@@ -1,3 +1,22 @@
2013-03-19 mosu
New 1.3.0 version:
* Note that this version is not binary compatible to its predecessors.
- Compilation warning fixes
- GetValue() and SetValue() functions for EbmlFloat/EbmlSInteger/EbmlUInteger
- GetValue(), SetValue(), GetValueUTF8(), SetValueUTF8() functions for EbmlString/EbmlUnicodeString
- Date values use 64bit integers
- Integer conversion operators were made 'const'
- GetElementList() function for EbmlMaster providing a reference to the underlying std::vector<> for better interaction with the C++ standard library
- New constructor for UTFstring taking a single std::wstring
- Increased library .so name to .4 due to binary incompatible changes.
- Removed the Debian build files from our package.
2011-09-23 robux4/mosu
New 1.2.2 version:
- fix usage of the DEBUG #define (use LIBEBML_DEBUG instead)
- The EbmlCodeVersion variable now resides in the library instead of being declared static in the header file.
- only use the test element to read once in the loop
2011-06-26 robux4/mosu
New 1.2.1 version:
- fix the constructor of CRTError in StdIOCallback (patch from Graham 'gbooker' Booker)
@@ -1585,4 +1604,3 @@ New 0.8.0 version:
trunk/libebml/src/platform/win32/WinIOCallback.cpp,
trunk/libebml/src/platform/win32/WinIOCallback.h: Initial CVS
version after the crash

180
debian/changelog vendored
View File

@@ -1,180 +0,0 @@
libebml (1.2.1-1) natty; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 15 Jun 2011 13:55:50 +0200
libebml (1.2.0-1) lucid; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 30 Jan 2011 15:30:00 +0200
libebml (1.0.0-1) lucid; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 05 Jun 2010 10:39:00 +0200
libebml (0.8.0-1) karmic; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 09 May 2010 16:56:41 +0200
libebml (0.7.8-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 5 Mar 2008 12:04:07 +0100
libebml (0.7.7-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 31 Mar 2006 14:28:30 +0200
libebml (0.7.6-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 18 Oct 2005 19:54:16 +0200
libebml (0.7.5-2) unstable; urgency=low
* Rebuilt with g++ 4.0.2.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 15 Oct 2005 14:20:24 +0200
libebml (0.7.5-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 20 May 2005 16:27:42 +0200
libebml (0.7.4-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 16 Apr 2005 13:05:06 +0200
libebml (0.7.3-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 10 Nov 2004 21:47:35 +0100
libebml (0.7.2-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 26 Sep 2004 12:16:57 +0200
libebml (0.7.1-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 25 Jul 2004 12:15:48 +0200
libebml (0.7.0-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 23 Apr 2004 18:38:00 +0200
libebml (0.6.5-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 9 Mar 2004 21:32:18 +0100
libebml (0.6.4-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 19 Jan 2004 11:28:42 +0100
libebml (0.6.3-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Thu, 25 Dec 2003 13:27:27 +0100
libebml (0.6.2-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 31 Oct 2003 09:34:13 +0100
libebml (0.6.1-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 28 Oct 2003 22:45:25 +0100
libebml (0.6.0-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 17 Sep 2003 22:28:18 +0200
libebml (0.5.1-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 1 Sep 2003 13:27:54 +0200
libebml (0.5.0-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 28 Jul 2003 10:48:35 +0200
libebml (0.4.4-2) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 14 Jun 2003 17:41:43 +0200
libebml (0.4.4-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 11 Jun 2003 20:27:01 +0200
libebml (0.4.3-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 21 May 2003 22:34:46 +0200
libebml (0.4.2-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 6 May 2003 22:21:09 +0200
libebml (0.4.0-2) unstable; urgency=low
* Compiled with gcc 3.2.3.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 04 May 2003 22:14:26 +0200
libebml (0.4.0-1) unstable; urgency=low
* First official alpha release.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 30 Apr 2003 10:27:26 +0200
libebml (0.2.0.20030424-1) unstable; urgency=low
* New version with bugfixes from Steve.
-- Moritz Bunkus <moritz@bunkus.org> Thu, 24 Apr 2003 19:57:48 +0200
libebml (0.2.0.20030421-1) unstable; urgency=low
* Initial Release.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 21 Apr 2003 12:49:33 +0200

15
debian/control vendored
View File

@@ -1,15 +0,0 @@
Source: libebml
Priority: optional
Maintainer: Moritz Bunkus <moritz@bunkus.org>
Build-Depends: debhelper (>> 3.0.0)
Standards-Version: 3.5.8
Section: libs
Package: libebml-dev
Section: libdevel
Architecture: any
Depends: ${shlibs:Depends}
Description: Extensible Binary Meta Language access library
A library for reading and writing files with the Extensible Binary
Meta Language, a binary pendant to XML.

27
debian/copyright vendored
View File

@@ -1,27 +0,0 @@
This package was debianized by Moritz Bunkus <moritz@bunkus.org> on
Mon, 21 Apr 2003 12:49:33 +0200.
It was downloaded from http://www.matroska.org/
Upstream Author: Steve Lhomme <steve.lhomme@free.fr>
Copyright (C) 2002-2003 Steve Lhomme. All rights reserved.
This file may be distributed under the terms of the Q Public License
as defined by Trolltech AS of Norway and appearing in the file
LICENSE.QPL included in the packaging of this file.
This proram is also licensed under the GPL. See
/usr/share/common-licenses/GPL for details.
Licensees holding an other license may use this file in accordance with
the Agreement provided with the Software.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
See http://www.matroska.org/license/qpl/ for QPL licensing information.
Contact license@matroska.org if any conditions of this licensing are
not clear to you.

2
debian/dirs vendored
View File

@@ -1,2 +0,0 @@
usr/bin
usr/sbin

0
debian/docs vendored
View File

View File

@@ -1,2 +0,0 @@
usr/lib
usr/include

View File

@@ -1,2 +0,0 @@
usr/include/*
usr/lib/lib*.a

96
debian/rules vendored
View File

@@ -1,96 +0,0 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This is the debhelper compatibility version to use.
export DH_COMPAT=4
# shared library versions, option 1
version=2.0.5
major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
#version=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
configure: configure-stamp
configure-stamp:
dh_testdir
# Add here commands to configure the package.
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
$(MAKE) $(DEB_BUILD_OPTIONS) -C make/linux staticlib
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
-$(MAKE) $(DEB_BUILD_OPTIONS) -C make/linux clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/tmp
$(MAKE) $(DEB_BUILD_OPTIONS) \
-C make/linux prefix=$(CURDIR)/debian/tmp/usr \
install_staticlib install_headers
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_movefiles
# dh_installdebconf
dh_installdocs
# dh_installexamples
# dh_installmenu
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installman
# dh_installinfo
# dh_undocumented
dh_installchangelogs ChangeLog
dh_link
# dh_strip
dh_compress
dh_fixperms
dh_makeshlibs
dh_installdeb
# dh_perl
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

View File

@@ -52,7 +52,7 @@ START_LIBEBML_NAMESPACE
static const int MAX_PREFIX_LENGTH = 128;
#if defined(DEBUG)
#if defined(LIBEBML_DEBUG)
// define the working debugging class
class EBML_DLL_API ADbg
@@ -102,21 +102,21 @@ private:
#endif // WIN32
};
#else // defined(DEBUG)
#else // defined(LIBEBML_DEBUG)
// define a class that does nothing (no output)
class EBML_DLL_API ADbg
{
public:
ADbg(int level = 0){}
ADbg(int /* level */ = 0){}
virtual ~ADbg() {}
inline int OutPut(int level, const char * format,...) const {
inline int OutPut(int /* level */, const char * /* format */,...) const {
return 0;
}
inline int OutPut(const char * format,...) const {
inline int OutPut(const char * /* format */,...) const {
return 0;
}
@@ -124,11 +124,11 @@ public:
return level;
}
inline bool setIncludeTime(const bool included = true) {
inline bool setIncludeTime(const bool /* included */ = true) {
return true;
}
inline bool setDebugFile(const char * NewFilename) {
inline bool setDebugFile(const char * /* NewFilename */) {
return true;
}
@@ -136,7 +136,7 @@ public:
return true;
}
inline bool setUseFile(const bool usefile = true) {
inline bool setUseFile(const bool /* usefile */ = true) {
return true;
}
@@ -145,7 +145,7 @@ public:
}
};
#endif // defined(DEBUG)
#endif // defined(LIBEBML_DEBUG)
extern class EBML_DLL_API ADbg globalDebug;

View File

@@ -96,7 +96,7 @@
// The LIBEBML_DEBUG symbol is defined, when we are creating a debug build. In this
// case the debug logging code is compiled in.
#if (defined(DEBUG)||defined(_DEBUG))&&!defined(LIBEBML_DEBUG)
#if (defined(DEBUG)||defined(_DEBUG)) && !defined(LIBEBML_DEBUG)
#define LIBEBML_DEBUG
#endif
@@ -111,7 +111,7 @@
#define EBML_PRETTYLONGINT(c) (c)
#endif // __GNUC__
#if __BORLANDC__ >= 0x0581 //Borland C++ Builder 2006 preview
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x0581 //Borland C++ Builder 2006 preview
#include <stdlib.h> //malloc(), free()
#include <memory.h> //memcpy()
#endif //__BORLANDC__

View File

@@ -101,9 +101,9 @@ DECLARE_EBML_BINARY(EbmlCrc32)
};
template <class T>
inline unsigned int GetAlignment(T *dummy=NULL) // VC60 workaround
inline unsigned int GetAlignment(T */* dummy */=NULL) // VC60 workaround
{
#if (_MSC_VER >= 1300)
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
return __alignof(T);
#elif defined(__GNUC__)
return __alignof__(T);
@@ -131,7 +131,7 @@ inline bool IsAlignedOn(const void *p, unsigned int alignment)
}
template <class T>
inline bool IsAligned(const void *p, T *dummy=NULL) // VC60 workaround
inline bool IsAligned(const void *p, T */* dummy */=NULL) // VC60 workaround
{
return IsAlignedOn(p, GetAlignment<T>());
}

View File

@@ -52,20 +52,22 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
\brief set the date with a UNIX/C/EPOCH form
\param NewDate UNIX/C date in UTC (no timezone)
*/
void SetEpochDate(int32 NewDate) {myDate = int64(NewDate - UnixEpochDelay) * 1000000000; SetValueIsSet();}
void SetEpochDate(int64 NewDate) {myDate = (NewDate - UnixEpochDelay) * 1000000000; SetValueIsSet();}
EbmlDate &SetValue(int64 NewValue) {SetEpochDate(NewValue); return *this;}
/*!
\brief get the date with a UNIX/C/EPOCH form
\note the date is in UTC (no timezone)
*/
int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
int64 GetEpochDate() const {return int64(myDate/1000000000 + UnixEpochDelay);}
int64 GetValue() const {return GetEpochDate();}
virtual bool ValidateSize() const {return IsFiniteSize() && ((GetSize() == 8) || (GetSize() == 0));}
/*!
\note no Default date handled
*/
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) {
filepos_t UpdateSize(bool /* bWithDefault = false */, bool /* bForceRender = false */) {
if(!ValueIsSet())
SetSize_(0);
else

View File

@@ -79,12 +79,15 @@ class EBML_DLL_API EbmlFloat : public EbmlElement {
virtual bool IsSmallerThan(const EbmlElement *Cmp) const;
operator const float() const;
operator const double() const;
operator float() const;
operator double() const;
EbmlFloat &SetValue(double NewValue);
double GetValue() const;
void SetDefaultValue(double);
const double DefaultVal() const;
double DefaultVal() const;
bool IsDefaultValue() const {
return (DefaultISset() && Value == DefaultValue);

View File

@@ -41,7 +41,7 @@
START_LIBEBML_NAMESPACE
DECLARE_EBML_MASTER(EbmlHead)
DECLARE_EBML_MASTER(EbmlHead)
public:
EbmlHead(const EbmlHead & ElementToClone) : EbmlMaster(ElementToClone) {}

View File

@@ -121,6 +121,8 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
void Sort();
size_t ListSize() const {return ElementList.size();}
std::vector<EbmlElement *> const &GetElementList() const {return ElementList;}
std::vector<EbmlElement *> &GetElementList() {return ElementList;}
inline EBML_MASTER_ITERATOR begin() {return ElementList.begin();}
inline EBML_MASTER_ITERATOR end() {return ElementList.end();}

View File

@@ -71,10 +71,13 @@ class EBML_DLL_API EbmlSInteger : public EbmlElement {
virtual bool IsSmallerThan(const EbmlElement *Cmp) const;
operator int8();
operator int16();
operator int32();
operator int64();
operator int8() const;
operator int16() const;
operator int32() const;
operator int64() const;
EbmlSInteger &SetValue(int64 NewValue);
int64 GetValue() const;
void SetDefaultValue(int64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}

View File

@@ -63,6 +63,9 @@ class EBML_DLL_API EbmlString : public EbmlElement {
EbmlString & operator=(const std::string &);
operator const std::string &() const;
EbmlString &SetValue(std::string const &NewValue);
std::string GetValue() const;
void SetDefaultValue(std::string &);
const std::string & DefaultVal() const;

View File

@@ -74,6 +74,9 @@ class EBML_DLL_API EbmlUInteger : public EbmlElement {
operator uint32() const;
operator uint64() const;
EbmlUInteger &SetValue(uint64 NewValue);
uint64 GetValue() const;
void SetDefaultValue(uint64);
uint64 DefaultVal() const;

View File

@@ -57,6 +57,7 @@ public:
UTFstring();
UTFstring(const wchar_t *); // should be NULL terminated
UTFstring(const UTFstring &);
UTFstring(std::wstring const &);
virtual ~UTFstring();
bool operator==(const UTFstring&) const;
@@ -112,6 +113,11 @@ class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
operator const UTFstring &() const;
EbmlUnicodeString &SetValue(UTFstring const &NewValue);
EbmlUnicodeString &SetValueUTF8(std::string const &NewValue);
UTFstring GetValue() const;
std::string GetValueUTF8() const;
void SetDefaultValue(UTFstring &);
const UTFstring & DefaultVal() const;

View File

@@ -42,10 +42,10 @@
START_LIBEBML_NAMESPACE
#define LIBEBML_VERSION 0x010201
#define LIBEBML_VERSION 0x010300
static const std::string EbmlCodeVersion = "1.2.1";
static const std::string EbmlCodeDate = __TIMESTAMP__;
extern const std::string EbmlCodeVersion;
extern const std::string EbmlCodeDate;
/*!
\todo Closer relation between an element and the context it comes from (context is an element attribute ?)

View File

@@ -2,7 +2,7 @@
LIB ebml
{
PROJECT_VERSION 1.2.1
PROJECT_VERSION 1.2.3
INCLUDE .
EXPINCLUDE .
@@ -14,7 +14,7 @@ LIB ebml
REDUCE_SIZE .
FASTER_FLOAT .
// SOURCE src/Debug.cpp
SOURCE src/Debug.cpp
SOURCE src/EbmlBinary.cpp
SOURCE src/EbmlContexts.cpp
SOURCE src/EbmlCrc32.cpp
@@ -38,7 +38,7 @@ LIB ebml
SOURCE(TARGET_WIN) src/platform/win32/WinIOCallback.cpp
HEADER(TARGET_WIN) src/platform/win32/WinIOCallback.h
// HEADER ebml/Debug.h
HEADER ebml/Debug.h
HEADER ebml/EbmlBinary.h
HEADER ebml/EbmlConfig.h
HEADER ebml/EbmlContexts.h

View File

@@ -49,7 +49,7 @@ LIBS=
# Names
LIBRARY=libebml.a
LIBRARY_SO=libebml.so
LIBRARY_SO_VER=libebml.so.3
LIBRARY_SO_VER=libebml.so.4
# source-files
sources:=$(wildcard ${SRC_DIR}*$(EXTENSION))
@@ -61,7 +61,7 @@ headers:=$(patsubst %$(EXTENSION),%.h,$(sources))
objects:=$(patsubst %$(EXTENSION),%.o,$(sources))
objects_so:=$(patsubst %$(EXTENSION),%.lo,$(sources))
WARNINGFLAGS=-Wall -Wno-unknown-pragmas -ansi -fno-gnu-keywords -Wshadow
WARNINGFLAGS=-Wall -Wextra -Wno-unknown-pragmas -ansi -fno-gnu-keywords -Wshadow
COMPILEFLAGS=$(WARNINGFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DEBUGFLAGS) $(INCLUDE)
DEPENDFLAGS = $(CXXFLAGS) $(INCLUDE)

View File

@@ -1,7 +1,7 @@
# SPEC file for libebml on (at least) Fedora Core 1, 2, 3
Name: libebml
Version: 1.2.1
Version: 1.3.0
Release: 1
License: LGPL
Summary: Extensible Binary Meta Language

View File

@@ -14,7 +14,7 @@ BuildRequires: bzip2 cpp make tar zlib zlib-devel binutils gcc gcc-c++ libstdc++
Name: libebml
URL: http://sourceforge.net/projects/ebml
Version: 1.2.1
Version: 1.3.0
Release: 1
Summary: libary to parse EBML files.
License: LGPL

View File

@@ -49,7 +49,7 @@ START_LIBEBML_NAMESPACE
class ADbg globalDebug;
#if defined(DEBUG)
#if defined(LIBEBML_DEBUG)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -232,6 +232,6 @@ bool ADbg::unsetDebugFile() {
return result;
}
#endif // defined(DEBUG)
#endif // defined(LIBEBML_DEBUG)
END_LIBEBML_NAMESPACE

View File

@@ -66,7 +66,7 @@ EbmlBinary::~EbmlBinary(void) {
EbmlBinary::operator const binary &() const {return *Data;}
filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
filepos_t EbmlBinary::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
output.writeFully(Data,GetSize());
@@ -76,7 +76,7 @@ filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bW
/*!
\note no Default binary value handled
*/
uint64 EbmlBinary::UpdateSize(bool bWithDefault, bool bForceRender)
uint64 EbmlBinary::UpdateSize(bool /* bWithDefault */, bool /* bForceRender */)
{
return GetSize();
}

View File

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

View File

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

View File

@@ -486,6 +486,7 @@ EbmlElement * EbmlElement::SkipData(EbmlStream & DataStream, const EbmlSemanticC
Result = DataStream.FindNextElement(Context, bUpperElement, 0xFFFFFFFFL, AllowDummyElt);
} else {
Result = TestReadElt;
TestReadElt = NULL;
}
if (Result != NULL) {
@@ -581,14 +582,14 @@ filepos_t EbmlElement::Render(IOCallback & output, bool bWithDefault, bool bKeep
if (!bWithDefault && IsDefaultValue()) {
return 0;
}
#if defined(_DEBUG) || defined(DEBUG)
#if defined(LIBEBML_DEBUG)
uint64 SupposedSize = UpdateSize(bWithDefault, bForceRender);
#endif // _DEBUG
#endif // LIBEBML_DEBUG
filepos_t result = RenderHead(output, bForceRender, bWithDefault, bKeepPosition);
uint64 WrittenSize = RenderData(output, bForceRender, bWithDefault);
#if defined(_DEBUG) || defined(DEBUG)
#if defined(LIBEBML_DEBUG)
if (static_cast<int64>(SupposedSize) != (0-1)) assert(WrittenSize == SupposedSize);
#endif // DEBUG
#endif // LIBEBML_DEBUG
result += WrittenSize;
return result;
} catch (std::exception & ex) {
@@ -654,7 +655,7 @@ bool EbmlElement::CompareElements(const EbmlElement *A, const EbmlElement *B)
return false;
}
void EbmlElement::Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully)
void EbmlElement::Read(EbmlStream & inDataStream, const EbmlSemanticContext & /* Context */, int & /* UpperEltFound */, EbmlElement * & /* FoundElt */, bool /* AllowDummyElt */, ScopeMode ReadFully)
{
ReadData(inDataStream.I_O(), ReadFully);
}

View File

@@ -67,21 +67,26 @@ void EbmlFloat::SetDefaultValue(double aValue)
SetDefaultIsSet();
}
const double EbmlFloat::DefaultVal() const
double EbmlFloat::DefaultVal() const
{
assert(DefaultISset());
return DefaultValue;
}
EbmlFloat::operator const float() const {return float(Value);}
EbmlFloat::operator const double() const {return double(Value);}
EbmlFloat::operator float() const {return float(Value);}
EbmlFloat::operator double() const {return double(Value);}
double EbmlFloat::GetValue() const {return Value;}
EbmlFloat & EbmlFloat::SetValue(double NewValue) {
return *this = NewValue;
}
/*!
\todo handle exception on errors
\todo handle 10 bits precision
*/
filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
filepos_t EbmlFloat::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
assert(GetSize() == 4 || GetSize() == 8);
@@ -102,7 +107,7 @@ filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bWi
return GetSize();
}
uint64 EbmlFloat::UpdateSize(bool bWithDefault, bool bForceRender)
uint64 EbmlFloat::UpdateSize(bool bWithDefault, bool /* bForceRender */)
{
if (!bWithDefault && IsDefaultValue())
return 0;

View File

@@ -145,10 +145,10 @@ uint64 EbmlMaster::UpdateSize(bool bWithDefault, bool bForceRender)
continue;
(ElementList[Index])->UpdateSize(bWithDefault, bForceRender);
uint64 SizeToAdd = (ElementList[Index])->ElementSize(bWithDefault);
#if defined(_DEBUG) || defined(DEBUG)
#if defined(LIBEBML_DEBUG)
if (static_cast<int64>(SizeToAdd) == (0-1))
return (0-1);
#endif // DEBUG
#endif // LIBEBML_DEBUG
SetSize_(GetSize() + SizeToAdd);
}
if (bChecksumUsed) {
@@ -167,7 +167,7 @@ filepos_t EbmlMaster::WriteHead(IOCallback & output, int nSizeLength, bool bWith
/*!
\todo this code is very suspicious !
*/
filepos_t EbmlMaster::ReadData(IOCallback & input, ScopeMode ReadFully)
filepos_t EbmlMaster::ReadData(IOCallback & input, ScopeMode /* ReadFully */)
{
input.setFilePointer(GetSize(), seek_current);
return GetSize();
@@ -204,10 +204,10 @@ bool EbmlMaster::CheckMandatory() const
for (EltIdx = 0; EltIdx < EBML_CTX_SIZE(Context); EltIdx++) {
if (EBML_CTX_IDX(Context,EltIdx).IsMandatory()) {
if (FindElt(EBML_CTX_IDX_INFO(Context,EltIdx)) == NULL) {
#if defined(_DEBUG) || defined(DEBUG)
#if defined(LIBEBML_DEBUG)
// you are missing this Mandatory element
// const char * MissingName = EBML_INFO_NAME(EBML_CTX_IDX_INFO(Context,EltIdx));
#endif // DEBUG
#endif // LIBEBML_DEBUG
return false;
}
}

View File

@@ -55,15 +55,21 @@ EbmlSInteger::EbmlSInteger(const EbmlSInteger & ElementToClone)
{
}
EbmlSInteger::operator int8() {return int8(Value);}
EbmlSInteger::operator int16() {return int16(Value);}
EbmlSInteger::operator int32() {return int32(Value);}
EbmlSInteger::operator int64() {return Value;}
EbmlSInteger::operator int8() const {return int8(Value);}
EbmlSInteger::operator int16() const {return int16(Value);}
EbmlSInteger::operator int32() const {return int32(Value);}
EbmlSInteger::operator int64() const {return Value;}
int64 EbmlSInteger::GetValue() const {return Value;}
EbmlSInteger & EbmlSInteger::SetValue(int64 NewValue) {
return *this = NewValue;
}
/*!
\todo handle exception on errors
*/
filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
filepos_t EbmlSInteger::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
unsigned int i;
@@ -82,7 +88,7 @@ filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool
return GetSize();
}
uint64 EbmlSInteger::UpdateSize(bool bWithDefault, bool bForceRender)
uint64 EbmlSInteger::UpdateSize(bool bWithDefault, bool /* bForceRender */)
{
if (!bWithDefault && IsDefaultValue())
return 0;

View File

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

View File

@@ -75,11 +75,16 @@ EbmlUInteger::operator uint16() const {return uint16(Value);}
EbmlUInteger::operator uint32() const {return uint32(Value);}
EbmlUInteger::operator uint64() const {return Value;}
uint64 EbmlUInteger::GetValue() const {return Value;}
EbmlUInteger & EbmlUInteger::SetValue(uint64 NewValue) {
return *this = NewValue;
}
/*!
\todo handle exception on errors
*/
filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
filepos_t EbmlUInteger::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
@@ -97,7 +102,7 @@ filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool
return GetSize();
}
uint64 EbmlUInteger::UpdateSize(bool bWithDefault, bool bForceRender)
uint64 EbmlUInteger::UpdateSize(bool bWithDefault, bool /* bForceRender */)
{
if (!bWithDefault && IsDefaultValue())
return 0;

View File

@@ -59,6 +59,13 @@ UTFstring::UTFstring(const wchar_t * _aBuf)
*this = _aBuf;
}
UTFstring::UTFstring(std::wstring const &_aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf.c_str();
}
UTFstring::~UTFstring()
{
delete [] _Data;
@@ -183,7 +190,7 @@ void UTFstring::UpdateFromUCS2()
Size++;
} else if (_Data[i] < 0x800) {
Size += 2;
} else if (_Data[i] < 0x10000) {
} else {
Size += 3;
}
}
@@ -195,7 +202,7 @@ void UTFstring::UpdateFromUCS2()
} else if (_Data[i] < 0x800) {
tmpStr[Size++] = 0xC0 | (_Data[i] >> 6);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
} else if (_Data[i] < 0x10000) {
} else {
tmpStr[Size++] = 0xE0 | (_Data[i] >> 12);
tmpStr[Size++] = 0x80 | ((_Data[i] >> 6) & 0x3F);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
@@ -256,7 +263,7 @@ const UTFstring & EbmlUnicodeString::DefaultVal() const
\note limited to UCS-2
\todo handle exception on errors
*/
filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
uint32 Result = Value.GetUTF8().length();
@@ -288,10 +295,28 @@ EbmlUnicodeString & EbmlUnicodeString::operator=(const UTFstring & NewString)
return *this;
}
EbmlUnicodeString &EbmlUnicodeString::SetValue(UTFstring const &NewValue) {
return *this = NewValue;
}
EbmlUnicodeString &EbmlUnicodeString::SetValueUTF8(std::string const &NewValue) {
UTFstring NewValueUTFstring;
NewValueUTFstring.SetUTF8(NewValue);
return *this = NewValueUTFstring;
}
UTFstring EbmlUnicodeString::GetValue() const {
return Value;
}
std::string EbmlUnicodeString::GetValueUTF8() const {
return Value.GetUTF8();
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::UpdateSize(bool bWithDefault, bool bForceRender)
uint64 EbmlUnicodeString::UpdateSize(bool bWithDefault, bool /* bForceRender */)
{
if (!bWithDefault && IsDefaultValue())
return 0;

View File

@@ -1,41 +1,44 @@
/****************************************************************************
** 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
/****************************************************************************
** 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
const std::string EbmlCodeVersion = "1.3.0";
const std::string EbmlCodeDate = __TIMESTAMP__;
END_LIBEBML_NAMESPACE

View File

@@ -1,138 +1,138 @@
/****************************************************************************
** 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
DEFINE_EBML_CLASS_GLOBAL(EbmlVoid, 0xEC, 1, "EBMLVoid");
EbmlVoid::EbmlVoid()
{
SetValueIsSet();
}
filepos_t EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{
// 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 bWithDefault)
{
EltToReplaceWith.UpdateSize(bWithDefault);
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here !
return INVALID_FILEPOS_T;
}
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
// there is not enough space to put a filling element
return INVALID_FILEPOS_T;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bWithDefault);
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, bWithDefault); // 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 bWithDefault)
{
// EltToVoid.UpdateSize(bWithDefault);
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, bWithDefault); // 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
DEFINE_EBML_CLASS_GLOBAL(EbmlVoid, 0xEC, 1, "EBMLVoid");
EbmlVoid::EbmlVoid()
{
SetValueIsSet();
}
filepos_t EbmlVoid::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
// 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 bWithDefault)
{
EltToReplaceWith.UpdateSize(bWithDefault);
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here !
return INVALID_FILEPOS_T;
}
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
// there is not enough space to put a filling element
return INVALID_FILEPOS_T;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bWithDefault);
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, bWithDefault); // 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 bWithDefault)
{
// EltToVoid.UpdateSize(bWithDefault);
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, bWithDefault); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return EltToVoid.GetSize() + EltToVoid.HeadSize();
}
END_LIBEBML_NAMESPACE