diff --git a/tests/save.cpp b/tests/save.cpp index 91250fe..83725ae 100644 --- a/tests/save.cpp +++ b/tests/save.cpp @@ -38,7 +38,6 @@ struct Robot { TEST_CASE("test using tser for serialization", "[config]") { auto robot = Robot{ Pixel{3,4}, L"BIG NAME", Item::RADAR}; - std::cout << robot << '\n'; tser::BinaryArchive archive; archive.save(robot); diff --git a/tser.hpp b/tser.hpp index b5a60d0..bcc16dc 100644 --- a/tser.hpp +++ b/tser.hpp @@ -11,6 +11,7 @@ #include #include + namespace tser{ //implementation details for C++20 is_detected namespace detail { @@ -85,52 +86,6 @@ namespace tser{ template constexpr bool is_pointer_like_v = std::is_pointer_v || is_detected_v || is_detected_v; - //implementation of the recursive json printing - template - constexpr inline decltype(auto) print(std::ostream& os, T&& val) { - using V = std::decay_t; - if constexpr (std::is_constructible_v || std::is_same_v) { - os << "\"" << val << "\""; - } else if constexpr (std::is_constructible_v || std::is_same_v) { - std::wstring_convert> converter; - os << "\"" << converter.to_bytes(val) << "\""; - } else if constexpr (is_container_v) { - size_t i = 0; - os << "\n["; - - for (auto& elem : val) { - os << (i++ == 0 ? "" : ",") << tser::print(os, elem); - } - - os << "]\n"; - } else if constexpr (is_tser_t_v && !is_detected_v) { - - auto pMem = [&](auto& ... memberVal) { - size_t i = 0; - (((os << (i != 0 ? ", " : "") << '\"'), os << V::_memberNames[i++] << "\" : " << tser::print(os, memberVal)), ...); - }; - - os << "{ \"" << V::_typeName << "\": {"; std::apply(pMem, val.members()); os << "}}\n"; - - } else if constexpr (std::is_enum_v &&! is_detected_v) { - os << tser::print(os, static_cast>(val)); - } else if constexpr (is_tuple_v && !is_detected_v) { - std::apply([&](auto& ... t) { - int i = 0; - os << "{"; - (((i++ != 0 ? os << ", " : os), - tser::print(os, t)), ...); // WTF - os << "}"; - }, val); - } else if constexpr (is_pointer_like_v) { - os << (val ? (os << (tser::print(os, *val)), "") : "null"); - } else { - os << val; - } - - return ""; - } - class BinaryArchive { std::string m_bytes = std::string(1024, '\0'); size_t m_bufferSize = 0, m_readOffset = 0; @@ -262,6 +217,4 @@ static constexpr std::array _me [](){ std::array out{ }; \ for(size_t _i = 0, nArgs = 0; nArgs < tser::detail::n_args(#__VA_ARGS__) ; ++_i) { \ while(Type::_memberNameData[_i] == '\0') _i++; out[nArgs++] = &Type::_memberNameData[_i]; \ -while(Type::_memberNameData[++_i] != '\0'); } return out;}();\ -template && !tser::is_detected_v, int> = 0>\ -friend std::ostream& operator<<(std::ostream& os, const OT& t) { tser::print(os, t); return os; } +while(Type::_memberNameData[++_i] != '\0'); } return out;}(); diff --git a/wraps/cereal.wrap b/wraps/cereal.wrap deleted file mode 100644 index f0bc435..0000000 --- a/wraps/cereal.wrap +++ /dev/null @@ -1,12 +0,0 @@ -[wrap-file] -directory = cereal-1.3.2 -source_url = https://github.com/USCiLab/cereal/archive/v1.3.2.tar.gz -source_filename = cereal-1.3.2.tar.gz -source_hash = 16a7ad9b31ba5880dac55d62b5d6f243c3ebc8d46a3514149e56b5e7ea81f85f -patch_filename = cereal_1.3.2-1_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/cereal_1.3.2-1/get_patch -patch_hash = fd2f047a40a0d291c643fdafe4ce743f0eadbef667b6afe43a332e1ba0862603 - -[provide] -cereal = cereal_dep -