Kumu updates
authorjhurst <jhurst@cinecert.com>
Sat, 29 Apr 2006 23:26:05 +0000 (23:26 +0000)
committerjhurst <>
Sat, 29 Apr 2006 23:26:05 +0000 (23:26 +0000)
src/KLV.h
src/KM_util.h
src/MXFTypes.cpp

index 9c274bf87339774ba0af689e9fe6832d0b68542a..ba291b6170a6c7f0a169d53b945fb31326dfefa5 100755 (executable)
--- a/src/KLV.h
+++ b/src/KLV.h
@@ -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;
index 900962459933fb18d86d635e37ab598072fd5fa3..0d37370197527faa606bcbb2d5b196789d34ad5b 100755 (executable)
@@ -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&);
index ba9d7eae600faf22fac20df44960a5948e44703a..af6e6af3b42884549151e0c94ab398b3ba556721 100755 (executable)
@@ -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;
 }