| 244 | |
| 245 | template <class FieldType, class Writer> |
| 246 | void putField(Optional<FieldType> const& field, Writer& wr, const char* fieldName) { |
| 247 | if (!field.present()) |
| 248 | return; |
| 249 | wr.Key(fieldName); |
| 250 | auto const& value = field.get(); |
| 251 | static_assert(std::is_same_v<StringRef, FieldType> || std::is_same_v<FieldType, uint64_t> || |
| 252 | std::is_same_v<FieldType, VectorRef<StringRef>>); |
| 253 | if constexpr (std::is_same_v<StringRef, FieldType>) { |
| 254 | wr.String(reinterpret_cast<const char*>(value.begin()), value.size()); |
| 255 | } else if constexpr (std::is_same_v<FieldType, uint64_t>) { |
| 256 | wr.Uint64(value); |
| 257 | } else { |
| 258 | wr.StartArray(); |
| 259 | for (auto elem : value) { |
| 260 | wr.String(reinterpret_cast<const char*>(elem.begin()), elem.size()); |
| 261 | } |
| 262 | wr.EndArray(); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | StringRef makeTokenPart(Arena& arena, TokenRef tokenSpec) { |
| 267 | using Buffer = rapidjson::StringBuffer; |
no test coverage detected