Skip to content

Commit

Permalink
make Sniper::create() be more user friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujh committed Nov 26, 2021
1 parent ec8df20 commit 505f512
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions SniperKernel/src/Sniper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ namespace Sniper

DLElement *Sniper::create(const std::string &json_str)
{
auto json = SniperJSON::loads(json_str);
DLElement *pobj = nullptr;

DLElement *pobj = DLEFactory::instance().create(json["identifier"].get<std::string>());
pobj->eval(json);
auto json = SniperJSON::loads(json_str);
if (json.isMap())
{
pobj = DLEFactory::instance().create(json["identifier"].get<std::string>());
pobj->eval(json);
}
else
{
pobj = DLEFactory::instance().create(json_str);
}

return pobj;
}
Expand Down

0 comments on commit 505f512

Please sign in to comment.