Revert "Support conversion between archive and string"
authorSangwan Kwon <sangwan.kwon@samsung.com>
Wed, 20 Nov 2019 01:20:37 +0000 (10:20 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Fri, 22 Nov 2019 01:52:17 +0000 (10:52 +0900)
This reverts commit dae502f799024c3b77afaea1c828f375f4301642.

src/vist/archive.hpp
src/vist/common/tests/archive.cpp

index 4086652fc793d34b23e19f4ca6308a9a884bb4c2..f1d525abab7728cc66bf4f4e44fcec45380fcaf5 100644 (file)
@@ -44,12 +44,6 @@ using IsArchival = typename std::enable_if<std::is_base_of<Archival, T>::value,
 
 class Archive final {
 public:
-       explicit Archive() = default;
-       /// Use only when flatten data comes from Archive (by casting to string)
-       explicit Archive(const std::string& flatten) : buffer(flatten.cbegin(), flatten.cend())
-       {
-       }
-
        template<typename Front, typename... Rest>
        void pack(const Front& front, const Rest&... rest);
        inline void pack(void) {}
@@ -61,7 +55,7 @@ public:
        template<typename... Ts>
        void transform(std::tuple<Ts...>& tuple);
 
-       /// serialize method
+       // serialize method
        template<typename T, IsFundamental<T> = 0>
        Archive& operator<<(const T& value);
        template<typename T, IsArchival<T> = 0>
@@ -73,7 +67,7 @@ public:
        Archive& operator<<(const std::string& value);
        Archive& operator<<(const Archive& archive);
 
-       /// deserialize method
+       // deserialize method
        template<typename T, IsFundamental<T> = 0>
        Archive& operator>>(T& value);
        template<typename T, IsArchival<T> = 0>
@@ -89,15 +83,9 @@ public:
        std::size_t size(void) const noexcept;
        void reserve(std::size_t size) noexcept;
 
-       /// It is not safe when Archive includes binary formats.
-       operator std::string() const
-       {
-               return std::string(this->buffer.begin(), this->buffer.end());
-       }
-
 protected:
-       void save(const void* bytes, std::size_t size);
-       void load(void* bytes, std::size_t size);
+       virtual void save(const void* bytes, std::size_t size);
+       virtual void load(void* bytes, std::size_t size);
 
 private:
        template<typename T>
index 508eb83c14f5040af5e208e2fb3617930f4fe8ad..ab8c69be021569760ea42623eb095a3a0ae1d5eb 100644 (file)
@@ -310,21 +310,3 @@ TEST(ArchiveTests, parameter_pack_transform_empty)
        Archive archive;
        archive.transform(tuple);
 }
-
-TEST(ArchiveTests, string_conversion)
-{
-       int input1 = std::numeric_limits<int>::lowest();
-       int input2 = std::numeric_limits<int>::max();
-
-       Archive archive;
-       archive << input1 << input2;
-
-       std::string flatten = archive;
-       Archive restore(flatten);
-
-       int output1, output2;
-       restore >> output1 >> output2;
-
-       EXPECT_EQ(input1, output1);
-       EXPECT_EQ(input2, output2);
-}