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