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

Class DiffComplex

tools/ktx/command_compare.cpp:389–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387
388template <typename T>
389struct DiffComplex {
390 DiffComplex(const std::string_view textHeaderIn, const std::string_view jsonPathIn,
391 const std::optional<T>& value1, const std::optional<T>& value2)
392 : textHeader(textHeaderIn), jsonPath(jsonPathIn), values(),
393 different((value1.has_value() && value2.has_value())
394 ? value1->isDifferent(*value2)
395 : (!value1.has_value() || !value2.has_value()) ? true : false) {
396 values[0] = value1;
397 values[1] = value2;
398 }
399
400 DiffComplex(const std::string_view textHeaderIn, const std::string_view jsonPathIn,
401 const T& value1, const T& value2)
402 : textHeader(textHeaderIn), jsonPath(jsonPathIn), values(), different(value1.different(value2)) {
403 values[0] = value1;
404 values[1] = value2;
405 }
406
407 const std::string_view textHeader;
408 const std::string_view jsonPath;
409
410 bool isDifferent() const {
411 return different;
412 }
413
414 bool hasValue(std::size_t index) const {
415 return values[index].has_value();
416 }
417
418 void printText(std::size_t index, PrintIndent& out, const char* prefix) const {
419 values[index]->printText(out, prefix);
420 }
421
422 void printJson(std::size_t index, PrintIndent& out, int indent, const char* space, const char* nl) const {
423 values[index]->printJson(out, indent, space, nl);
424 }
425
426private:
427 std::optional<T> values[2];
428 const bool different;
429};
430
431
432struct DiffTextCustom {

Callers 1

compareKVEntryMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected