|
Functionality designed for use by those requiring control over the inner mechanisms of the XMLInputArchive
|
template<class T > |
| value |
| Loads a type best represented as an int from the current top node. More...
|
|
void | startNode () |
| Prepares to start reading the next node. More...
|
|
void | finishNode () |
| Finishes reading the current node. More...
|
|
const char * | getNodeName () const |
|
void | setNextName (const char *name) |
| Sets the name for the next node created with startNode. More...
|
|
template<class T , traits::EnableIf< std::is_unsigned< T >::value, std::is_same< T, bool >::value > = traits::sfinae> |
void | loadValue (T &value) |
| Loads a bool from the current top node. More...
|
|
template<class T , traits::EnableIf< std::is_integral< T >::value, !std::is_same< T, bool >::value, sizeof(T)==sizeof(char)> = traits::sfinae> |
void | loadValue (T &value) |
| Loads a char (signed or unsigned) from the current top node. More...
|
|
void | loadValue (int8_t &value) |
| Load an int8_t from the current top node (ensures we parse entire number) More...
|
|
void | loadValue (uint8_t &value) |
| Load a uint8_t from the current top node (ensures we parse entire number) More...
|
|
template<class T , traits::EnableIf< std::is_unsigned< T >::value, !std::is_same< T, bool >::value, !std::is_same< T, char >::value, !std::is_same< T, unsigned char >::value, sizeof(T)< sizeof(long long)>=traits::sfinae > inline void loadValue(T &value) { value=static_cast< T >(std::stoul(itsNodes.top().node->value()));} template< class T, traits::EnableIf< std::is_unsigned< T >::value, !std::is_same< T, bool >::value, sizeof(T) >=sizeof(long long)> = traits::sfinae> |
void | loadValue (T &value) |
| Loads a type best represented as an unsigned long from the current top node. More...
|
|
| if (std::fpclassify(value) !=FP_SUBNORMAL) throw |
|
void | loadValue (long double &value) |
| Loads a type best represented as a long double from the current top node. More...
|
|
template<class CharT , class Traits , class Alloc > |
void | loadValue (std::basic_string< CharT, Traits, Alloc > &str) |
| Loads a string from the current node from the current top node. More...
|
|
template<class T > |
void | loadSize (T &value) |
| Loads the size of the current top node. More...
|
|
static size_t | getNumChildren (rapidxml::xml_node<> *node) |
| Gets the number of children (usually interpreted as size) for the specified node. More...
|
|
An output archive designed to load data from XML.
This archive uses RapidXML to build an in memory XML tree of the data in the stream it is given before loading any types serialized.
As with the output XML archive, the preferred way to use this archive is in an RAII fashion, ensuring its destruction after all data has been read.
Input XML should have been produced by the XMLOutputArchive. Data can only be added to dynamically sized containers - the input archive will determine their size by looking at the number of child nodes. Data that did not originate from an XMLOutputArchive is not officially supported, but may be possible to use if properly formatted.
The XMLInputArchive does not require that nodes are loaded in the same order they were saved by XMLOutputArchive. Using name value pairs (NVPs), it is possible to load in an out of order fashion or otherwise skip/select specific nodes to load.
The default behavior of the input archive is to read sequentially starting with the first node and exploring its children. When a given NVP does not match the read in name for a node, the archive will search for that node at the current level and load it if it exists. After loading an out of order node, the archive will then proceed back to loading sequentially from its new position.
Consider this simple example where loading of some data is skipped:
ar( someData1, someData2, someData3 );
ar( cereal::make_nvp( "hello", someData6 ) );
ar( someData7, someData8, someData9 );
template<class T , traits::EnableIf< std::is_unsigned< T >::value, !std::is_same< T, bool >::value, !std::is_same< T, char >::value, !std::is_same< T, unsigned char >::value, sizeof(T)< sizeof(long long)>=traits::sfinae > inline void loadValue(T &value) { value=static_cast< T >(std::stoul(itsNodes.top().node->value()));} template< class T, traits::EnableIf< std::is_unsigned< T >::value, !std::is_same< T, bool >::value, sizeof(T) >=sizeof(long long)> = traits::sfinae>
void cereal::XMLInputArchive::loadValue |
( |
T & |
value | ) |
|
|
inline |
Loads a type best represented as an unsigned long from the current top node.
void cereal::XMLInputArchive::startNode |
( |
| ) |
|
|
inline |
Prepares to start reading the next node.
This places the next node to be parsed onto the nodes stack.
By default our strategy is to start with the document root node and then recursively iterate through all children in the order they show up in the document. We don't need to know NVPs do to this; we'll just blindly load in the order things appear in.
We check to see if the specified NVP matches what the next automatically loaded node is. If they match, we just continue as normal, going in order. If they don't match, we attempt to find a node named after the NVP that is being loaded. If that NVP does not exist, we throw an exception.