| 1895 | }; |
| 1896 | |
| 1897 | void CommandCompare::compareKVEntry(PrintDiff& diff, const std::string_view& key, |
| 1898 | ktxHashListEntry* entry1, ktxHashListEntry* entry2) { |
| 1899 | const std::unordered_set<std::string_view> keysWithUint32Values = { |
| 1900 | "KTXdxgiFormat__", |
| 1901 | "KTXmetalPixelFormat" |
| 1902 | }; |
| 1903 | const std::unordered_set<std::string_view> keysWithStringValues = { |
| 1904 | "KTXorientation", |
| 1905 | "KTXswizzle", |
| 1906 | "KTXwriter", |
| 1907 | "KTXwriterScParams", |
| 1908 | "KTXastcDecodeMode" |
| 1909 | }; |
| 1910 | |
| 1911 | if (keysWithUint32Values.find(key) != keysWithUint32Values.end()) { |
| 1912 | struct KVEntryUint32 : public KVEntry { |
| 1913 | bool isValid() const { |
| 1914 | return valueLen == sizeof(ktx_uint32_t); |
| 1915 | } |
| 1916 | |
| 1917 | void printText(PrintIndent& out, const char*) const { |
| 1918 | if (isValid()) { |
| 1919 | out(0, " {}\n", extract<ktx_uint32_t>()); |
| 1920 | } else { |
| 1921 | out(0, " {}\n", extractRawBytes(true)); |
| 1922 | } |
| 1923 | } |
| 1924 | |
| 1925 | void printJson(PrintIndent& out, int indent, const char* space, const char*) const { |
| 1926 | if (isValid()) { |
| 1927 | out(indent, "{}", extract<ktx_uint32_t>()); |
| 1928 | } else { |
| 1929 | out(indent, "{}", extractRawBytes(false, space)); |
| 1930 | } |
| 1931 | } |
| 1932 | }; |
| 1933 | |
| 1934 | diff << DiffComplex(key, fmt::format("/keyValueData/{}", key), |
| 1935 | KVEntry::load<KVEntryUint32>(entry1), KVEntry::load<KVEntryUint32>(entry2)); |
| 1936 | } else if (keysWithStringValues.find(key) != keysWithStringValues.end()) { |
| 1937 | struct KVEntryString : public KVEntry { |
| 1938 | bool isValid() const { |
| 1939 | return value[valueLen - 1] == '\0'; |
| 1940 | } |
| 1941 | |
| 1942 | void printText(PrintIndent& out, const char*) const { |
| 1943 | if (isValid()) { |
| 1944 | out(0, " {}\n", value); |
| 1945 | } else { |
| 1946 | out(0, " {}\n", extractRawBytes(true)); |
| 1947 | } |
| 1948 | } |
| 1949 | |
| 1950 | void printJson(PrintIndent& out, int indent, const char* space, const char*) const { |
| 1951 | if (isValid()) { |
| 1952 | out(indent, "\"{}\"", value); |
| 1953 | } else { |
| 1954 | out(indent, "{}", extractRawBytes(false, space)); |
nothing calls this directly
no test coverage detected