Scarab  v2.4.11
Project 8 C++ Utility Library
test_yaml.cc
Go to the documentation of this file.
1 /*
2  * test_yaml.cc
3  *
4  * Created on: Jan 19, 2016
5  * Author: bidishasen97
6  *
7  * Usage: test_yaml [filename]
8  */
9 
10 #include "param.hh"
11 #include "param_yaml.hh"
12 #include "logger.hh"
13 
14 using namespace scarab;
15 
16 LOGGER( slog, "test_yaml" );
17 
18 int main( int argc, char** argv )
19 {
20  if( argc < 2 )
21  {
22  LERROR( slog, "Please provide a YAML file to read" );
23  return -1;
24  }
25 
26  //read file
27  param_input_yaml t_input;
28  param_ptr_t t_param_location( t_input.read_file( argv[1] ) );
29  if( ! t_param_location )
30  {
31  LERROR( slog, "File did not read!" );
32  return -1;
33  }
34 
35  LINFO( slog, "File read and parsed: \n" << *t_param_location );
36 
37  //write file
38  param_output_yaml t_output;
39  bool t_did_write_file = t_output.write_file( *t_param_location, "test_output.yaml" );
40 
41  if( ! t_did_write_file )
42  {
43  LERROR( slog, "File did not write!" );
44  return -1;
45  }
46 
47  LINFO( slog, "File written successfully (test_output.yaml)" );
48  return 0;
49 }
virtual param_ptr_t read_file(const std::string &a_filename, const param_node &a_options=param_node())
Definition: param_yaml.cc:33
LOGGER(mtlog, "authentication")
#define LERROR(...)
Definition: logger.hh:370
virtual bool write_file(const param &a_to_write, const std::string &a_filename, const param_node &a_options=param_node())
Definition: param_yaml.cc:155
Contains the logger class and macros, based on Kasper&#39;s KLogger class.
Convert Param to YAML.
Definition: param_yaml.hh:62
#define LINFO(...)
Definition: logger.hh:367
Convert YAML to Param.
Definition: param_yaml.hh:34
std::unique_ptr< param > param_ptr_t
Definition: param_base.hh:23
int main(int argc, char **argv)
Definition: test_yaml.cc:18