Unravel Engine C++ Reference
Loading...
Searching...
No Matches
ser20::YAMLOutputArchive Class Reference

#include <yaml.hpp>

Inheritance diagram for ser20::YAMLOutputArchive:

Public Member Functions

 YAMLOutputArchive (std::ostream &stream)
 
 ~YAMLOutputArchive () noexcept
 
void saveBinaryValue (const void *data, size_t size, const char *name=nullptr)
 Saves some binary data, encoded as a base64 string, with an optional name.
 

Static Public Attributes

static constexpr bool is_binary = false
 

Internal Functionality

Functionality designed for use by those requiring control over the inner mechanisms of the YAMLOutputArchive

void startNode ()
 Starts a new node in the YAML output.
 
void finishNode ()
 Designates the most recently added node as finished.
 
void setNextName (const char *name)
 Sets the name for the next node created with startNode.
 
void saveValue (bool b)
 Saves a bool to the current node.
 
void saveValue (int i)
 Saves an int to the current node.
 
void saveValue (unsigned u)
 Saves a uint to the current node.
 
void saveValue (int64_t i64)
 Saves an int64 to the current node.
 
void saveValue (uint64_t u64)
 Saves a uint64 to the current node.
 
void saveValue (double d)
 Saves a double to the current node.
 
void saveValue (std::string const &s)
 Saves a string to the current node.
 
void saveValue (char const *s)
 Saves a const char * to the current node.
 
void saveValue (std::nullptr_t)
 Saves a nullptr to the current node.
 
template<class T >
requires (std::is_same_v<T, long> && !std::is_same_v<T, int> && !std::is_same_v<T, std::int64_t>)
void saveValue (T t)
 Serialize a long if it would not be caught otherwise.
 
template<class T >
requires (std::is_same_v<T, unsigned long> && !std::is_same_v<T, unsigned> && !std::is_same_v<T, std::uint64_t>)
void saveValue (T t)
 Serialize an unsigned long if it would not be caught otherwise.
 
template<class T >
requires (std::is_arithmetic_v<T> && !std::is_same_v<T, long> && !std::is_same_v<T, unsigned long> && !std::is_same_v<T, std::int64_t> && !std::is_same_v<T, std::uint64_t> && !std::is_same_v<T, long long> && !std::is_same_v<T, unsigned long long> && (sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long)))
void saveValue (T const &t)
 Save exotic arithmetic as strings to current node.
 
void writeName ()
 Write the name of the upcoming node and prepare object/array state.
 
void makeArray ()
 Designates that the current node should be output as an array, not an object.
 

Detailed Description

Definition at line 48 of file yaml.hpp.

Constructor & Destructor Documentation

◆ YAMLOutputArchive()

ser20::YAMLOutputArchive::YAMLOutputArchive ( std::ostream & stream)
inline

Definition at line 63 of file yaml.hpp.

◆ ~YAMLOutputArchive()

ser20::YAMLOutputArchive::~YAMLOutputArchive ( )
inlinenoexcept

Definition at line 69 of file yaml.hpp.

Member Function Documentation

◆ finishNode()

void ser20::YAMLOutputArchive::finishNode ( )
inline

Designates the most recently added node as finished.

Definition at line 114 of file yaml.hpp.

◆ makeArray()

void ser20::YAMLOutputArchive::makeArray ( )
inline

Designates that the current node should be output as an array, not an object.

Definition at line 320 of file yaml.hpp.

◆ saveBinaryValue()

void ser20::YAMLOutputArchive::saveBinaryValue ( const void * data,
size_t size,
const char * name = nullptr )
inline

Saves some binary data, encoded as a base64 string, with an optional name.

This will create a new node, optionally named, and insert a value that consists of the data encoded as a base64 string

Definition at line 86 of file yaml.hpp.

◆ saveValue() [1/12]

void ser20::YAMLOutputArchive::saveValue ( bool b)
inline

Saves a bool to the current node.

Definition at line 146 of file yaml.hpp.

◆ saveValue() [2/12]

