Changed widget "name" to "type" in config JSON
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
"widgets":
|
||||
[
|
||||
{
|
||||
"name": "widget_name",
|
||||
"type": "widget_type",
|
||||
"parameter1": "example",
|
||||
"parameter2": 10
|
||||
}
|
||||
|
||||
14
main.cpp
14
main.cpp
@@ -102,22 +102,22 @@ int main(int argc, char **argv)
|
||||
|
||||
for (const json& j : widgets_cfg)
|
||||
{
|
||||
string widget_name;
|
||||
json_extract(j, "name", widget_name);
|
||||
if (widget_name.empty())
|
||||
string widget_type;
|
||||
json_extract(j, "type", widget_type);
|
||||
if (widget_type.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if name exists in known builders
|
||||
if (0 == widget_builders.count(widget_name))
|
||||
// Check if type exists in known builders
|
||||
if (0 == widget_builders.count(widget_type))
|
||||
{
|
||||
cout << "Unknown widget '" << widget_name << "'. Skipping ..." << endl;
|
||||
cout << "Unknown widget '" << widget_type << "'. Skipping ..." << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Construct and add widget to vector
|
||||
shared_ptr<Widget> widget = widget_builders[widget_name](j);
|
||||
shared_ptr<Widget> widget = widget_builders[widget_type](j);
|
||||
if (nullptr != widget)
|
||||
{
|
||||
widgets.push_back(widget);
|
||||
|
||||
Reference in New Issue
Block a user