I have a config file like this, where properties1
can have 1 or more values:
[OBJECT]
properties1=val1, val2, val3
porperty2=Blah
property3=Blah
property4=Blah
porperty5=Bla bla bla
[OBJECT]
properties1=val1
porperty2=Blah
property3=Blah
property4=Blah
porperty5=Bla bla bla
And I am parsing it using boost::program_options
. However it does not work properly because for example properties1
gets stored into one vector, and so it is not possible to get a mapping between each OBJECT and its properties. So I think boost::property_map
might be a good solution. Here is the current solution:
namespace po = boost::program_options;
std::vector<std::string> properties1_all;
std::vector<std::string> property2_all;
std::vector<std::string> property3_all;
std::vector<std::string> property4_all;
std::vector<std::string> property5_all;
po::options_description desc;
desc.add_options()
("OBJECT.properties1",
po::value<std::vector<std::string> >(&properties1_all))
("OBJECT.property2",
po::value<std::vector<std::string> >(&property2_all))
("OBJECT.property3",
po::value<std::vector<std::string> >(&property3_all))
("OBJECT.property4",
po::value<std::vector<std::string> >(&property4_all))
("OBJECT.property5",
po::value<std::vector<std::string> >(&property5_all));
po::variables_map vm;
std::ifstream settings_file("config.ini", std::ifstream::in);
po::store(po::parse_config_file(settings_file, desc), vm);
settings_file.close();
po::notify(vm);
And my attempt with property map, but it does not seem to work... I think making each OBJECT a node and then an edge to 5 vertices, which are its properties, would be a good solution:
typedef adjacency_list<vecS, vecS, bidirectionalS,
no_property, property<edge_index_t, std::size_t> > Graph;
const int num_vertices = 5;
Graph G(num_vertices);
int propertyarray[] = { 1, 2, 3, 4, 5 };
int objectarray[] = { 1, 2, 3 };
// Add edges to the graph, and assign each edge an ID number.
add_edge(0, 1, 0, G);
// ...
typedef graph_traits<Graph>::edge_descriptor Edge;
typedef property_map<Graph, edge_index_t>::type EdgeID_Map;
EdgeID_Map edge_id = get(edge_index, G);