aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2020-01-23 12:31:08 -0700
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2020-01-23 13:28:02 -0700
commitd9854c32eee5d43d66f0c0273f9f5521e43f302e (patch)
tree81dd184df9288935b8ee3372009491657f0e2f81
parentaaba1e4e6aec7701e7ee95dd54634e8f2a7806ea (diff)
downloadusermoji-d9854c32eee5d43d66f0c0273f9f5521e43f302e.tar.xz
vulkaninfo: Fix UUID printing
The output printers for UUID and LUID wouldn't retain the leading zero's, leading to an inaccurate hex string. Changes to be committed: modified: vulkaninfo/outputprinter.h Change-Id: I0834c00ca810d67a2849cdfb0a46db5e70158376
-rw-r--r--vulkaninfo/outputprinter.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/vulkaninfo/outputprinter.h b/vulkaninfo/outputprinter.h
index 53cf7514..c5df2c2c 100644
--- a/vulkaninfo/outputprinter.h
+++ b/vulkaninfo/outputprinter.h
@@ -33,24 +33,23 @@
std::string insert_quotes(std::string s) { return "\"" + s + "\""; }
std::string to_string_16(uint8_t uid[16]) {
- std::stringstream stream;
- stream << std::setw(2) << std::hex;
- stream << (int)uid[0] << (int)uid[1] << (int)uid[2] << (int)uid[3] << "-";
- stream << (int)uid[4] << (int)uid[5] << "-";
- stream << (int)uid[6] << (int)uid[7] << "-";
- stream << (int)uid[8] << (int)uid[9] << "-";
- stream << (int)uid[10] << (int)uid[11] << (int)uid[12] << (int)uid[13] << (int)uid[14] << (int)uid[15];
-
- return stream.str();
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ for (int i = 0; i < 16; ++i) {
+ if (i == 4 || i == 6 || i == 8 || i == 10) ss << '-';
+ ss << std::setw(2) << static_cast<unsigned>(uid[i]);
+ }
+ return ss.str();
}
std::string to_string_8(uint8_t uid[8]) {
- std::stringstream stream;
- stream << std::setw(2) << std::hex;
- stream << (int)uid[0] << (int)uid[1] << (int)uid[2] << (int)uid[3] << "-";
- stream << (int)uid[4] << (int)uid[5] << (int)uid[6] << (int)uid[7];
-
- return stream.str();
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ for (int i = 0; i < 8; ++i) {
+ if (i == 4) ss << '-';
+ ss << std::setw(2) << static_cast<unsigned>(uid[i]);
+ }
+ return ss.str();
}
std::string VkVersionString(uint32_t version) {