cereal::XMLInputArchive(3) Library Functions Manual cereal::XMLInputArchive(3)

# [NAME](#NAME)

cereal::XMLInputArchive - An output archive designed to load data from XML.

# [SYNOPSIS](#SYNOPSIS)

#include &lt;/home/build/include/cereal/archives/xml.hpp&gt;

Inherits **cereal::InputArchive&lt; XMLInputArchive &gt;**, and **cereal::traits::TextArchive**.

## [Classes](#Classes)

struct **NodeInfo**  
A struct that contains metadata about a node.

## [Public Member Functions](#Public_Member_Functions)

**Common Functionality**  
Common use cases for directly interacting with an **XMLInputArchive**

**XMLInputArchive** (std::istream &stream)  
Construct, reading in from the provided stream. void **loadBinaryValue** (void \*data, size\_t size, const char \*name=nullptr)  
Loads some binary data, encoded as a base64 string, optionally specified by some name.

Public Member Functions inherited from **cereal::InputArchive&lt; XMLInputArchive &gt;**  
**InputArchive** (**XMLInputArchive** \*const derived)  
Construct the output archive. **InputArchive** & **operator=** (**InputArchive** const &)=delete  
**XMLInputArchive** & **operator()** (Types &&... args)  
Serializes all passed in data. void **serializeDeferments** ()  
Serializes any data marked for deferment using defer. std::shared\_ptr&lt; void &gt; **getSharedPointer** (std::uint32\_t const id)  
Retrieves a shared pointer given a unique key for it. void **registerSharedPointer** (std::uint32\_t const id, std::shared\_ptr&lt; void &gt; ptr)  
Registers a shared pointer to its unique identifier. std::string **getPolymorphicName** (std::uint32\_t const id)  
Retrieves the string for a polymorphic type given a unique key for it. void **registerPolymorphicName** (std::uint32\_t const id, std::string const &name)  
Registers a polymorphic name string to its unique identifier.

**XMLInputArchive** & **operator&** (T &&arg)  
Serializes passed in data.

**XMLInputArchive** & **operator&gt;&gt;** (T &&arg)  
Serializes passed in data.

Public Member Functions inherited from **cereal::detail::InputArchiveBase**  
**InputArchiveBase** (InputArchiveBase &&) **CEREAL\_NOEXCEPT**  
InputArchiveBase & **operator=** (InputArchiveBase &&) **CEREAL\_NOEXCEPT**

## [Internal Functionality](#Internal_Functionality)

Functionality designed for use by those requiring control over the inner mechanisms of the **XMLInputArchive**  
template&lt;class T, traits::EnableIf&lt; std::is\_unsigned&lt; T &gt;::value, !std::is\_same&lt; T, bool &gt;::value, !std::is\_same&lt; T, char &gt;::value, !std::is\_same&lt; T, unsigned char &gt;::value, sizeof(T)&lt; sizeof(long long)&gt;=traits::sfinae &gt; inline void **loadValue**(T &value) { value=static\_cast&lt; T &gt;(std::stoul(itsNodes.top().node-&gt;value()));} template&lt; class T, traits::EnableIf&lt; std::is\_unsigned&lt; T &gt;::value, !std::is\_same&lt; T, bool &gt;::value, sizeof(T) &gt;=sizeof(long long)&gt; = traits::sfinae&gt; **value**  
Loads a type best represented as an unsigned long from the current top node. void **startNode** ()  
Prepares to start reading the next node. void **finishNode** ()  
Finishes reading the current node. const char * **getNodeName** () const  
void **setNextName** (const char \*name)  
Sets the name for the next node created with startNode. template&lt;class T, traits::EnableIf&lt; std::is\_unsigned&lt; T &gt;**::value**, std::is\_same&lt; T, bool &gt;**::value** &gt; = traits::sfinae&gt; void **loadValue** (T &value)  
Loads a bool from the current top node. template&lt;class T, traits::EnableIf&lt; std::is\_integral&lt; T &gt;**::value**, !std::is\_same&lt; T, bool &gt;**::value**, sizeof(T)==sizeof(char)&gt; = traits::sfinae&gt; void **loadValue** (T &value)  
Loads a char (signed or unsigned) from the current top node. void **loadValue** (int8\_t &value)  
Load an int8\_t from the current top node (ensures we parse entire number). void **loadValue** (uint8\_t &value)  
Load a uint8\_t from the current top node (ensures we parse entire number). **if** (std::fpclassify(**value**) !=FP\_SUBNORMAL) throw  
void **loadValue** (double &value)  
Loads a type best represented as a double from the current top node. void **loadValue** (long double &value)  
Loads a type best represented as a long double from the current top node. template&lt;class CharT, class Traits, class Alloc&gt; void **loadValue** (std::basic\_string&lt; CharT, Traits, Alloc &gt; &str)  
Loads a string from the current node from the current top node. template&lt;class T&gt; void **loadSize** (T &value)  
Loads the size of the current top node. static size\_t **getNumChildren** (rapidxml::xml\_node&lt;&gt; \*node)  
Gets the number of children (usually interpreted as size) for the specified node.

