![]() |
GenericContainer
GenericContaine a tool for C++ programming
|
This module provides interface with YAML files. More...
Functions | |
bool | GC_namespace::file_YAML_to_GC (string const &file_name_YAML, GenericContainer &gc) |
bool | GC_namespace::YAML_to_GC (istream_type &file_YAML, GenericContainer &gc) |
bool | GC_namespace::YAML_to_GC (string const &YAML, GenericContainer &gc) |
bool | GC_namespace::YAML_to_GC (vector< string > const &YAML, GenericContainer &gc) |
void | GC_namespace::GC_to_YAML (GenericContainer const &gc, vector< string > &YAML) |
void | GC_namespace::GC_to_YAML (GenericContainer const &gc, ostream_type &file_YAML) |
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.
The GC_to_YAML
function converts the contents of a GenericContainer
into a vector of YAML strings.
Example:
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:
bool GC_namespace::file_YAML_to_GC | ( | string const & | file_name_YAML, |
GenericContainer & | gc ) |
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_YAML | Input file name containing YAML data. |
[out] | gc | The GenericContainer to be populated. |
void GC_namespace::GC_to_YAML | ( | GenericContainer const & | gc, |
ostream_type & | file_YAML ) |
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] | file_YAML | Output stream to write the YAML data. |
void GC_namespace::GC_to_YAML | ( | GenericContainer const & | gc, |
vector< string > & | YAML ) |
Convert a GenericContainer
to a vector of YAML strings.
This function converts the contents of the provided GenericContainer
into YAML format and stores it in the specified vector.
[in] | gc | The GenericContainer to convert. |
[out] | YAML | Vector to store the resulting YAML strings. |
bool GC_namespace::YAML_to_GC | ( | istream_type & | file_YAML, |
GenericContainer & | gc ) |
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] | file_YAML | Input stream containing YAML data. |
[out] | gc | The GenericContainer to be populated. |
bool GC_namespace::YAML_to_GC | ( | string const & | YAML, |
GenericContainer & | gc ) |
Convert a YAML string to a GenericContainer
.
This function parses the given YAML string and populates the specified GenericContainer
with the resulting data.
[in] | YAML | The YAML string to parse. |
[out] | gc | The GenericContainer to be populated. |
bool GC_namespace::YAML_to_GC | ( | vector< string > const & | YAML, |
GenericContainer & | gc ) |
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] | YAML | Vector containing YAML strings to parse. |
[out] | gc | The GenericContainer to be populated. |