From 18676e251fea0d7045f3720509923f1ebbe6c0bb Mon Sep 17 00:00:00 2001 From: Randolph Voorhies Date: Mon, 17 Jun 2013 16:17:20 -0700 Subject: [PATCH] Restructuring --- .gitignore | 2 +- Makefile | 18 +-- boost_serialize.cpp | 34 ----- .../cereal/binary_archive}/array.hpp | 0 .../cereal/binary_archive}/binary_archive.hpp | 0 .../cereal/binary_archive}/bitset.hpp | 0 .../cereal/binary_archive}/complex.hpp | 0 .../cereal/binary_archive}/deque.hpp | 0 .../cereal/binary_archive}/forward_list.hpp | 0 .../cereal/binary_archive}/list.hpp | 0 .../cereal/binary_archive}/map.hpp | 0 .../cereal/binary_archive}/memory.hpp | 0 .../cereal/binary_archive}/queue.hpp | 0 .../cereal/binary_archive}/set.hpp | 0 .../cereal/binary_archive}/stack.hpp | 0 .../cereal/binary_archive}/string.hpp | 0 .../cereal/binary_archive}/tuple.hpp | 0 .../cereal/binary_archive}/unordered_map.hpp | 0 .../cereal/binary_archive}/unordered_set.hpp | 0 .../cereal/binary_archive}/utility.hpp | 0 .../cereal/binary_archive}/vector.hpp | 0 cereal.hpp => include/cereal/cereal.hpp | 0 .../cereal/details}/traits.hpp | 0 json_archive/json_archive.hpp | 127 ------------------ test.cpp => sandbox.cpp | 1 - 25 files changed, 11 insertions(+), 171 deletions(-) delete mode 100644 boost_serialize.cpp rename {binary_archive => include/cereal/binary_archive}/array.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/binary_archive.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/bitset.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/complex.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/deque.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/forward_list.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/list.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/map.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/memory.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/queue.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/set.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/stack.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/string.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/tuple.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/unordered_map.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/unordered_set.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/utility.hpp (100%) rename {binary_archive => include/cereal/binary_archive}/vector.hpp (100%) rename cereal.hpp => include/cereal/cereal.hpp (100%) rename {details => include/cereal/details}/traits.hpp (100%) delete mode 100644 json_archive/json_archive.hpp rename test.cpp => sandbox.cpp (99%) diff --git a/.gitignore b/.gitignore index d4f252bb..e5353cb7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,9 +14,9 @@ out.txt ptr.txt -test test.txt unittests boost_serialize arr.txt performance +sandbox diff --git a/Makefile b/Makefile index 8ac4fd71..163d305b 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,17 @@ -all: test.cpp - g++ -std=c++0x test.cpp -o test -ljsoncpp -I./.. +CPPFLAGS=-std=c++11 -I./include +CC=g++ + +all: unittests sandbox performance + +sandbox: sandbox.cpp + ${CC} sandbox.cpp -o sandbox ${CPPFLAGS} unittests: unittests.cpp - clang++ -std=c++0x unittests.cpp -o unittests -lboost_unit_test_framework -I./.. + ${CC} unittests.cpp -o unittests -lboost_unit_test_framework ${CPPFLAGS} ./unittests --show_progress performance: performance.cpp - clang++ -std=c++11 performance.cpp -o performance -lboost_serialization -I./.. -O3 - -boost_serialize: boost_serialize.cpp - g++ -std=c++11 boost_serialize.cpp -o boost_serialize -lboost_serialization -I./.. + ${CC} performance.cpp -o performance -lboost_serialization ${CPPFLAGS} -O3 clean: - rm test; rm unittests; + rm sandbox; rm unittests; rm performance; diff --git a/boost_serialize.cpp b/boost_serialize.cpp deleted file mode 100644 index e90f6fa8..00000000 --- a/boost_serialize.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -struct myStruct -{ - myStruct() : x(0) {} - int x; - - - template - void serialize(Archive & ar, const unsigned int version) - { - ar & x; - } -}; - - -int main() -{ - boost::archive::text_oarchive oa(std::cout); - - const myStruct v; - - oa & v; - - std::cout << BOOST_NO_FUNCTION_TEMPLATE_ORDERING << std::endl; - - return 0; -} diff --git a/binary_archive/array.hpp b/include/cereal/binary_archive/array.hpp similarity index 100% rename from binary_archive/array.hpp rename to include/cereal/binary_archive/array.hpp diff --git a/binary_archive/binary_archive.hpp b/include/cereal/binary_archive/binary_archive.hpp similarity index 100% rename from binary_archive/binary_archive.hpp rename to include/cereal/binary_archive/binary_archive.hpp diff --git a/binary_archive/bitset.hpp b/include/cereal/binary_archive/bitset.hpp similarity index 100% rename from binary_archive/bitset.hpp rename to include/cereal/binary_archive/bitset.hpp diff --git a/binary_archive/complex.hpp b/include/cereal/binary_archive/complex.hpp similarity index 100% rename from binary_archive/complex.hpp rename to include/cereal/binary_archive/complex.hpp diff --git a/binary_archive/deque.hpp b/include/cereal/binary_archive/deque.hpp similarity index 100% rename from binary_archive/deque.hpp rename to include/cereal/binary_archive/deque.hpp diff --git a/binary_archive/forward_list.hpp b/include/cereal/binary_archive/forward_list.hpp similarity index 100% rename from binary_archive/forward_list.hpp rename to include/cereal/binary_archive/forward_list.hpp diff --git a/binary_archive/list.hpp b/include/cereal/binary_archive/list.hpp similarity index 100% rename from binary_archive/list.hpp rename to include/cereal/binary_archive/list.hpp diff --git a/binary_archive/map.hpp b/include/cereal/binary_archive/map.hpp similarity index 100% rename from binary_archive/map.hpp rename to include/cereal/binary_archive/map.hpp diff --git a/binary_archive/memory.hpp b/include/cereal/binary_archive/memory.hpp similarity index 100% rename from binary_archive/memory.hpp rename to include/cereal/binary_archive/memory.hpp diff --git a/binary_archive/queue.hpp b/include/cereal/binary_archive/queue.hpp similarity index 100% rename from binary_archive/queue.hpp rename to include/cereal/binary_archive/queue.hpp diff --git a/binary_archive/set.hpp b/include/cereal/binary_archive/set.hpp similarity index 100% rename from binary_archive/set.hpp rename to include/cereal/binary_archive/set.hpp diff --git a/binary_archive/stack.hpp b/include/cereal/binary_archive/stack.hpp similarity index 100% rename from binary_archive/stack.hpp rename to include/cereal/binary_archive/stack.hpp diff --git a/binary_archive/string.hpp b/include/cereal/binary_archive/string.hpp similarity index 100% rename from binary_archive/string.hpp rename to include/cereal/binary_archive/string.hpp diff --git a/binary_archive/tuple.hpp b/include/cereal/binary_archive/tuple.hpp similarity index 100% rename from binary_archive/tuple.hpp rename to include/cereal/binary_archive/tuple.hpp diff --git a/binary_archive/unordered_map.hpp b/include/cereal/binary_archive/unordered_map.hpp similarity index 100% rename from binary_archive/unordered_map.hpp rename to include/cereal/binary_archive/unordered_map.hpp diff --git a/binary_archive/unordered_set.hpp b/include/cereal/binary_archive/unordered_set.hpp similarity index 100% rename from binary_archive/unordered_set.hpp rename to include/cereal/binary_archive/unordered_set.hpp diff --git a/binary_archive/utility.hpp b/include/cereal/binary_archive/utility.hpp similarity index 100% rename from binary_archive/utility.hpp rename to include/cereal/binary_archive/utility.hpp diff --git a/binary_archive/vector.hpp b/include/cereal/binary_archive/vector.hpp similarity index 100% rename from binary_archive/vector.hpp rename to include/cereal/binary_archive/vector.hpp diff --git a/cereal.hpp b/include/cereal/cereal.hpp similarity index 100% rename from cereal.hpp rename to include/cereal/cereal.hpp diff --git a/details/traits.hpp b/include/cereal/details/traits.hpp similarity index 100% rename from details/traits.hpp rename to include/cereal/details/traits.hpp diff --git a/json_archive/json_archive.hpp b/json_archive/json_archive.hpp deleted file mode 100644 index 5cfe3e21..00000000 --- a/json_archive/json_archive.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - Copyright (c) 2013, Randolph Voorhies, Shane Grant - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of cereal nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifndef CEREAL_JSON_ARCHIVE_JSON_ARCHIVE_HPP_ -#define CEREAL_JSON_ARCHIVE_JSON_ARCHIVE_HPP_ - -#include -#include -#include - -namespace cereal -{ - // ###################################################################### - class JSONOutputArchive : public OutputArchive - { - public: - JSONOutputArchive(std::ostream & stream) : - OutputArchive(this), - itsStream(stream) - { } - - Json::StyledStreamWriter & writer() { return itsWriter; } - std::ostream & stream() {return itsStream; } - - private: - std::ostream & itsStream; - Json::StyledStreamWriter itsWriter; - }; - - // ###################################################################### - class JSONInputArchive : public InputArchive - { - public: - JSONInputArchive(std::istream & stream) : - InputArchive(this), - itsStream(stream) - { } - - std::istream & stream() {return itsStream; } - - private: - std::istream & itsStream; - }; - - //! Saving for POD types to json - template - typename std::enable_if::value, void>::type - save(JSONOutputArchive & ar, T const & t) - { - //ar.stream() << t; - } - - //! Loading for POD types from json - template - typename std::enable_if::value, void>::type - load(JSONInputArchive & ar, T & t) - { - //ar.stream() >> t; - } - - //! Saving for NVP types to json - template - void save(JSONOutputArchive & ar, NameValuePair const & t) - { - //ar.stream() << t.name << " : "; - // - //ar & t.value; - - //ar.stream() << "\n"; - Json::Value v; - v[t.name] = t.value; - ar.writer().write(ar.stream(), v); - - //ar.writer().write(ar.stream(), Json::Value(t.name)); - //ar.writer().write(ar.stream(), Json::Value(t.value)); - } - - //! Loading for NVP types from json - template - void load(JSONInputArchive & ar, NameValuePair t) - { - ar & t.value; - } - - //! Serialization for basic_string types to json - template - void save(JSONOutputArchive & ar, std::basic_string const & str) - { - //ar.stream() << "\"" << str << "\""; - } - - //! Serialization for basic_string types from json - template - void load(JSONInputArchive & ar, std::basic_string & str) - { - //size_t size; - //ar & size; - //str.resize(size); - //ar.load_json(const_cast(str.data()), size * sizeof(CharT)); - //std::cout << "Loading string: " << str << std::endl; - } -} - -#endif // CEREAL_JSON_ARCHIVE_JSON_ARCHIVE_HPP_ diff --git a/test.cpp b/sandbox.cpp similarity index 99% rename from test.cpp rename to sandbox.cpp index 413086fc..3d914a32 100644 --- a/test.cpp +++ b/sandbox.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include