void ser20::YAMLOutputArchive::saveValue ( char const * s)
inline

Saves a const char * to the current node.

Definition at line 181 of file yaml.hpp.

◆ saveValue() [3/12]

void ser20::YAMLOutputArchive::saveValue ( double d)
inline

Saves a double to the current node.

Definition at line 171 of file yaml.hpp.

◆ saveValue() [4/12]

void ser20::YAMLOutputArchive::saveValue ( int i)
inline

Saves an int to the current node.

Definition at line 151 of file yaml.hpp.

◆ saveValue() [5/12]

void ser20::YAMLOutputArchive::saveValue ( int64_t i64)
inline

Saves an int64 to the current node.

Definition at line 161 of file yaml.hpp.

◆ saveValue() [6/12]

void ser20::YAMLOutputArchive::saveValue ( std::nullptr_t )
inline

Saves a nullptr to the current node.

Definition at line 186 of file yaml.hpp.

◆ saveValue() [7/12]

void ser20::YAMLOutputArchive::saveValue ( std::string const & s)
inline

Saves a string to the current node.

Definition at line 176 of file yaml.hpp.

◆ saveValue() [8/12]

template<class T >
requires (std::is_arithmetic_v<T> && !std::is_same_v<T, long> && !std::is_same_v<T, unsigned long> && !std::is_same_v<T, std::int64_t> && !std::is_same_v<T, std::uint64_t> && !std::is_same_v<T, long long> && !std::is_same_v<T, unsigned long long> && (sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long)))
void ser20::YAMLOutputArchive::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

Definition at line 256 of file yaml.hpp.

◆ saveValue() [9/12]

template<class T >
requires (std::is_same_v<T, long> && !std::is_same_v<T, int> && !std::is_same_v<T, std::int64_t>)
void ser20::YAMLOutputArchive::saveValue ( T t)
inline

Serialize a long if it would not be caught otherwise.

Definition at line 237 of file yaml.hpp.

◆ saveValue() [10/12]

template<class T >
requires (std::is_same_v<T, unsigned long> && !std::is_same_v<T, unsigned> && !std::is_same_v<T, std::uint64_t>)
void ser20::YAMLOutputArchive::saveValue ( T t)
inline

Serialize an unsigned long if it would not be caught otherwise.

Definition at line 245 of file yaml.hpp.

◆ saveValue() [11/12]

void ser20::YAMLOutputArchive::saveValue ( uint64_t u64)
inline

Saves a uint64 to the current node.

Definition at line 166 of file yaml.hpp.

◆ saveValue() [12/12]

void ser20::YAMLOutputArchive::saveValue ( unsigned u)
inline

Saves a uint to the current node.

Definition at line 156 of file yaml.hpp.

◆ setNextName()

void ser20::YAMLOutputArchive::setNextName ( const char * name)
inline

Sets the name for the next node created with startNode.

Definition at line 140 of file yaml.hpp.

◆ startNode()

void ser20::YAMLOutputArchive::startNode ( )
inline

Starts a new node in the YAML output.

The node can optionally be given a name by calling setNextName prior to creating the node

Nodes only need to be started for types that are themselves objects or arrays

Definition at line 106 of file yaml.hpp.

◆ writeName()

void ser20::YAMLOutputArchive::writeName ( )
inline

Write the name of the upcoming node and prepare object/array state.

Since writeName is called for every value that is output, regardless of whether it has a name or not, it is the place where we will do a deferred check of our node state and decide whether we are in an array or an object.

The general workflow of saving to the YAML archive is:

  1. (optional) Set the name for the next node to be created, usually done by an NVP
  2. Start the node
  3. (if there is data to save) Write the name of the node (this function)
  4. (if there is data to save) Save the data (with saveValue)
  5. Finish the node

Definition at line 281 of file yaml.hpp.

Member Data Documentation

◆ is_binary

bool ser20::YAMLOutputArchive::is_binary = false
inlinestaticconstexpr

Definition at line 61 of file yaml.hpp.


The documentation for this class was generated from the following file: