GenericContainer
GenericContainer a tool for C++ programming
Loading...
Searching...
No Matches
GenericContainerInterface_yaml.hh
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*\
2 | |
3 | Copyright (C) 2013 |
4 | |
5 | , __ , __ |
6 | /|/ \ /|/ \ |
7 | | __/ _ ,_ | __/ _ ,_ |
8 | | \|/ / | | | | \|/ / | | | |
9 | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ |
10 | /| /| |
11 | \| \| |
12 | |
13 | Enrico Bertolazzi |
14 | Dipartimento di Ingegneria Industriale |
15 | Università degli Studi di Trento |
16 | email: enrico.bertolazzi@unitn.it |
17 | |
18\*--------------------------------------------------------------------------*/
19
20#pragma once
21
22#ifndef GENERIC_CONTAINER_INTERFACE_YAML_HH
23#define GENERIC_CONTAINER_INTERFACE_YAML_HH
24
25#ifdef __clang__
26#pragma clang diagnostic ignored "-Wpoison-system-directories"
27#endif
28
29#include "GenericContainer.hh"
30
31#include <fstream>
32
33namespace GC_namespace {
34
35 using std::ifstream;
36
41
52 inline
53 bool
55 string_view file_name,
57 ) {
58 ifstream stream(file_name.data());
59 gc.clear();
60 return gc.from_yaml( stream );
61 }
62
73 inline
74 bool
76 istream_type & stream,
78 ) {
79 gc.clear();
80 return gc.from_yaml( stream );
81 }
82
93 inline
94 bool
96 string const & DATA,
98 ) {
99 istringstream stream(DATA);
100 gc.clear();
101 return gc.from_yaml(stream);
102 }
103
114 inline
115 void
116 GC_to_YAML( GenericContainer const & gc, std::string & res ) {
117 ostringstream stream;
118 gc.to_yaml( stream );
119 res = stream.str();
120 }
121
131 inline
132 void
134 GenericContainer const & gc,
135 ostream_type & stream
136 ) {
137 gc.to_yaml( stream );
138 }
139
143}
144
145#endif
The GenericContainer class provides a flexible container for storing heterogeneous data types.
Definition GenericContainer.hh:614
void to_yaml(ostream_type &stream, string_view prefix="") const
Serializes the contents of the GenericContainer into YAML format and writes it to the provided output...
void clear()
Clears the content of the GenericContainer, resetting it to an empty state.
Definition GenericContainer.cc:592
bool from_yaml(istream_type &stream)
Loads the contents of the GenericContainer from a YAML-formatted stream.
void GC_to_YAML(GenericContainer const &gc, std::string &res)
Definition GenericContainerInterface_yaml.hh:116
bool file_YAML_to_GC(string_view file_name, GenericContainer &gc)
Definition GenericContainerInterface_yaml.hh:54
bool YAML_to_GC(istream_type &stream, GenericContainer &gc)
Definition GenericContainerInterface_yaml.hh:75
Definition GenericContainer.cc:68
std::basic_ostream< char > ostream_type
Alias for a character-based output stream.
Definition GenericContainer.hh:109
std::basic_istream< char > istream_type
Alias for a character-based input stream.
Definition GenericContainer.hh:118