| 50 | ParamPackage::ParamPackage(std::initializer_list<DataType::value_type> list) : data(list) {} |
| 51 | |
| 52 | std::string ParamPackage::Serialize() const { |
| 53 | if (data.empty()) |
| 54 | return EMPTY_PLACEHOLDER; |
| 55 | |
| 56 | std::string result; |
| 57 | |
| 58 | for (const auto& pair : data) { |
| 59 | std::array<std::string, 2> key_value{{pair.first, pair.second}}; |
| 60 | for (std::string& part : key_value) { |
| 61 | part = Common::ReplaceAll(part, {ESCAPE_CHARACTER}, ESCAPE_CHARACTER_ESCAPE); |
| 62 | part = Common::ReplaceAll(part, {PARAM_SEPARATOR}, PARAM_SEPARATOR_ESCAPE); |
| 63 | part = Common::ReplaceAll(part, {KEY_VALUE_SEPARATOR}, KEY_VALUE_SEPARATOR_ESCAPE); |
| 64 | } |
| 65 | result += key_value[0] + KEY_VALUE_SEPARATOR + key_value[1] + PARAM_SEPARATOR; |
| 66 | } |
| 67 | |
| 68 | result.pop_back(); // discard the trailing PARAM_SEPARATOR |
| 69 | return result; |
| 70 | } |
| 71 | |
| 72 | std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { |
| 73 | auto pair = data.find(key); |
no test coverage detected