@@ -101,6 +101,24 @@ void ptreeToMember(boost::property_tree::ptree const& value,
101101 TDataMember* dm,
102102 void * ptr)
103103{
104+
105+ if (dm->IsSTLContainer ()) {
106+ auto type = dm->GetTypeName ();
107+ switch (compile_time_hash (type)) {
108+ case compile_time_hash (" vector<int>" ):
109+ *static_cast <std::vector<int >*>(ptr) = extractVector<int >(value);
110+ return ;
111+ case compile_time_hash (" vector<float>" ):
112+ *static_cast <std::vector<float >*>(ptr) = extractVector<float >(value);
113+ return ;
114+ case compile_time_hash (" vector<double>" ):
115+ *static_cast <std::vector<double >*>(ptr) = extractVector<double >(value);
116+ return ;
117+ case compile_time_hash (" vector<bool>" ):
118+ default :
119+ throw std::runtime_error (" Not and int/float/double/bool vector" );
120+ }
121+ }
104122 auto dt = dm->GetDataType ();
105123 if (dt != nullptr ) {
106124 switch (dt->GetType ()) {
@@ -165,33 +183,32 @@ void ptreeToMember(boost::property_tree::ptree const& value,
165183 }
166184 }
167185 }
186+ // if we get here none of the above worked
187+ if (strcmp (tname, " string" ) == 0 || strcmp (tname, " std::string" )) {
188+ *(std::string*)ptr = value.get_value <std::string>();
189+ }
190+ throw std::runtime_error (" Unable to override value" );
191+ }
192+
193+ // Convert a DataMember to a ConfigParamSpec
194+ ConfigParamSpec memberToConfigParamSpec (const char * tname, TDataMember* dm, void * ptr)
195+ {
168196 if (dm->IsSTLContainer ()) {
169197 auto type = dm->GetTypeName ();
170198 switch (compile_time_hash (type)) {
171199 case compile_time_hash (" vector<int>" ):
172- *static_cast <std::vector<int >*>(ptr) = extractVector<int >(value);
173- return ;
200+ return ConfigParamSpec{tname, VariantType::ArrayInt, *static_cast <std::vector<int >*>(ptr), {" No help" }};
174201 case compile_time_hash (" vector<float>" ):
175- *static_cast <std::vector<float >*>(ptr) = extractVector<float >(value);
176- return ;
202+ return ConfigParamSpec{tname, VariantType::ArrayFloat, *static_cast <std::vector<float >*>(ptr), {" No help" }};
177203 case compile_time_hash (" vector<double>" ):
178- *static_cast <std::vector<double >*>(ptr) = extractVector<double >(value);
179- return ;
204+ return ConfigParamSpec{tname, VariantType::ArrayDouble, *static_cast <std::vector<double >*>(ptr), {" No help" }};
180205 case compile_time_hash (" vector<bool>" ):
206+ throw std::runtime_error (" bool vector not supported yet" );
207+ // return ConfigParamSpec{tname, VariantType::ArrayBool, *static_cast<std::vector<bool>*>(ptr), {"No help"}};
181208 default :
182209 throw std::runtime_error (" Not and int/float/double/bool vector" );
183210 }
184211 }
185- // if we get here none of the above worked
186- if (strcmp (tname, " string" ) == 0 || strcmp (tname, " std::string" )) {
187- *(std::string*)ptr = value.get_value <std::string>();
188- }
189- throw std::runtime_error (" Unable to override value" );
190- }
191-
192- // Convert a DataMember to a ConfigParamSpec
193- ConfigParamSpec memberToConfigParamSpec (const char * tname, TDataMember* dm, void * ptr)
194- {
195212 auto dt = dm->GetDataType ();
196213 if (dt != nullptr ) {
197214 switch (dt->GetType ()) {
@@ -242,22 +259,6 @@ ConfigParamSpec memberToConfigParamSpec(const char* tname, TDataMember* dm, void
242259 }
243260 }
244261 }
245- if (dm->IsSTLContainer ()) {
246- auto type = dm->GetTypeName ();
247- switch (compile_time_hash (type)) {
248- case compile_time_hash (" vector<int>" ):
249- return ConfigParamSpec{tname, VariantType::ArrayInt, *static_cast <std::vector<int >*>(ptr), {" No help" }};
250- case compile_time_hash (" vector<float>" ):
251- return ConfigParamSpec{tname, VariantType::ArrayFloat, *static_cast <std::vector<float >*>(ptr), {" No help" }};
252- case compile_time_hash (" vector<double>" ):
253- return ConfigParamSpec{tname, VariantType::ArrayDouble, *static_cast <std::vector<double >*>(ptr), {" No help" }};
254- case compile_time_hash (" vector<bool>" ):
255- throw std::runtime_error (" bool vector not supported yet" );
256- // return ConfigParamSpec{tname, VariantType::ArrayBool, *static_cast<std::vector<bool>*>(ptr), {"No help"}};
257- default :
258- throw std::runtime_error (" Not and int/float/double/bool vector" );
259- }
260- }
261262 // if we get here none of the above worked
262263 if (strcmp (tname, " string" ) == 0 || strcmp (tname, " std::string" )) {
263264 return ConfigParamSpec{tname, VariantType::String, *(std::string*)ptr, {" No help" }};
0 commit comments