| 144 | } |
| 145 | |
| 146 | void setJsonStr(const std::string& key, const state::response::ValueNode& value, rapidjson::Value& parent, rapidjson::Document::AllocatorType& alloc) { // NOLINT |
| 147 | rapidjson::Value keyVal; |
| 148 | rapidjson::Value valueVal; |
| 149 | const char* c_key = key.c_str(); |
| 150 | auto base_type = value.getValue(); |
| 151 | keyVal.SetString(c_key, gsl::narrow<rapidjson::SizeType>(key.length()), alloc); |
| 152 | |
| 153 | auto type_index = base_type->getTypeIndex(); |
| 154 | if (auto sub_type = std::dynamic_pointer_cast<core::TransformableValue>(base_type)) { |
| 155 | auto str = base_type->getStringValue(); |
| 156 | const char* c_val = str.c_str(); |
| 157 | valueVal.SetString(c_val, gsl::narrow<rapidjson::SizeType>(str.length()), alloc); |
| 158 | } else { |
| 159 | if (type_index == state::response::Value::BOOL_TYPE) { |
| 160 | bool value = false; |
| 161 | base_type->convertValue(value); |
| 162 | valueVal.SetBool(value); |
| 163 | } else if (type_index == state::response::Value::INT_TYPE) { |
| 164 | int value = 0; |
| 165 | base_type->convertValue(value); |
| 166 | valueVal.SetInt(value); |
| 167 | } else if (type_index == state::response::Value::UINT32_TYPE) { |
| 168 | uint32_t value = 0; |
| 169 | base_type->convertValue(value); |
| 170 | valueVal.SetUint(value); |
| 171 | } else if (type_index == state::response::Value::INT64_TYPE) { |
| 172 | int64_t value = 0; |
| 173 | base_type->convertValue(value); |
| 174 | valueVal.SetInt64(value); |
| 175 | } else if (type_index == state::response::Value::UINT64_TYPE) { |
| 176 | int64_t value = 0; |
| 177 | base_type->convertValue(value); |
| 178 | valueVal.SetInt64(value); |
| 179 | } else { |
| 180 | auto str = base_type->getStringValue(); |
| 181 | const char* c_val = str.c_str(); |
| 182 | valueVal.SetString(c_val, gsl::narrow<rapidjson::SizeType>(str.length()), alloc); |
| 183 | } |
| 184 | } |
| 185 | parent.AddMember(keyVal, valueVal, alloc); |
| 186 | } |
| 187 | |
| 188 | rapidjson::Value RESTProtocol::getStringValue(const std::string& value, rapidjson::Document::AllocatorType& alloc) { // NOLINT |
| 189 | rapidjson::Value Val; |
no test coverage detected