Helper function to parse parameters from JSON to a vector of string pairs.
| 196 | |
| 197 | // Helper function to parse parameters from JSON to a vector of string pairs. |
| 198 | std::vector<std::pair<std::string, std::string>> |
| 199 | parseExpectedList(const simdjson::dom::array &Args) { |
| 200 | std::vector<std::pair<std::string, std::string>> Result; |
| 201 | Result.reserve(Args.size()); |
| 202 | for (const simdjson::dom::object &Element : Args) { |
| 203 | std::string_view Type = Element["type"]; |
| 204 | simdjson::dom::element Value; |
| 205 | auto NoValue = Element["value"].get(Value); |
| 206 | if (NoValue) { |
| 207 | // Only marked the result type, not check the opaque result reference |
| 208 | // value. |
| 209 | Result.emplace_back(std::string(Type), ""); |
| 210 | } else { |
| 211 | if (Value.type() == simdjson::dom::element_type::ARRAY) { |
| 212 | simdjson::dom::array ValueNodeArray = Value; |
| 213 | std::string StrValue; |
| 214 | std::string_view LaneType = Element["lane_type"]; |
| 215 | for (std::string_view X : ValueNodeArray) { |
| 216 | StrValue += std::string(X); |
| 217 | StrValue += ' '; |
| 218 | } |
| 219 | StrValue.pop_back(); |
| 220 | Result.emplace_back(std::string(Type) + std::string(LaneType), |
| 221 | std::move(StrValue)); |
| 222 | } else if (Value.type() == simdjson::dom::element_type::STRING) { |
| 223 | std::string_view ValueStr = Value; |
| 224 | Result.emplace_back(std::string(Type), std::string(ValueStr)); |
| 225 | } else { |
| 226 | assumingUnreachable(); |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | return Result; |
| 231 | } |
| 232 | |
| 233 | std::vector<std::vector<std::pair<std::string, std::string>>> |
| 234 | parseEithersList(const simdjson::dom::array &Args) { |
no test coverage detected