@@ -65,7 +65,7 @@ jsoncons::json tryParse(jsoncons::json val) {
65
65
}
66
66
67
67
// Check the value type and if the value is within the range
68
- void checkTypeAndBound (std::shared_ptr<ILogger> logger, string value_type, jsoncons::json val) {
68
+ void checkTypeAndBound (std::shared_ptr<ILogger> logger, string value_type, jsoncons::json & val) {
69
69
bool typeValid = false ;
70
70
71
71
boost::algorithm::to_lower (value_type);
@@ -171,7 +171,6 @@ jsoncons::json tryParse(jsoncons::json val) {
171
171
msg << " The type " << value_type << " with value " << val.as <float >()
172
172
<< " is out of bound" ;
173
173
logger->Log (LogLevel::ERROR, " VssDatabase::setSignal: " + msg.str ());
174
-
175
174
throw outOfBoundException (msg.str ());
176
175
}
177
176
} else if (value_type == " float" ) {
@@ -203,6 +202,22 @@ jsoncons::json tryParse(jsoncons::json val) {
203
202
throw outOfBoundException (msg.str ());
204
203
}
205
204
} else if (value_type == " boolean" ) {
205
+ string v=val.as <string>();
206
+ boost::algorithm::erase_all (v, " \" " );
207
+
208
+ if ( v == " true" ) {
209
+ val=true ;
210
+ }
211
+ else if ( v == " false" ) {
212
+ val=false ;
213
+ }
214
+ else {
215
+ std::stringstream msg;
216
+ msg << val.as_string () << " is not a bool. Valid values are true and false " ;
217
+ logger->Log (LogLevel::ERROR, " VssDatabase::setSignal: " + msg.str ());
218
+ std::cout << pretty_print (val) << std::endl;
219
+ throw outOfBoundException (msg.str ());
220
+ }
206
221
typeValid = true ;
207
222
} else if (value_type == " string" ) {
208
223
typeValid = true ;
0 commit comments