MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / DiffRawBytes

Class DiffRawBytes

tools/ktx/command_compare.cpp:353–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351};
352
353struct DiffRawBytes : public DiffBase<std::vector<uint8_t>> {
354 DiffRawBytes(const std::string_view textHeaderIn, const std::string_view jsonPathIn,
355 const std::optional<std::vector<uint8_t>>& value1, const std::optional<std::vector<uint8_t>>& value2)
356 : DiffBase<std::vector<uint8_t>>(textHeaderIn, jsonPathIn, value1, value2) {}
357
358 DiffRawBytes(const std::string_view textHeaderIn, const std::string_view jsonPathIn,
359 const std::vector<uint8_t>& value1, const std::vector<uint8_t>& value2)
360 : DiffBase<std::vector<uint8_t>>(textHeaderIn, jsonPathIn, value1, value2) {}
361
362 virtual std::string value(std::size_t index, OutputFormat format) const override {
363 const auto space = format != OutputFormat::json_mini ? " " : "";
364
365 std::stringstream formattedValue;
366 bool first = true;
367 for (std::size_t arrayIndex = 0; arrayIndex < rawValue(index).size(); ++arrayIndex) {
368 const auto comma = std::exchange(first, false) ? "" : fmt::format(",{}", space);
369 if (format == OutputFormat::text) {
370 fmt::print(formattedValue, "{}0x{:x}", comma, rawValue(index)[arrayIndex]);
371 } else {
372 fmt::print(formattedValue, "{}{}", comma, rawValue(index)[arrayIndex]);
373 }
374 }
375
376 if (format == OutputFormat::text) {
377 return fmt::format("[{}]", formattedValue.str());
378 } else {
379 if (formattedValue.str().empty()) {
380 return "[]";
381 } else {
382 return fmt::format("[{}{}{}]", space, formattedValue.str(), space);
383 }
384 }
385 }
386};
387
388template <typename T>
389struct DiffComplex {

Callers 1

compareDFDMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected