| 320 | |
| 321 | template <typename T, std::size_t N> |
| 322 | struct DiffArray : public DiffBase<std::array<T, N>> { |
| 323 | DiffArray(const std::string_view textHeaderIn, const std::string_view jsonPathIn, |
| 324 | const std::optional<std::array<T, N>>& value1, const std::optional<std::array<T, N>>& value2) |
| 325 | : DiffBase<std::array<T, N>>(textHeaderIn, jsonPathIn, value1, value2) {} |
| 326 | |
| 327 | DiffArray(const std::string_view textHeaderIn, const std::string_view jsonPathIn, |
| 328 | const std::array<T, N>& value1, const std::array<T, N>& value2) |
| 329 | : DiffBase<std::array<T, N>>(textHeaderIn, jsonPathIn, value1, value2) {} |
| 330 | |
| 331 | virtual std::string value(std::size_t index, OutputFormat format) const override { |
| 332 | const auto space = format != OutputFormat::json_mini ? " " : ""; |
| 333 | |
| 334 | std::stringstream formattedValue; |
| 335 | bool first = true; |
| 336 | for (std::size_t arrayIndex = 0; arrayIndex < N; ++arrayIndex) { |
| 337 | const auto comma = std::exchange(first, false) ? "" : fmt::format(",{}", space); |
| 338 | fmt::print(formattedValue, "{}{}", comma, DiffBase<std::array<T, N>>::rawValue(index)[arrayIndex]); |
| 339 | } |
| 340 | |
| 341 | if (format == OutputFormat::text) { |
| 342 | return formattedValue.str(); |
| 343 | } else { |
| 344 | if (formattedValue.str().empty()) { |
| 345 | return "[]"; |
| 346 | } else { |
| 347 | return fmt::format("[{}{}{}]", space, formattedValue.str(), space); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | }; |
| 352 | |
| 353 | struct DiffRawBytes : public DiffBase<std::vector<uint8_t>> { |
| 354 | DiffRawBytes(const std::string_view textHeaderIn, const std::string_view jsonPathIn, |