Skip to content
Snippets Groups Projects
Commit 9542cae3 authored by jgatt's avatar jgatt
Browse files

added error check for parse_dm_window function

parent b54f0fef
Branches
Tags
1 merge request!12Merge Request multibehavior
......@@ -127,7 +127,7 @@ Broker::Broker(rapidjson::Document *user_description_file)
else if (category == "dm_user_multi_behavior"){
PPK_ASSERT_ERROR(
dm_window || red_windows_list || yellow_windows_list,
"One of these 3 fiels should be defined to use dm_user_multi_behavior"
"One of these 3 fields should be defined to use dm_user_multi_behavior"
" 'dm_windows' 'red_windows', 'yellow_windows' "
);
PPK_ASSERT_ERROR(
......@@ -280,19 +280,23 @@ DMWindow_list* Broker::parse_dm_windows(const std::string attr_name,
const rapidjson::Document *user_description_file)
{
const Value &windows_param = (*user_description_file)[attr_name.c_str()];
/*PPK_ASSERT_ERROR(yellow_windows_param.IsArray(),
"Invalid user_description file: field "
attr_name "should be an array.");*/
std::string error_message = "Invalid user_description file: field ";
error_message += attr_name;
error_message = "should be an array";
PPK_ASSERT_ERROR(windows_param.IsArray(),
error_message.c_str());
error_message = "Invalid user_description file: the field ";
error_message += attr_name;
error_message += " should be an array containing only array of int of size 2.";
std::vector<DMWindow> windows_collect;
for (SizeType i = 0 ; i < windows_param.GetArray().Size(); i++) {
const Value &window =
(*user_description_file)[attr_name.c_str()].GetArray()[i];
/*PPK_ASSERT_ERROR(window.IsArray()
PPK_ASSERT_ERROR(window.IsArray()
&& window.GetArray().Size()==2
&& window.GetArray()[0].IsInt()
&& window.GetArray()[1].IsInt()
&& window.GetArray().Size()==2,
"Invalid user_description file: field "
attr_name "should be an array containing only array of int of size 2.");*/
&& window.GetArray()[1].IsInt(),
error_message.c_str());
DMWindow* dm_window =
new DMWindow(window.GetArray()[0].GetInt(),
window.GetArray()[1].GetInt());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment