1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
ConfigHolderStruct.hpp
Go to the documentation of this file.
1
#ifndef __STDAIR_BOM_CONFIGHOLDERSTRUCT_HPP
2
#define __STDAIR_BOM_CONFIGHOLDERSTRUCT_HPP
3
4
// //////////////////////////////////////////////////////////////////////
5
// Import section
6
// //////////////////////////////////////////////////////////////////////
7
// STL
8
#include <iosfwd>
9
#include <string>
10
// Boost
11
#include <boost/static_assert.hpp>
12
#include <boost/type_traits/is_same.hpp>
13
#if BOOST_VERSION_MACRO >= 104100
14
// Boost Property Tree
15
#include <boost/property_tree/ptree.hpp>
16
#endif
// BOOST_VERSION_MACRO >= 104100
17
// StdAir
18
#include <
stdair/stdair_file.hpp
>
19
#include <
stdair/stdair_maths_types.hpp
>
20
#include <
stdair/stdair_date_time_types.hpp
>
21
#include <
stdair/basic/StructAbstract.hpp
>
22
#include <
stdair/bom/ConfigHolderTypes.hpp
>
23
24
#if BOOST_VERSION_MACRO >= 104100
25
namespace
bpt
=
boost::property_tree
;
26
#else
// BOOST_VERSION_MACRO >= 104100
27
namespace
bpt
{
28
typedef
char
ptree
;
29
}
30
#endif
// BOOST_VERSION_MACRO >= 104100
31
32
namespace
stdair
{
33
35
class
BomRoot
;
36
40
struct
ConfigHolderStruct
:
public
StructAbstract
{
41
public
:
42
// /////////////// Getters /////////////////
43
44
// ///////////// Business Methods //////////
51
void
add
(
const
bpt::ptree
&);
52
61
bool
addValue
(
const
std::string& iValue,
62
const
std::string& iPath);
63
72
template
<
typename
ValueType>
73
bool
exportValue
(ValueType& ioValue,
const
std::string& iPath)
const
;
74
81
void
updateAirlineFeatures
(
BomRoot
&);
82
83
private
:
87
void
add
(
const
bpt::ptree
&,
88
const
std::string&);
89
90
public
:
91
// /////////// Display support method /////////////
96
void
toStream
(std::ostream& ioOut)
const
;
97
102
void
fromStream
(std::istream& ioIn);
103
107
const
std::string
describe
()
const
;
108
112
const
std::string
jsonExport
()
const
;
113
114
115
// /////////////// Constructors and Destructors /////////////////
116
public
:
120
ConfigHolderStruct
();
121
125
ConfigHolderStruct
(
const
ConfigHolderStruct
&);
126
127
public
:
131
~ConfigHolderStruct
();
132
133
134
private
:
135
// /////////////// Attributes /////////////////
139
bpt::ptree
_pt;
140
};
141
142
// ////////////////////////////////////////////////////////////////////
143
template
<
typename
ValueType>
144
bool
ConfigHolderStruct::exportValue
(ValueType& ioValue,
145
const
std::string& iPath)
const
{
146
147
bool
hasValueBeenSuccessfullyRetrieved =
true
;
148
149
#if BOOST_VERSION_MACRO >= 104100
150
try
{
151
// Get the value.
152
// If the path key is not found, an exception is thrown.
153
const
std::string lPrefix (
"config."
);
154
const
std::string lFinalPath = lPrefix + iPath;
155
ioValue = _pt.get<ValueType> (lFinalPath);
156
157
}
catch
(bpt::ptree_error& bptException) {
158
hasValueBeenSuccessfullyRetrieved =
false
;
159
}
160
#endif
// BOOST_VERSION_MACRO >= 104100
161
162
return
hasValueBeenSuccessfullyRetrieved;
163
164
}
165
166
// ////////////////////////////////////////////////////////////////////
167
//
168
// Specialization of the template method exportValue above for the type
169
// Date_T.
170
//
171
// ////////////////////////////////////////////////////////////////////
172
173
template
<>
174
inline
bool
ConfigHolderStruct::exportValue<Date_T>
175
(
Date_T
& ioValue,
176
const
std::string& iPath)
const
{
177
178
bool
hasValueBeenSuccessfullyRetrieved =
true
;
179
180
#if BOOST_VERSION_MACRO >= 104100
181
182
try
{
183
184
// Get the string date value.
185
// If the path key is not found, an exception is thrown.
186
const
std::string lPrefix (
"config."
);
187
const
std::string lFinalPath = lPrefix + iPath;
188
const
std::string& lDateStr =
189
_pt.get<std::string> (lFinalPath);
190
191
// Convert the string into a Date_T.
192
ioValue =
193
boost::gregorian::from_simple_string (lDateStr);
194
195
}
catch
(bpt::ptree_error& bptException) {
196
hasValueBeenSuccessfullyRetrieved =
false
;
197
}
198
#endif
// BOOST_VERSION_MACRO >= 104100
199
200
return
hasValueBeenSuccessfullyRetrieved;
201
202
203
}
204
205
}
206
207
#endif
// __STDAIR_BOM_CONFIGHOLDERSTRUCT_HPP
StructAbstract.hpp
ConfigHolderTypes.hpp
stdair_date_time_types.hpp
stdair_file.hpp
stdair_maths_types.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::Date_T
boost::gregorian::date Date_T
Definition
stdair_date_time_types.hpp:20
boost::property_tree
Definition
BomINIImport.cpp:23
bpt
Definition
BomJSONExport.hpp:20
bpt::ptree
char ptree
Definition
BomJSONExport.hpp:21
stdair::StructAbstract::StructAbstract
StructAbstract()
Definition
StructAbstract.hpp:49
stdair::BomRoot
Class representing the actual attributes for the Bom root.
Definition
BomRoot.hpp:32
stdair::ConfigHolderStruct::ConfigHolderStruct
ConfigHolderStruct()
Definition
ConfigHolderStruct.cpp:28
stdair::ConfigHolderStruct::describe
const std::string describe() const
Definition
ConfigHolderStruct.cpp:51
stdair::ConfigHolderStruct::add
void add(const bpt::ptree &)
Definition
ConfigHolderStruct.cpp:145
stdair::ConfigHolderStruct::exportValue
bool exportValue(ValueType &ioValue, const std::string &iPath) const
Definition
ConfigHolderStruct.hpp:144
stdair::ConfigHolderStruct::addValue
bool addValue(const std::string &iValue, const std::string &iPath)
Definition
ConfigHolderStruct.cpp:192
stdair::ConfigHolderStruct::jsonExport
const std::string jsonExport() const
Definition
ConfigHolderStruct.cpp:135
stdair::ConfigHolderStruct::updateAirlineFeatures
void updateAirlineFeatures(BomRoot &)
Definition
ConfigHolderStruct.cpp:221
stdair::ConfigHolderStruct::toStream
void toStream(std::ostream &ioOut) const
Definition
ConfigHolderStruct.cpp:42
stdair::ConfigHolderStruct::fromStream
void fromStream(std::istream &ioIn)
Definition
ConfigHolderStruct.cpp:47
stdair::ConfigHolderStruct::~ConfigHolderStruct
~ConfigHolderStruct()
Definition
ConfigHolderStruct.cpp:38
Generated for StdAir by
1.17.0