Scarab  v2.2.3
Project 8 C++ Utility Library
test_param_node.cc
Go to the documentation of this file.
1 /*
2  * test_param_node.cc
3  *
4  * Created on: Jul 13, 2018
5  * Author: N.S. Oblath
6  *
7  * Output should be something like:
8  *
9 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(18): Creating param node
10 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(21): Adding a value
11 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(24): Adding an array
12 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(33): Printing contents:
13 {
14  five : 5
15  subarray1 :
16  [
17  500
18  ]
19 
20  subarray2 :
21  [
22  5000
23  ]
24 
25 }
26 
27 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(35): After copy, should be full:
28 [
29  500
30 ]
31 
32 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(36): After move, should be empty:
33 [
34 ]
35 
36 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(38): Access:
37 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(39): 5
38 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(40): 5
39 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(41): 500
40 2018-07-13 15:53:19 [ INFO] (tid 0x7fff9c9dc380) st_param_node.cc(42): 5000
41  *
42  */
43 
44 #include "param.hh"
45 
46 #include "logger.hh"
47 
48 LOGGER( testlog, "test_param_node" )
49 
50 using namespace scarab;
51 
52 int main()
53 {
54  LINFO( testlog, "Creating param node" );
55  param_node node;
56 
57  LINFO( testlog, "Adding a value" );
58  node.add( "five", 5 );
59 
60  LINFO( testlog, "Adding an array" );
61  param_array subarray1;
62  subarray1.push_back( 500 );
63  node.add( "subarray1", subarray1 );
64 
65  param_array subarray2;
66  subarray2.push_back( "5000" );
67  node.add( "subarray2", std::move(subarray2) );
68 
69  LINFO( testlog, "Printing contents:" << node );
70 
71  LINFO( testlog, "After copy, should be full: " << subarray1 );
72  LINFO( testlog, "After move, should be empty: " << subarray2 );
73 
74  LINFO( testlog, "Access:" );
75  LINFO( testlog, node.get_value("five", 99999) );
76  LINFO( testlog, node["five"]() );
77  LINFO( testlog, node["subarray1"][0]() );
78  LINFO( testlog, node["subarray2"][0]() );
79 
80  return 0;
81 }
82 
83 
84 
#define LOGGER(I, K)
Definition: logger.hh:352
Contains the logger class and macros, based on Kasper&#39;s KLogger class.
#define LINFO(...)
Definition: logger.hh:362
int main()
std::string get_value(const std::string &a_name, const std::string &a_default) const
Definition: param_node.hh:208
void push_back(const param &a_value)
Definition: param_array.hh:242
bool add(const std::string &a_name, const param &a_value)
Definition: param_node.hh:228