Replace std::string with CKM::Password
[platform/core/security/key-manager.git] / src / manager / dpl / core / include / dpl / serialization.h
index 5140acf..4cda53e 100644 (file)
@@ -29,6 +29,8 @@
 #include <memory>
 
 #include <dpl/raw-buffer.h>
+// temporary fix for tizen 2.3
+#include <ckm/ckm-password.h>
 
 namespace CKM {
 // Abstract data stream buffer
@@ -139,6 +141,20 @@ struct Serialization {
         stream.Write(length, str->c_str());
     }
 
+    // Password
+    static void Serialize(IStream& stream, const Password& str)
+    {
+        int length = str.size();
+        stream.Write(sizeof(length), &length);
+        stream.Write(length, str.c_str());
+    }
+    static void Serialize(IStream& stream, const Password* const str)
+    {
+        int length = str->size();
+        stream.Write(sizeof(length), &length);
+        stream.Write(length, str->c_str());
+    }
+
     // STL templates
 
     // std::list
@@ -334,6 +350,28 @@ struct Deserialization {
         delete[] buf;
     }
 
+    // Password
+    static void Deserialize(IStream& stream, Password& str)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        char * buf = new char[length + 1];
+        stream.Read(length, buf);
+        buf[length] = 0;
+        str = Password(buf);
+        delete[] buf;
+    }
+    static void Deserialize(IStream& stream, Password*& str)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        char * buf = new char[length + 1];
+        stream.Read(length, buf);
+        buf[length] = 0;
+        str = new Password(buf);
+        delete[] buf;
+    }
+
     // STL templates
 
     // std::list