release candidate
[asdcplib.git] / src / KM_util.h
index 7ca30e0e7d4e7227efc3dbc038b4289ecab7513e..ea83e63c6fea3fed45d0d77572a003d6e6366c16 100755 (executable)
@@ -230,6 +230,35 @@ namespace Kumu
        }
     };
 
+  // archivable version of std::string
+
+  //
+  class ArchivableString : public std::string, public Kumu::IArchive
+    {
+
+    public:
+      ArchivableString() {}
+      ArchivableString(const char* sz) : std::string(sz) {}
+      ArchivableString(const std::string& s) : std::string(s) {}
+      virtual ~ArchivableString() {}
+
+      bool   HasValue() const { return ! this->empty(); }
+      ui32_t ArchiveLength() const { return sizeof(ui32_t) + this->size(); }
+
+      bool   Archive(MemIOWriter* Writer) const {
+       if ( Writer == 0 ) return false;
+       return Writer->WriteString(*this);
+      }
+
+      bool   Unarchive(MemIOReader* Reader) {
+       if ( Reader == 0 ) return false;
+       return Reader->ReadString(*this);
+      }
+    };
+
+  //
+  typedef Kumu::ArchivableList<ArchivableString> StringList;
+
   //
   // the base of all identifier classes, Identifier is not usually used directly
   // see UUID and SymmetricKey below for more detail.