diff options
| author | jhurst <jhurst@cinecert.com> | 2006-04-29 23:26:05 +0000 |
|---|---|---|
| committer | jhurst <> | 2006-04-29 23:26:05 +0000 |
| commit | 7c33dd683c5ef79630ae3bd5e1f8f8057d591388 (patch) | |
| tree | 8858319568a81e9a9b5d61b42679635cf7bc5c88 /src | |
| parent | 149c8628c287436f6127de1870462a03efbc1840 (diff) | |
Kumu updates
Diffstat (limited to 'src')
| -rwxr-xr-x | src/KLV.h | 28 | ||||
| -rwxr-xr-x | src/KM_util.h | 53 | ||||
| -rwxr-xr-x | src/MXFTypes.cpp | 1 |
3 files changed, 44 insertions, 38 deletions
@@ -98,19 +98,14 @@ inline const char* ui64sz(ui64_t i, char* buf) { public: UL() {} - UL(const byte_t* rhs) { - assert(rhs); - Set(rhs); - } - - UL(const UL& rhs) { - Set(rhs.m_Value); - } - + UL(const UL& rhs) : Kumu::Identifier<SMPTE_UL_LENGTH>(rhs) {} + UL(const byte_t* value) : Kumu::Identifier<SMPTE_UL_LENGTH>(value) {} virtual ~UL() {} - bool operator==(const UL& rhs) const { - return ( memcmp(m_Value, rhs.m_Value, SMPTE_UL_LENGTH) == 0 ) ? true : false; + const UL& operator=(const UL& rhs) { + if ( m_HasValue = rhs.m_HasValue ) + memcpy(m_Value, rhs.m_Value, SMPTE_UL_LENGTH); + return *this; } const char* EncodeString(char* str_buf, ui32_t buf_len) const; @@ -121,11 +116,16 @@ inline const char* ui64sz(ui64_t i, char* buf) { public: UMID() {} - UMID(const UMID &rhs) { - Set(rhs.m_Value); - }; + UMID(const UMID& rhs) : Kumu::Identifier<SMPTE_UMID_LENGTH>(rhs) {} + UMID(const byte_t* value) : Kumu::Identifier<SMPTE_UMID_LENGTH>(value) {} virtual ~UMID() {} + const UMID& operator=(const UMID& rhs) { + if ( m_HasValue = rhs.m_HasValue ) + memcpy(m_Value, rhs.m_Value, SMPTE_UMID_LENGTH); + return *this; + } + void MakeUMID(int Type); void MakeUMID(int Type, const UUID& ID); const char* EncodeString(char* str_buf, ui32_t buf_len) const; diff --git a/src/KM_util.h b/src/KM_util.h index 9009624..0d37370 100755 --- a/src/KM_util.h +++ b/src/KM_util.h @@ -167,22 +167,22 @@ namespace Kumu template <ui32_t SIZE> class Identifier : public IArchive { + const Identifier& operator=(const Identifier& rhs); + protected: bool m_HasValue; byte_t m_Value[SIZE]; public: Identifier() : m_HasValue(false) { memset(m_Value, 0, SIZE); } - Identifier(const byte_t* value) : m_HasValue(true) { memcpy(m_Value, value, SIZE); } - Identifier(const Identifier& rhs) : m_HasValue(true) { memcpy(m_Value, rhs.m_Value, SIZE); } - virtual ~Identifier() {} - - const Identifier& operator=(const Identifier& rhs) { - m_HasValue = true; - memcpy(m_Value, rhs.m_Value, SIZE); - return *this; + Identifier(const byte_t* value) : m_HasValue(true) { memcpy(m_Value, value, SIZE); } + Identifier(const Identifier& rhs) { + if ( m_HasValue = rhs.m_HasValue ) + memcpy(m_Value, rhs.m_Value, SIZE); } + virtual ~Identifier() {} + inline void Set(const byte_t* value) { m_HasValue = true; memcpy(m_Value, value, SIZE); } inline const byte_t* Value() const { return m_Value; } inline ui32_t Size() const { return SIZE; } @@ -214,11 +214,8 @@ namespace Kumu inline bool DecodeHex(const char* str) { ui32_t char_count; - if ( hex2bin(str, m_Value, SIZE, &char_count) != 0 ) - return false; - - m_HasValue = true; - return true; + m_HasValue = ( hex2bin(str, m_Value, SIZE, &char_count) == 0 ); + return m_HasValue; } inline const char* EncodeHex(char* buf, ui32_t buf_len) const @@ -233,11 +230,8 @@ namespace Kumu inline bool DecodeBase64(const char* str) { ui32_t char_count; - if ( base64decode(str, m_Value, SIZE, &char_count) != 0 ) - return false; - - m_HasValue = true; - return true; + m_HasValue = ( base64decode(str, m_Value, SIZE, &char_count) == 0 ); + return m_HasValue; } inline const char* EncodeBase64(char* buf, ui32_t buf_len) const @@ -245,15 +239,14 @@ namespace Kumu return base64encode(m_Value, SIZE, buf, buf_len); } - inline virtual bool HasValue() const { return m_HasValue; } + inline bool HasValue() const { return m_HasValue; } - inline virtual bool Unarchive(Kumu::MemIOReader* Reader) { - if ( ! Reader->ReadRaw(m_Value, SIZE) ) return false; - m_HasValue = true; - return true; + inline bool Unarchive(Kumu::MemIOReader* Reader) { + m_HasValue = Reader->ReadRaw(m_Value, SIZE); + return m_HasValue; } - inline virtual bool Archive(Kumu::MemIOWriter* Writer) const { + inline bool Archive(Kumu::MemIOWriter* Writer) const { return Writer->WriteRaw(m_Value, SIZE); } }; @@ -270,6 +263,12 @@ namespace Kumu UUID(const UUID& rhs) : Identifier<UUID_Length>(rhs) {} virtual ~UUID() {} + const UUID& operator=(const UUID& rhs) { + if ( m_HasValue = rhs.m_HasValue ) + memcpy(m_Value, rhs.m_Value, UUID_Length); + return *this; + } + inline const char* EncodeHex(char* buf, ui32_t buf_len) const { return bin2UUIDhex(m_Value, Size(), buf, buf_len); } @@ -293,6 +292,12 @@ namespace Kumu SymmetricKey(const byte_t* value) : Identifier<SymmetricKey_Length>(value) {} SymmetricKey(const UUID& rhs) : Identifier<SymmetricKey_Length>(rhs) {} virtual ~SymmetricKey() { memcpy(m_Value, NilKey, 16); m_HasValue = false; } + + const SymmetricKey& operator=(const SymmetricKey& rhs) { + if ( m_HasValue = rhs.m_HasValue ) + memcpy(m_Value, rhs.m_Value, SymmetricKey_Length); + return *this; + } }; void GenRandomValue(SymmetricKey&); diff --git a/src/MXFTypes.cpp b/src/MXFTypes.cpp index ba9d7ea..af6e6af 100755 --- a/src/MXFTypes.cpp +++ b/src/MXFTypes.cpp @@ -95,6 +95,7 @@ ASDCP::UMID::MakeUMID(int Type, const UUID& AssetID) m_Value[13] = m_Value[14] = m_Value[15] = 0; memcpy(&m_Value[16], AssetID.Value(), AssetID.Size()); + m_HasValue = true; } |
