mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现策略配置功能
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "Fields.h"
|
||||
#include "common/Utils.h"
|
||||
|
||||
#include "common/JsonN.h"
|
||||
|
||||
std::string& Fields::value(std::string key)
|
||||
{
|
||||
@@ -14,14 +14,16 @@ bool Fields::contains(std::string key)
|
||||
return (mapFields.find(key) != mapFields.end());
|
||||
}
|
||||
|
||||
std::unordered_map<string, string>::iterator Fields::remove(string key)
|
||||
std::string Fields::remove(string key)
|
||||
{
|
||||
std::string val;
|
||||
auto it = mapFields.find(key);
|
||||
if (it != mapFields.end())
|
||||
{
|
||||
it = mapFields.erase(it);
|
||||
val = it->second;
|
||||
mapFields.erase(it);
|
||||
}
|
||||
return it;
|
||||
return val;
|
||||
}
|
||||
|
||||
void Fields::append(Fields& datafield)
|
||||
@@ -177,6 +179,13 @@ string Fields::toSqlUpdate(string tableName, std::vector<std::string> vecKeys, s
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void Fields::parseJson(std::string jsonstr)
|
||||
{
|
||||
NJsonNode jsonroot;
|
||||
NJson::parse(jsonstr, jsonroot);
|
||||
|
||||
|
||||
|
||||
for (auto& item : jsonroot.items())
|
||||
{
|
||||
this->set(item.key(), item.value());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user