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
This commit is contained in:
Moritz Bunkus 2012-09-04 07:37:12 +00:00
parent b95a4104aa
commit 0312461091
5 changed files with 38 additions and 2 deletions

View File

@ -52,13 +52,15 @@ 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));}

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

@ -112,6 +112,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

@ -122,6 +122,14 @@ EbmlString & EbmlString::operator=(const std::string & NewString)
return *this;
}
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())

View File

@ -288,6 +288,24 @@ 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
*/