I am using yaml-cpp for my configuration files parsing because I have to be able to parse yaml and json files and this is the only cpp library supporting yaml 1.2 I have found. While parsing, I do not ask for key because I do not know what component is current configuration file for. Also I am using ncurses for displaying the configuration file content.
While parsing configuration files which include arrays I am not getting these arrays. Program just skips them.
Example of yaml configuration file:
SLICE_POSITION: 285
SLICE_HEIGHT: 15
OUTPUT_ADDRESS: "localhost:3335"
VIRTCAM_IDS:
- 0
- 1
- 2
Example of json configuration file:
{
"width" : 1366,
"mappings" : {
"x" : [ "mt_position_x" ],
"y" : [ "mt_position_y" ]
},
"active_quadrangle" : {
"bottom_left" : "[1472;4698;0]",
"bottom_right" : "[5654;4698;0]",
"top_left" : "[1472;1408;0]",
"top_right" : "[5654;1408;0]"
},
"x" : 0.0,
"y" : 0.0
}
My code:
YAML::Node config = YAML::LoadFile(fileName);
for(YAML::const_iterator it = config.begin(); it != config.end();) {
const char* key = (it->first.as<std::string>()).c_str();
mvprintw(i, 4, key);
i++; // row number
++it;
}
Keys I am getting from yaml file:
VIRTCAM_IDS
SLICE_POSITION
SLICE_HEIGHT
OUTPUT_ADDRESS
Keys I am getting from json file:
uuid
mappings
width
device
sensor_type
target
height
x
active_quadrangle
y
So can somebody tell me, how to parse this, so I can get to the arrays(and their values)? Also is there any way I can get items in right order?
Thanks for any answer!