diff options
Diffstat (limited to 'src/common/param_package.cpp')
| -rw-r--r-- | src/common/param_package.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index e0df430ab..9526ca0c6 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp | |||
| @@ -3,7 +3,9 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <utility> | ||
| 6 | #include <vector> | 7 | #include <vector> |
| 8 | |||
| 7 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 8 | #include "common/param_package.h" | 10 | #include "common/param_package.h" |
| 9 | #include "common/string_util.h" | 11 | #include "common/string_util.h" |
| @@ -12,10 +14,11 @@ namespace Common { | |||
| 12 | 14 | ||
| 13 | constexpr char KEY_VALUE_SEPARATOR = ':'; | 15 | constexpr char KEY_VALUE_SEPARATOR = ':'; |
| 14 | constexpr char PARAM_SEPARATOR = ','; | 16 | constexpr char PARAM_SEPARATOR = ','; |
| 17 | |||
| 15 | constexpr char ESCAPE_CHARACTER = '$'; | 18 | constexpr char ESCAPE_CHARACTER = '$'; |
| 16 | const std::string KEY_VALUE_SEPARATOR_ESCAPE{ESCAPE_CHARACTER, '0'}; | 19 | constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0"; |
| 17 | const std::string PARAM_SEPARATOR_ESCAPE{ESCAPE_CHARACTER, '1'}; | 20 | constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1"; |
| 18 | const std::string ESCAPE_CHARACTER_ESCAPE{ESCAPE_CHARACTER, '2'}; | 21 | constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2"; |
| 19 | 22 | ||
| 20 | ParamPackage::ParamPackage(const std::string& serialized) { | 23 | ParamPackage::ParamPackage(const std::string& serialized) { |
| 21 | std::vector<std::string> pairs; | 24 | std::vector<std::string> pairs; |
| @@ -35,7 +38,7 @@ ParamPackage::ParamPackage(const std::string& serialized) { | |||
| 35 | part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); | 38 | part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); |
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | Set(key_value[0], key_value[1]); | 41 | Set(key_value[0], std::move(key_value[1])); |
| 39 | } | 42 | } |
| 40 | } | 43 | } |
| 41 | 44 | ||
| @@ -101,16 +104,16 @@ float ParamPackage::Get(const std::string& key, float default_value) const { | |||
| 101 | } | 104 | } |
| 102 | } | 105 | } |
| 103 | 106 | ||
| 104 | void ParamPackage::Set(const std::string& key, const std::string& value) { | 107 | void ParamPackage::Set(const std::string& key, std::string value) { |
| 105 | data[key] = value; | 108 | data.insert_or_assign(key, std::move(value)); |
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | void ParamPackage::Set(const std::string& key, int value) { | 111 | void ParamPackage::Set(const std::string& key, int value) { |
| 109 | data[key] = std::to_string(value); | 112 | data.insert_or_assign(key, std::to_string(value)); |
| 110 | } | 113 | } |
| 111 | 114 | ||
| 112 | void ParamPackage::Set(const std::string& key, float value) { | 115 | void ParamPackage::Set(const std::string& key, float value) { |
| 113 | data[key] = std::to_string(value); | 116 | data.insert_or_assign(key, std::to_string(value)); |
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | bool ParamPackage::Has(const std::string& key) const { | 119 | bool ParamPackage::Has(const std::string& key) const { |