1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024 |
- #ifndef CEREAL_ARCHIVES_JSON_HPP_
- #define CEREAL_ARCHIVES_JSON_HPP_
- #include "cereal/cereal.hpp"
- #include "cereal/details/util.hpp"
- namespace cereal
- {
-
-
- struct RapidJSONException : Exception
- { RapidJSONException( const char * what_ ) : Exception( what_ ) {} };
- }
- #ifndef CEREAL_RAPIDJSON_ASSERT_THROWS
- #define CEREAL_RAPIDJSON_ASSERT_THROWS
- #endif
- #ifndef CEREAL_RAPIDJSON_ASSERT
- #define CEREAL_RAPIDJSON_ASSERT(x) if(!(x)){ \
- throw ::cereal::RapidJSONException("rapidjson internal assertion failure: " #x); }
- #endif
- #ifndef CEREAL_RAPIDJSON_WRITE_DEFAULT_FLAGS
- #define CEREAL_RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNanAndInfFlag
- #endif
- #ifndef CEREAL_RAPIDJSON_PARSE_DEFAULT_FLAGS
- #define CEREAL_RAPIDJSON_PARSE_DEFAULT_FLAGS kParseFullPrecisionFlag | kParseNanAndInfFlag
- #endif
- #include "cereal/external/rapidjson/prettywriter.h"
- #include "cereal/external/rapidjson/ostreamwrapper.h"
- #include "cereal/external/rapidjson/istreamwrapper.h"
- #include "cereal/external/rapidjson/document.h"
- #include "cereal/external/base64.hpp"
- #include <limits>
- #include <sstream>
- #include <stack>
- #include <vector>
- #include <string>
- namespace cereal
- {
-
-
-
- class JSONOutputArchive : public OutputArchive<JSONOutputArchive>, public traits::TextArchive
- {
- enum class NodeType { StartObject, InObject, StartArray, InArray };
- using WriteStream = CEREAL_RAPIDJSON_NAMESPACE::OStreamWrapper;
- using JSONWriter = CEREAL_RAPIDJSON_NAMESPACE::PrettyWriter<WriteStream>;
- public:
-
-
-
- class Options
- {
- public:
-
- static Options Default(){ return Options(); }
-
- static Options NoIndent(){ return Options( JSONWriter::kDefaultMaxDecimalPlaces, IndentChar::space, 0 ); }
-
- enum class IndentChar : char
- {
- space = ' ',
- tab = '\t',
- newline = '\n',
- carriage_return = '\r'
- };
-
-
- explicit Options( int precision = JSONWriter::kDefaultMaxDecimalPlaces,
- IndentChar indentChar = IndentChar::space,
- unsigned int indentLength = 4 ) :
- itsPrecision( precision ),
- itsIndentChar( static_cast<char>(indentChar) ),
- itsIndentLength( indentLength ) { }
- private:
- friend class JSONOutputArchive;
- int itsPrecision;
- char itsIndentChar;
- unsigned int itsIndentLength;
- };
-
-
- JSONOutputArchive(std::ostream & stream, Options const & options = Options::Default() ) :
- OutputArchive<JSONOutputArchive>(this),
- itsWriteStream(stream),
- itsWriter(itsWriteStream),
- itsNextName(nullptr)
- {
- itsWriter.SetMaxDecimalPlaces( options.itsPrecision );
- itsWriter.SetIndent( options.itsIndentChar, options.itsIndentLength );
- itsNameCounter.push(0);
- itsNodeStack.push(NodeType::StartObject);
- }
-
- ~JSONOutputArchive() CEREAL_NOEXCEPT
- {
- if (itsNodeStack.top() == NodeType::InObject)
- itsWriter.EndObject();
- else if (itsNodeStack.top() == NodeType::InArray)
- itsWriter.EndArray();
- }
-
-
- void saveBinaryValue( const void * data, size_t size, const char * name = nullptr )
- {
- setNextName( name );
- writeName();
- auto base64string = base64::encode( reinterpret_cast<const unsigned char *>( data ), size );
- saveValue( base64string );
- };
-
-
-
-
-
- void startNode()
- {
- writeName();
- itsNodeStack.push(NodeType::StartObject);
- itsNameCounter.push(0);
- }
-
- void finishNode()
- {
-
-
-
-
-
- switch(itsNodeStack.top())
- {
- case NodeType::StartArray:
- itsWriter.StartArray();
-
- case NodeType::InArray:
- itsWriter.EndArray();
- break;
- case NodeType::StartObject:
- itsWriter.StartObject();
-
- case NodeType::InObject:
- itsWriter.EndObject();
- break;
- }
- itsNodeStack.pop();
- itsNameCounter.pop();
- }
-
- void setNextName( const char * name )
- {
- itsNextName = name;
- }
-
- void saveValue(bool b) { itsWriter.Bool(b); }
-
- void saveValue(int i) { itsWriter.Int(i); }
-
- void saveValue(unsigned u) { itsWriter.Uint(u); }
-
- void saveValue(int64_t i64) { itsWriter.Int64(i64); }
-
- void saveValue(uint64_t u64) { itsWriter.Uint64(u64); }
-
- void saveValue(double d) { itsWriter.Double(d); }
-
- void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<CEREAL_RAPIDJSON_NAMESPACE::SizeType>( s.size() )); }
-
- void saveValue(char const * s) { itsWriter.String(s); }
-
- void saveValue(std::nullptr_t) { itsWriter.Null(); }
- private:
-
-
-
- template <class T, traits::EnableIf<sizeof(T) == sizeof(std::int32_t),
- std::is_signed<T>::value> = traits::sfinae> inline
- void saveLong(T l){ saveValue( static_cast<std::int32_t>( l ) ); }
-
- template <class T, traits::EnableIf<sizeof(T) != sizeof(std::int32_t),
- std::is_signed<T>::value> = traits::sfinae> inline
- void saveLong(T l){ saveValue( static_cast<std::int64_t>( l ) ); }
-
- template <class T, traits::EnableIf<sizeof(T) == sizeof(std::int32_t),
- std::is_unsigned<T>::value> = traits::sfinae> inline
- void saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
-
- template <class T, traits::EnableIf<sizeof(T) != sizeof(std::int32_t),
- std::is_unsigned<T>::value> = traits::sfinae> inline
- void saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
- public:
- #if defined(_MSC_VER) && _MSC_VER < 1916
-
- void saveValue( unsigned long lu ){ saveLong( lu ); };
- #else
-
- template <class T, traits::EnableIf<std::is_same<T, long>::value,
- !std::is_same<T, int>::value,
- !std::is_same<T, std::int64_t>::value> = traits::sfinae> inline
- void saveValue( T t ){ saveLong( t ); }
-
- template <class T, traits::EnableIf<std::is_same<T, unsigned long>::value,
- !std::is_same<T, unsigned>::value,
- !std::is_same<T, std::uint64_t>::value> = traits::sfinae> inline
- void saveValue( T t ){ saveLong( t ); }
- #endif
-
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value,
- !std::is_same<T, long>::value,
- !std::is_same<T, unsigned long>::value,
- !std::is_same<T, std::int64_t>::value,
- !std::is_same<T, std::uint64_t>::value,
- (sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long))> = traits::sfinae> inline
- void saveValue(T const & t)
- {
- std::stringstream ss; ss.precision( std::numeric_limits<long double>::max_digits10 );
- ss << t;
- saveValue( ss.str() );
- }
-
-
- void writeName()
- {
- NodeType const & nodeType = itsNodeStack.top();
-
- if(nodeType == NodeType::StartArray)
- {
- itsWriter.StartArray();
- itsNodeStack.top() = NodeType::InArray;
- }
- else if(nodeType == NodeType::StartObject)
- {
- itsNodeStack.top() = NodeType::InObject;
- itsWriter.StartObject();
- }
-
- if(nodeType == NodeType::InArray) return;
- if(itsNextName == nullptr)
- {
- std::string name = "value" + std::to_string( itsNameCounter.top()++ ) + "\0";
- saveValue(name);
- }
- else
- {
- saveValue(itsNextName);
- itsNextName = nullptr;
- }
- }
-
- void makeArray()
- {
- itsNodeStack.top() = NodeType::StartArray;
- }
-
- private:
- WriteStream itsWriteStream;
- JSONWriter itsWriter;
- char const * itsNextName;
- std::stack<uint32_t> itsNameCounter;
- std::stack<NodeType> itsNodeStack;
- };
-
-
-
- class JSONInputArchive : public InputArchive<JSONInputArchive>, public traits::TextArchive
- {
- private:
- using ReadStream = CEREAL_RAPIDJSON_NAMESPACE::IStreamWrapper;
- typedef CEREAL_RAPIDJSON_NAMESPACE::GenericValue<CEREAL_RAPIDJSON_NAMESPACE::UTF8<>> JSONValue;
- typedef JSONValue::ConstMemberIterator MemberIterator;
- typedef JSONValue::ConstValueIterator ValueIterator;
- typedef CEREAL_RAPIDJSON_NAMESPACE::Document::GenericValue GenericValue;
- public:
-
-
-
-
- JSONInputArchive(std::istream & stream) :
- InputArchive<JSONInputArchive>(this),
- itsNextName( nullptr ),
- itsReadStream(stream)
- {
- itsDocument.ParseStream<>(itsReadStream);
- if (itsDocument.IsArray())
- itsIteratorStack.emplace_back(itsDocument.Begin(), itsDocument.End());
- else
- itsIteratorStack.emplace_back(itsDocument.MemberBegin(), itsDocument.MemberEnd());
- }
- ~JSONInputArchive() CEREAL_NOEXCEPT = default;
-
-
- void loadBinaryValue( void * data, size_t size, const char * name = nullptr )
- {
- itsNextName = name;
- std::string encoded;
- loadValue( encoded );
- auto decoded = base64::decode( encoded );
- if( size != decoded.size() )
- throw Exception("Decoded binary data size does not match specified size");
- std::memcpy( data, decoded.data(), decoded.size() );
- itsNextName = nullptr;
- };
- private:
-
-
-
-
-
- class Iterator
- {
- public:
- Iterator() : itsIndex( 0 ), itsType(Null_) {}
- Iterator(MemberIterator begin, MemberIterator end) :
- itsMemberItBegin(begin), itsMemberItEnd(end), itsIndex(0), itsSize(std::distance(begin, end)), itsType(Member)
- {
- if( itsSize == 0 )
- itsType = Null_;
- }
- Iterator(ValueIterator begin, ValueIterator end) :
- itsValueItBegin(begin), itsIndex(0), itsSize(std::distance(begin, end)), itsType(Value)
- {
- if( itsSize == 0 )
- itsType = Null_;
- }
-
- Iterator & operator++()
- {
- ++itsIndex;
- return *this;
- }
-
- GenericValue const & value()
- {
- if( itsIndex >= itsSize )
- throw cereal::Exception("No more objects in input");
- switch(itsType)
- {
- case Value : return itsValueItBegin[itsIndex];
- case Member: return itsMemberItBegin[itsIndex].value;
- default: throw cereal::Exception("JSONInputArchive internal error: null or empty iterator to object or array!");
- }
- }
-
- const char * name() const
- {
- if( itsType == Member && (itsMemberItBegin + itsIndex) != itsMemberItEnd )
- return itsMemberItBegin[itsIndex].name.GetString();
- else
- return nullptr;
- }
-
-
- inline void search( const char * searchName )
- {
- const auto len = std::strlen( searchName );
- size_t index = 0;
- for( auto it = itsMemberItBegin; it != itsMemberItEnd; ++it, ++index )
- {
- const auto currentName = it->name.GetString();
- if( ( std::strncmp( searchName, currentName, len ) == 0 ) &&
- ( std::strlen( currentName ) == len ) )
- {
- itsIndex = index;
- return;
- }
- }
- throw Exception("JSON Parsing failed - provided NVP (" + std::string(searchName) + ") not found");
- }
- private:
- MemberIterator itsMemberItBegin, itsMemberItEnd;
- ValueIterator itsValueItBegin;
- size_t itsIndex, itsSize;
- enum Type {Value, Member, Null_} itsType;
- };
-
-
- inline void search()
- {
-
- auto localNextName = itsNextName;
- itsNextName = nullptr;
-
- if( localNextName )
- {
-
- auto const actualName = itsIteratorStack.back().name();
-
- if( !actualName || std::strcmp( localNextName, actualName ) != 0 )
- itsIteratorStack.back().search( localNextName );
- }
- }
- public:
-
-
- void startNode()
- {
- search();
- if(itsIteratorStack.back().value().IsArray())
- itsIteratorStack.emplace_back(itsIteratorStack.back().value().Begin(), itsIteratorStack.back().value().End());
- else
- itsIteratorStack.emplace_back(itsIteratorStack.back().value().MemberBegin(), itsIteratorStack.back().value().MemberEnd());
- }
-
- void finishNode()
- {
- itsIteratorStack.pop_back();
- ++itsIteratorStack.back();
- }
-
-
- const char * getNodeName() const
- {
- return itsIteratorStack.back().name();
- }
-
- void setNextName( const char * name )
- {
- itsNextName = name;
- }
-
- template <class T, traits::EnableIf<std::is_signed<T>::value,
- sizeof(T) < sizeof(int64_t)> = traits::sfinae> inline
- void loadValue(T & val)
- {
- search();
- val = static_cast<T>( itsIteratorStack.back().value().GetInt() );
- ++itsIteratorStack.back();
- }
-
- template <class T, traits::EnableIf<std::is_unsigned<T>::value,
- sizeof(T) < sizeof(uint64_t),
- !std::is_same<bool, T>::value> = traits::sfinae> inline
- void loadValue(T & val)
- {
- search();
- val = static_cast<T>( itsIteratorStack.back().value().GetUint() );
- ++itsIteratorStack.back();
- }
-
- void loadValue(bool & val) { search(); val = itsIteratorStack.back().value().GetBool(); ++itsIteratorStack.back(); }
-
- void loadValue(int64_t & val) { search(); val = itsIteratorStack.back().value().GetInt64(); ++itsIteratorStack.back(); }
-
- void loadValue(uint64_t & val) { search(); val = itsIteratorStack.back().value().GetUint64(); ++itsIteratorStack.back(); }
-
- void loadValue(float & val) { search(); val = static_cast<float>(itsIteratorStack.back().value().GetDouble()); ++itsIteratorStack.back(); }
-
- void loadValue(double & val) { search(); val = itsIteratorStack.back().value().GetDouble(); ++itsIteratorStack.back(); }
-
- void loadValue(std::string & val) { search(); val = itsIteratorStack.back().value().GetString(); ++itsIteratorStack.back(); }
-
- void loadValue(std::nullptr_t&) { search(); CEREAL_RAPIDJSON_ASSERT(itsIteratorStack.back().value().IsNull()); ++itsIteratorStack.back(); }
-
-
- #ifndef _MSC_VER
- private:
-
- template <class T> inline
- typename std::enable_if<sizeof(T) == sizeof(std::int32_t) && std::is_signed<T>::value, void>::type
- loadLong(T & l){ loadValue( reinterpret_cast<std::int32_t&>( l ) ); }
-
- template <class T> inline
- typename std::enable_if<sizeof(T) == sizeof(std::int64_t) && std::is_signed<T>::value, void>::type
- loadLong(T & l){ loadValue( reinterpret_cast<std::int64_t&>( l ) ); }
-
- template <class T> inline
- typename std::enable_if<sizeof(T) == sizeof(std::uint32_t) && !std::is_signed<T>::value, void>::type
- loadLong(T & lu){ loadValue( reinterpret_cast<std::uint32_t&>( lu ) ); }
-
- template <class T> inline
- typename std::enable_if<sizeof(T) == sizeof(std::uint64_t) && !std::is_signed<T>::value, void>::type
- loadLong(T & lu){ loadValue( reinterpret_cast<std::uint64_t&>( lu ) ); }
- public:
-
- template <class T> inline
- typename std::enable_if<std::is_same<T, long>::value &&
- sizeof(T) >= sizeof(std::int64_t) &&
- !std::is_same<T, std::int64_t>::value, void>::type
- loadValue( T & t ){ loadLong(t); }
-
- template <class T> inline
- typename std::enable_if<std::is_same<T, unsigned long>::value &&
- sizeof(T) >= sizeof(std::uint64_t) &&
- !std::is_same<T, std::uint64_t>::value, void>::type
- loadValue( T & t ){ loadLong(t); }
- #endif
- private:
-
- void stringToNumber( std::string const & str, long long & val ) { val = std::stoll( str ); }
-
- void stringToNumber( std::string const & str, unsigned long long & val ) { val = std::stoull( str ); }
-
- void stringToNumber( std::string const & str, long double & val ) { val = std::stold( str ); }
- public:
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value,
- !std::is_same<T, long>::value,
- !std::is_same<T, unsigned long>::value,
- !std::is_same<T, std::int64_t>::value,
- !std::is_same<T, std::uint64_t>::value,
- (sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long))> = traits::sfinae>
- inline void loadValue(T & val)
- {
- std::string encoded;
- loadValue( encoded );
- stringToNumber( encoded, val );
- }
-
- void loadSize(size_type & size)
- {
- if (itsIteratorStack.size() == 1)
- size = itsDocument.Size();
- else
- size = (itsIteratorStack.rbegin() + 1)->value().Size();
- }
-
- private:
- const char * itsNextName;
- ReadStream itsReadStream;
- std::vector<Iterator> itsIteratorStack;
- CEREAL_RAPIDJSON_NAMESPACE::Document itsDocument;
- };
-
-
-
-
-
-
- template <class T> inline
- void prologue( JSONOutputArchive &, NameValuePair<T> const & )
- { }
-
- template <class T> inline
- void prologue( JSONInputArchive &, NameValuePair<T> const & )
- { }
-
-
-
- template <class T> inline
- void epilogue( JSONOutputArchive &, NameValuePair<T> const & )
- { }
-
-
- template <class T> inline
- void epilogue( JSONInputArchive &, NameValuePair<T> const & )
- { }
-
-
-
- template <class T> inline
- void prologue( JSONOutputArchive &, DeferredData<T> const & )
- { }
-
- template <class T> inline
- void prologue( JSONInputArchive &, DeferredData<T> const & )
- { }
-
-
-
- template <class T> inline
- void epilogue( JSONOutputArchive &, DeferredData<T> const & )
- { }
-
-
- template <class T> inline
- void epilogue( JSONInputArchive &, DeferredData<T> const & )
- { }
-
-
-
- template <class T> inline
- void prologue( JSONOutputArchive & ar, SizeTag<T> const & )
- {
- ar.makeArray();
- }
-
- template <class T> inline
- void prologue( JSONInputArchive &, SizeTag<T> const & )
- { }
-
-
-
- template <class T> inline
- void epilogue( JSONOutputArchive &, SizeTag<T> const & )
- { }
-
- template <class T> inline
- void epilogue( JSONInputArchive &, SizeTag<T> const & )
- { }
-
-
-
- template <class T, traits::EnableIf<!std::is_arithmetic<T>::value,
- !traits::has_minimal_base_class_serialization<T, traits::has_minimal_output_serialization, JSONOutputArchive>::value,
- !traits::has_minimal_output_serialization<T, JSONOutputArchive>::value> = traits::sfinae>
- inline void prologue( JSONOutputArchive & ar, T const & )
- {
- ar.startNode();
- }
-
- template <class T, traits::EnableIf<!std::is_arithmetic<T>::value,
- !traits::has_minimal_base_class_serialization<T, traits::has_minimal_input_serialization, JSONInputArchive>::value,
- !traits::has_minimal_input_serialization<T, JSONInputArchive>::value> = traits::sfinae>
- inline void prologue( JSONInputArchive & ar, T const & )
- {
- ar.startNode();
- }
-
-
-
- template <class T, traits::EnableIf<!std::is_arithmetic<T>::value,
- !traits::has_minimal_base_class_serialization<T, traits::has_minimal_output_serialization, JSONOutputArchive>::value,
- !traits::has_minimal_output_serialization<T, JSONOutputArchive>::value> = traits::sfinae>
- inline void epilogue( JSONOutputArchive & ar, T const & )
- {
- ar.finishNode();
- }
-
- template <class T, traits::EnableIf<!std::is_arithmetic<T>::value,
- !traits::has_minimal_base_class_serialization<T, traits::has_minimal_input_serialization, JSONInputArchive>::value,
- !traits::has_minimal_input_serialization<T, JSONInputArchive>::value> = traits::sfinae>
- inline void epilogue( JSONInputArchive & ar, T const & )
- {
- ar.finishNode();
- }
-
-
- inline
- void prologue( JSONOutputArchive & ar, std::nullptr_t const & )
- {
- ar.writeName();
- }
-
- inline
- void prologue( JSONInputArchive &, std::nullptr_t const & )
- { }
-
-
- inline
- void epilogue( JSONOutputArchive &, std::nullptr_t const & )
- { }
-
- inline
- void epilogue( JSONInputArchive &, std::nullptr_t const & )
- { }
-
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
- void prologue( JSONOutputArchive & ar, T const & )
- {
- ar.writeName();
- }
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
- void prologue( JSONInputArchive &, T const & )
- { }
-
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
- void epilogue( JSONOutputArchive &, T const & )
- { }
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
- void epilogue( JSONInputArchive &, T const & )
- { }
-
-
- template<class CharT, class Traits, class Alloc> inline
- void prologue(JSONOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const &)
- {
- ar.writeName();
- }
-
- template<class CharT, class Traits, class Alloc> inline
- void prologue(JSONInputArchive &, std::basic_string<CharT, Traits, Alloc> const &)
- { }
-
-
- template<class CharT, class Traits, class Alloc> inline
- void epilogue(JSONOutputArchive &, std::basic_string<CharT, Traits, Alloc> const &)
- { }
-
- template<class CharT, class Traits, class Alloc> inline
- void epilogue(JSONInputArchive &, std::basic_string<CharT, Traits, Alloc> const &)
- { }
-
-
-
-
- template <class T> inline
- void CEREAL_SAVE_FUNCTION_NAME( JSONOutputArchive & ar, NameValuePair<T> const & t )
- {
- ar.setNextName( t.name );
- ar( t.value );
- }
- template <class T> inline
- void CEREAL_LOAD_FUNCTION_NAME( JSONInputArchive & ar, NameValuePair<T> & t )
- {
- ar.setNextName( t.name );
- ar( t.value );
- }
-
- inline
- void CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, std::nullptr_t const & t)
- {
- ar.saveValue( t );
- }
-
- inline
- void CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, std::nullptr_t & t)
- {
- ar.loadValue( t );
- }
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
- void CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, T const & t)
- {
- ar.saveValue( t );
- }
-
- template <class T, traits::EnableIf<std::is_arithmetic<T>::value> = traits::sfinae> inline
- void CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, T & t)
- {
- ar.loadValue( t );
- }
-
- template<class CharT, class Traits, class Alloc> inline
- void CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
- {
- ar.saveValue( str );
- }
-
- template<class CharT, class Traits, class Alloc> inline
- void CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
- {
- ar.loadValue( str );
- }
-
-
- template <class T> inline
- void CEREAL_SAVE_FUNCTION_NAME( JSONOutputArchive &, SizeTag<T> const & )
- {
-
- }
-
- template <class T> inline
- void CEREAL_LOAD_FUNCTION_NAME( JSONInputArchive & ar, SizeTag<T> & st )
- {
- ar.loadSize( st.size );
- }
- }
- CEREAL_REGISTER_ARCHIVE(cereal::JSONInputArchive)
- CEREAL_REGISTER_ARCHIVE(cereal::JSONOutputArchive)
- CEREAL_SETUP_ARCHIVE_TRAITS(cereal::JSONInputArchive, cereal::JSONOutputArchive)
- #endif
|