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() );
69 if( a_node.IsScalar() )
73 if( a_node.IsSequence() )
82 catch( YAML::Exception& e )
84 LERROR(slog,
"YAML error in read_node_type: " << e.what());
85 throw error() <<
"YAML error: " << e.
what();
87 LDEBUG( slog,
"YAML unknown" );
88 throw error() <<
"Unknown YAML encountered";
98 for( YAML::const_iterator counter = a_node.begin(); counter != a_node.end(); ++counter )
103 return t_config_array;
105 catch( YAML::Exception& e )
107 LERROR( slog,
"YAML error in sequence_handler: " << e.what() );
118 for( YAML::const_iterator counter = a_node.begin(); counter != a_node.end(); ++counter )
123 return t_config_object;
125 catch( YAML::Exception& e )
127 LERROR( slog,
"YAML error in map_handler: " << e.what() );
139 catch ( YAML::Exception& e )
141 LERROR( slog,
"YAML error in scalar_handler: " << e.what() )
157 if( a_filename.empty() )
159 LERROR( slog,
"Filename cannot be an empty string" );
163 FILE* file = fopen( a_filename.c_str(),
"w" );
167 LERROR( slog,
"Unable to open file: " << a_filename );
173 std::ofstream fout( a_filename.c_str() );
184 std::stringstream t_out;
186 a_string = t_out.str();
197 else if( a_to_write.
is_node() )
209 LWARN( slog,
"Unknown param type encountered" );
231 for (
int count = 0; count != (int) array.
size(); ++count )
246 return t_node = value.
as_bool();
251 return t_node = value.
as_uint();
261 return t_node = value.
as_int();
269 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)
const param & at(unsigned a_index) const
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.
YAML::Node param_value_handler(const param &a_to_write)
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")