## [Additional Inherited Members](#Additional_Inherited_Members)

using **is\_loading**  
Indicates this archive is intended for loading.

using **is\_saving**  
Indicates this archive is not intended for saving.

# [Detailed Description](#Detailed_Description)

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)](/man/enterprise-packages/cereal/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:

```
// imagine the input file has someData(1-9) saved in order at the top level node
ar( someData1, someData2, someData3 );        // XML loads in the order it sees in the file
ar( cereal::make_nvp( "hello", someData6 ) ); // NVP given does not


                                              // match expected NVP name, so we search


                                              // for the given NVP and load that value
ar( someData7, someData8, someData9 );        // with no NVP given, loading resumes at its


                                              // current location, proceeding sequentially
```

# [Constructor & Destructor Documentation](#Constructor_&_Destructor_Documentation)

## [cereal::XMLInputArchive::XMLInputArchive (std::istream & stream) \[inline\]](#cereal::XMLInputArchive::XMLInputArchive_%28std::istream_&_stream%29)

Construct, reading in from the provided stream. Reads in an entire XML document from some stream and parses it as soon as serialization starts

**Parameters**

*stream* The stream to read from. Can be a stringstream or a file.

# [Member Function Documentation](#Member_Function_Documentation)

## [const char * cereal::XMLInputArchive::getNodeName () const \[inline\]](#const_char_*_cereal::XMLInputArchive::getNodeName_%28%29_const)

Retrieves the current node name will return nullptr if the node does not have a name

## [void cereal::XMLInputArchive::loadBinaryValue (void * data, size\_t size, const char * name = nullptr) \[inline\]](#void_cereal::XMLInputArchive::loadBinaryValue_%28void_*_data,_size_t_size,_const_char_*_name_=_)

Loads some binary data, encoded as a base64 string, optionally specified by some name. This will automatically start and finish a node to load the data, and can be called directly by users.

Note that this follows the same ordering rules specified in the class description in regards to loading in/out of order

## [void cereal::XMLInputArchive::startNode () \[inline\]](#void_cereal::XMLInputArchive::startNode_%28%29)

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.

# [Member Data Documentation](#Member_Data_Documentation)

## [template&lt;class T, traits::EnableIf&lt; std::is\_unsigned&lt; T &gt;::value, !std::is\_same&lt; T, bool &gt;::value, !std::is\_same&lt; T, char &gt;::value, !std::is\_same&lt; T, unsigned char &gt;::value, sizeof(T)&lt; sizeof(long long)&gt;=traits::sfinae &gt; inline void **loadValue**(T &value) { value=static\_cast&lt; T &gt;(std::stoul(itsNodes.top().node-&gt;value()));} template&lt; class T, traits::EnableIf&lt; std::is\_unsigned&lt; T &gt;::value, !std::is\_same&lt; T, bool &gt;::value, sizeof(T) &gt;=sizeof(long long)&gt; = traits::sfinae&gt; cereal::XMLInputArchive::value](#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%28T%29__sizeof%28long_long%29_=traits::sfinae___inline_void_)

Loads a type best represented as an unsigned long from the current top node.

**Template Parameters**

*traits::EnableIf&lt;* std::is\_unsigned&lt; T &gt;::value, !std::is\_same&lt; T, bool &gt;::value, !std::is\_same&lt; T, char &gt;::value, !std::is\_same&lt; T, unsigned char &gt;::value, sizeof(T)&lt; sizeof(long long)&gt;=traits::sfinae &gt; inline void **loadValue(T &value)** { value=static\_cast&lt; T &gt;(std::stoul(itsNodes.top().node-&gt;**value()**));} template&lt; class T, traits::EnableIf&lt; std::is\_unsigned&lt; T &gt;::value, !std::is\_same&lt; T, bool &gt;::value, sizeof(T) &gt;=sizeof(long long)&gt; Loads a type best represented as an unsigned long long from the current top node

# [Author](#Author)

Generated automatically by Doxygen for cereal from the source code.

Mon Oct 26 2026 20:39:03 cereal

---

Document: cereal_XMLInputArchive(3) from cereal 1.3.2-r8 (Chainguard OS)
Source: https://github.com/USCiLab/cereal
