13 #ifndef ARGOS_CONFIGURATION_H
14 #define ARGOS_CONFIGURATION_H
16 #include <argos3/core/utility/datatypes/datatypes.h>
17 #include <argos3/core/utility/configuration/argos_exception.h>
18 #include <argos3/core/utility/configuration/tinyxml/ticpp.h>
45 const std::string& str_tag)
throw() {
47 it = it.begin(&t_node);
64 const std::string& str_tag) {
67 it = it.begin(&t_node);
73 catch(ticpp::Exception& ex) {
91 t_parent_node.InsertEndChild(t_child_node);
93 catch(ticpp::Exception& ex) {
127 template <
typename T>
131 t_node.GetText(&t_buffer);
133 catch(std::exception& ex) {
151 template <
typename T>
154 const T& t_default) {
156 t_node.GetTextOrDefault(&t_buffer, t_default);
158 catch(std::exception& ex) {
173 const std::string& str_attribute) {
174 return t_node.HasAttribute(str_attribute);
207 template <
typename T>
209 const std::string& str_attribute,
212 t_node.GetAttribute(str_attribute, &t_buffer,
true);
214 catch(ticpp::Exception& ex) {
232 const std::string& str_attribute,
234 std::string strBuffer;
236 t_node.GetAttribute(str_attribute, &strBuffer,
true);
237 if(strBuffer ==
"true") {
240 else if(strBuffer ==
"false") {
244 THROW_ARGOSEXCEPTION(
"Cannot convert '" << strBuffer <<
"' into a bool. Accepted values: 'true', 'false'.");
247 catch(ticpp::Exception& ex) {
265 const std::string& str_attribute,
269 t_node.GetAttribute(str_attribute, &unTmpBuffer,
true);
270 un_buffer = unTmpBuffer;
272 catch(ticpp::Exception& ex) {
290 const std::string& str_attribute,
294 t_node.GetAttribute(str_attribute, &nTmpBuffer,
true);
295 n_buffer = nTmpBuffer;
297 catch(ticpp::Exception& ex) {
317 template <
typename T>
319 const std::string& str_attribute,
321 const T& t_default) {
323 t_node.GetAttributeOrDefault(str_attribute, &t_buffer, t_default);
325 catch(ticpp::Exception& ex) {
345 const std::string& str_attribute,
347 const bool b_default) {
348 std::string strBuffer;
349 const std::string strDefault = (b_default ?
"true" :
"false");
351 t_node.GetAttributeOrDefault(str_attribute, &strBuffer, strDefault);
352 if(strBuffer ==
"true") {
355 else if(strBuffer ==
"false") {
359 THROW_ARGOSEXCEPTION(
"Cannot convert '" << strBuffer <<
"' into a bool. Accepted values: 'true', 'false'.");
362 catch(ticpp::Exception& ex) {
382 const std::string& str_attribute,
384 const UInt8 un_default) {
387 t_node.GetAttributeOrDefault(str_attribute, &unTmpBuffer,
static_cast<UInt32>(un_default));
388 un_buffer = unTmpBuffer;
390 catch(ticpp::Exception& ex) {
410 const std::string& str_attribute,
412 const SInt8 n_default) {
415 t_node.GetAttributeOrDefault(str_attribute, &nTmpBuffer,
static_cast<SInt32>(n_default));
416 n_buffer = nTmpBuffer;
418 catch(ticpp::Exception& ex) {
433 template <
typename T>
435 const std::string& str_attribute,
437 t_node.SetAttribute(str_attribute, t_value);
452 const std::string& str_attribute,
453 const bool b_value) {
455 t_node.SetAttribute(str_attribute,
"true");
458 t_node.SetAttribute(str_attribute,
"false");
474 const std::string& str_attribute,
475 const SInt8 n_value) {
476 t_node.SetAttribute(str_attribute,
static_cast<SInt32>(n_value));
491 const std::string& str_attribute,
492 const UInt8 un_value) {
493 t_node.SetAttribute(str_attribute,
static_cast<UInt32>(un_value));