This module provides interface with YAML files. More...
Functions | |
bool | GC_namespace::file_YAML_to_GC (string_view file_name, GenericContainer &gc) |
bool | GC_namespace::YAML_to_GC (istream_type &stream, GenericContainer &gc) |
bool | GC_namespace::YAML_to_GC (string const &DATA, GenericContainer &gc) |
void | GC_namespace::GC_to_YAML (GenericContainer const &gc, std::string &res) |
void | GC_namespace::GC_to_YAML (GenericContainer const &gc, ostream_type &stream) |
This module provides interface with YAML files.
The GenericContainer (GC) module offers a flexible container for storing various data types such as booleans, integers, floating-point numbers, complex numbers, and strings. It also supports structured data types such as vectors and maps. The C++ interface allows for seamless interaction with the container, enabling users to perform operations like adding elements, retrieving data, and managing hierarchical structures.
This tutorial explains how to use the GenericContainer YAML interface for converting between YAML data and the GenericContainer object.
The GenericContainer is a flexible structure that can store various data types like booleans, integers, floating-point numbers, complex numbers, strings, vectors, and maps. The interface provides multiple ways to convert YAML files, streams, or strings into GenericContainer objects and vice versa.
There are several ways to load YAML data into a GenericContainer.
The file_YAML_to_GC function reads YAML data from a file and populates a GenericContainer. This is useful for handling configuration files or other data stored in YAML format.
Example:
The YAML_to_GC function allows loading YAML data from an input stream, such as a file stream or a string stream.
Example:
You can convert a YAML string directly into a GenericContainer using the YAML_to_GC function.
Example:
If you have multiple YAML strings in a vector, you can load them into a GenericContainer using the YAML_to_GC function.
Example:
You can also convert a GenericContainer back to YAML format.
You can write the contents of a GenericContainer to an output stream (e.g., a file) in YAML format using the GC_to_YAML function.
Example:
|
inline |
Convert a YAML file to a GenericContainer.
This function reads YAML data from the provided input stream and populates the given GenericContainer with the parsed data.
[in] | file_name | Input file name containing YAML data. |
[out] | gc | The GenericContainer to be populated. |
|
inline |
Convert a GenericContainer to a YAML file stream.
This function converts the contents of the provided GenericContainer into YAML format and writes it to the specified output stream.
[in] | gc | The GenericContainer to convert. |
[out] | stream | Output stream to write the YAML data. |
|
inline |
Convert a vector of YAML strings to a GenericContainer.
This function parses each string in the given vector as YAML and populates the specified GenericContainer with the resulting data.
[in] | gc | The GenericContainer to convert. |
[out] | DATA | String to store the YAML encoded GenericContainer. |
|
inline |
Convert a YAML file stream to a GenericContainer.
This function reads YAML data from the provided input stream and populates the given GenericContainer with the parsed data.
[in] | stream | Input stream containing YAML data. |
[out] | gc | The GenericContainer to be populated. |
|
inline |
Convert a YAML string to a GenericContainer.
This function parses the given YAML string and populates the specified GenericContainer with the resulting data.
[in] | DATA | The YAML string to parse. |
[out] | gc | The GenericContainer to be populated. |