|
Functionality designed for use by those requiring control over the inner mechanisms of the JSONOutputArchive
|
void | startNode () |
| Starts a new node in the JSON output. More...
|
|
void | finishNode () |
| Designates the most recently added node as finished. More...
|
|
void | setNextName (const char *name) |
| Sets the name for the next node created with startNode. More...
|
|
void | saveValue (bool b) |
| Saves a bool to the current node. More...
|
|
void | saveValue (int i) |
| Saves an int to the current node. More...
|
|
void | saveValue (unsigned u) |
| Saves a uint to the current node. More...
|
|
void | saveValue (int64_t i64) |
| Saves an int64 to the current node. More...
|
|
void | saveValue (uint64_t u64) |
| Saves a uint64 to the current node. More...
|
|
void | saveValue (double d) |
| Saves a double to the current node. More...
|
|
void | saveValue (std::string const &s) |
| Saves a string to the current node. More...
|
|
void | saveValue (char const *s) |
| Saves a const char * to the current node. More...
|
|
void | saveValue (std::nullptr_t) |
| Saves a nullptr to the current node. More...
|
|
template<class T > |
std::enable_if<!std::is_same< T, int64_t >::value &&std::is_same< T, long long >::value, void >::type | saveValue (T val) |
|
template<class T > |
std::enable_if<!std::is_same< T, uint64_t >::value &&std::is_same< T, unsigned long long >::value, void >::type | saveValue (T val) |
|
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> |
void | saveValue (T t) |
| Serialize a long if it would not be caught otherwise. More...
|
|
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> |
void | saveValue (T t) |
| Serialize an unsigned long if it would not be caught otherwise. More...
|
|
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, !std::is_same< T, long long >::value, !std::is_same< T, unsigned long long >::value,(sizeof(T) >=sizeof(long double)||sizeof(T) >=sizeof(long long))> = traits::sfinae> |
void | saveValue (T const &t) |
| Save exotic arithmetic as strings to current node. More...
|
|
void | writeName () |
| Write the name of the upcoming node and prepare object/array state. More...
|
|
void | makeArray () |
| Designates that the current node should be output as an array, not an object. More...
|
|
template<class T , traits::EnableIf< sizeof(T)==sizeof(std::int32_t), std::is_signed< T >::value > = traits::sfinae> |
void | saveLong (T l) |
| 32 bit signed long saving to current node More...
|
|
template<class T , traits::EnableIf< sizeof(T) !=sizeof(std::int32_t), std::is_signed< T >::value > = traits::sfinae> |
void | saveLong (T l) |
| non 32 bit signed long saving to current node More...
|
|
template<class T , traits::EnableIf< sizeof(T)==sizeof(std::int32_t), std::is_unsigned< T >::value > = traits::sfinae> |
void | saveLong (T lu) |
| 32 bit unsigned long saving to current node More...
|
|
template<class T , traits::EnableIf< sizeof(T) !=sizeof(std::int32_t), std::is_unsigned< T >::value > = traits::sfinae> |
void | saveLong (T lu) |
| non 32 bit unsigned long saving to current node More...
|
|
An output archive designed to save data to JSON.
This archive uses RapidJSON to build serialize data to JSON.
JSON archives provides a human readable output but at decreased performance (both in time and space) compared to binary archives.
JSON archives are only guaranteed to finish flushing their contents upon destruction and should thus be used in an RAII fashion.
JSON benefits greatly from name-value pairs, which if present, will name the nodes in the output. If these are not present, each level of the output will be given an automatically generated delimited name.
The precision of the output archive controls the number of decimals output for floating point numbers and should be sufficiently large (i.e. at least 20) if there is a desire to have binary equality between the numbers output and those read in. In general you should expect a loss of precision when going from floating point to text and back.
JSON archives do not output the size information for any dynamically sized structure and instead infer it from the number of children for a node. This means that data can be hand edited for dynamic sized structures and will still be readable. This is accomplished through the cereal::SizeTag object, which will cause the archive to output the data as a JSON array (e.g. marked by [] instead of {}), which indicates that the container is variable sized and may be edited.
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, !std::is_same< T, long long >::value, !std::is_same< T, unsigned long long >::value,(sizeof(T) >=sizeof(long double)||sizeof(T) >=sizeof(long long))> = traits::sfinae>
void cereal::JSONOutputArchive::saveValue |
( |
T const & |
t | ) |
|
|
inline |
Save exotic arithmetic as strings to current node.
Handles long long (if distinct from other types), unsigned long (if distinct), and long double