CfgMgr::Set
函数功能
设置参数。可按参数名设置单个参数,或按namespace来设置多个参数。
函数原型
uint32_t CfgMgr::Set(const std::string &kParam, const T &value, const bool isSync = false, const bool isPersist = false, const std::string &srv = "")
功能安全等级
ASIL-D
参数说明
返回值
返回uint32_t类型,成功返回CFGMGR_SUCCESS,失败返回对应的错误码。
使用说明
- 当参数不存在时则新增参数,当参数已存在时则修改参数。
- 非模板函数,针对不同类型的value进行重载,value值支持的类型有:std::string、double、float、int、bool、std::vector<std::string>、std::vector<double>、std::vector<float>、std::vector<int>、std::vector<bool>、std::map<std::string, std::string>、std::map<std::string, double>、std::map<std::string, float>、std::map<std::string, int>、std::map<std::string, bool>、const char*(当成string处理)。
- 按参数名称域来设置参数时,value值必须为map类型,表示健值对。
注意事项
- key值需小于128个字节(map类型时,入参kParam加first值才是实际的key,实际的key需小于128字节,需保证实际key下面的参数都属于同一个组)、单个value值需小于256个字节。
- 一次性Set的参数不能超过128个字节(map类型时,map的size等于参数个数),超过可能会失败。
- 设置参数失败时,需自行判断是否需要上报故障或其他处理。
- 接口返回失败,可能的原因有:没权限、数据传输失败、key或value超过长度。
父主题: 配置管理相关接口