--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#include "serializer.hpp"
+#include "storage_backend_xml.hpp"
+#include "tslog.hpp"
+#include <iostream>
+
+using namespace ldp_serializer;
+
+const uint8_t *Serializer::serialize(const std::string &config_path, size_t &size) {
+ tslog::init(tslog::ldp_log_level::DEFAULT);
+ ldp_xml::StorageBackendXML xmlStorage;
+
+ if (!xmlStorage.init(config_path.c_str())) {
+ std::cout << "xmlStorage init error" << std::endl;
+ return nullptr;
+ }
+
+ return serialize(xmlStorage, size);
+}
+const uint8_t *Serializer::serialize(const std::string &config_path, std::ostream &output) {
+ size_t size = 0;
+ auto buf = serialize(config_path, size);
+
+ output.write(reinterpret_cast<const char *>(buf), size);
+ return buf;
+}
* THE SOFTWARE. */
#include "serializer_flatbuffers.hpp"
+#include <iostream>
+#include <string>
+
+namespace ldp_xml {
+class StorageBackendXML;
+};
+
+namespace ldp_serializer
+{
+
+class Serializer {
+ SerializerFlatbuffers impl;
+public:
+ auto serialize(const ldp_xml::StorageBackendXML &db, size_t &size) {
+ return impl.serialize(db, size);
+ }
+ const uint8_t *serialize(const std::string &config_path, size_t &size);
+ const uint8_t *serialize(const std::string &config_path, std::ostream &output);
+};
-namespace ldp_serializer {
-using Serializer = SerializerFlatbuffers;
}
return buf;
}
-const uint8_t* SerializerFlatbuffers::serialize(const std::string config_path, size_t &size) {
- tslog::init(tslog::ldp_log_level::DEFAULT);
- ldp_xml::StorageBackendXML xmlStorage;
-
- if (!xmlStorage.init(config_path.c_str())) {
- std::cout << "xmlStorage init error" << std::endl;
- return nullptr;
- }
-
- return serialize(xmlStorage, size);
-}
-
-const uint8_t *SerializerFlatbuffers::serialize(const std::string config_path, std::ostream &output) {
- size_t size = 0;
- auto buf = serialize(config_path, size);
-
- output.write(reinterpret_cast<const char *>(buf), size);
- return buf;
-}
-
template <typename T>
auto SerializerFlatbuffers::get_create_set() -> decltype(type_helper<T>::create_set) {
return type_helper<T>::create_set;