8 #define SCARAB_API_EXPORTS 19 using std::stringstream;
23 LOGGER( slog,
"param_yaml" );
37 YAML::Node root_node = YAML::LoadFile( a_filename );
40 catch( YAML::Exception& e )
42 LERROR( slog,
"YAML error: " << e.what() );
51 YAML::Node root_node = YAML::Load( a_string );
54 catch( YAML::Exception& e )
56 LERROR( slog,
"YAML error: " << e.what() );
67 LDEBUG( slog,
"YAML null" << a_node );
70 if( a_node.IsScalar() )
72 LDEBUG( slog,
"YAML scalar" << a_node );
75 if( a_node.IsSequence() )
77 LDEBUG( slog,
"YAML sequence" << a_node );
82 LDEBUG( slog,
"YAML map" << a_node );
86 catch( YAML::Exception& e )
88 LERROR(slog,
"YAML error in read_node_type: " << e.what());
89 throw error() <<
"YAML error: " << e.
what();
91 LDEBUG( slog,
"YAML unknown" );
92 throw error() <<
"Unknown YAML encountered";
102 for( YAML::const_iterator counter = a_node.begin(); counter != a_node.end(); ++counter )
107 return t_config_array;
109 catch( YAML::Exception& e )
111 LERROR( slog,
"YAML error in sequence_handler: " << e.what() );
122 for( YAML::const_iterator counter = a_node.begin(); counter != a_node.end(); ++counter )
127 return t_config_object;
129 catch( YAML::Exception& e )
131 LERROR( slog,
"YAML error in map_handler: " << e.what() );
143 catch ( YAML::Exception& e )
145 LERROR( slog,
"YAML error in scalar_handler: " << e.what() )
161 if( a_filename.empty() )
163 LERROR( slog,
"Filename cannot be an empty string" );
167 FILE* file = fopen( a_filename.c_str(),
"w" );
171 LERROR( slog,
"Unable to open file: " << a_filename );
177 std::ofstream fout( a_filename.c_str() );
188 std::stringstream t_out;
190 a_string = t_out.str();
201 else if( a_to_write.
is_node() )
213 LWARN( slog,
"Unknown param type encountered" );
235 for (
int count = 0; count != (int) array.
size(); ++count )
250 return t_node = value.
as_bool();
255 return t_node = value.
as_uint();
265 return t_node = value.
as_int();
273 LWARN( slog,
"Unkown value type encountered" );
virtual bool is_node() const
void replace(const std::string &a_name, const param &a_value)
creates a copy of a_value
REGISTER_PARAM_INPUT_CODEC(param_input_json,"json")
REGISTER_PARAM_OUTPUT_CODEC(param_output_json,"json")
virtual bool write_string(const param &a_to_write, std::string &a_string, const param_node *a_options=nullptr)
virtual bool is_value() const
virtual const char * what() const
virtual bool write_file(const param &a_to_write, const std::string &a_filename, const param_node *a_options=nullptr)
Contains the logger class and macros, based on Kasper's KLogger class.
contents::const_iterator const_iterator
YAML::Node param_value_handler(const param &a_to_write)
const param * at(unsigned a_index) const
virtual bool is_null() const
virtual ~param_output_yaml()
YAML::Node param_array_handler(const param &a_to_write)
const std::string & as_string() const
void push_back(const param &a_value)
YAML::Node check_param_type(const param &a_to_write)
virtual bool is_array() const
YAML::Node param_node_handler(const param &a_to_write)
LOGGER(mtlog,"authentication")