MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / MakeString

Function MakeString

source/util/string_utils.h:85–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83// assert_found_terminating_null is passed as false).
84template <class InputIt>
85inline std::string MakeString(InputIt first, InputIt last,
86 bool assert_found_terminating_null = true) {
87 std::string result;
88 constexpr size_t kCharsPerWord = sizeof(*first);
89 static_assert(kCharsPerWord == 4, "expect 4-byte word");
90
91 for (InputIt pos = first; pos != last; ++pos) {
92 uint32_t word = *pos;
93 for (size_t byte_index = 0; byte_index < kCharsPerWord; byte_index++) {
94 uint32_t extracted_word = (word >> (8 * byte_index)) & 0xFF;
95 char c = static_cast<char>(extracted_word);
96 if (c == 0) {
97 return result;
98 }
99 result += c;
100 }
101 }
102 assert(!assert_found_terminating_null &&
103 "Did not find terminating null for the string.");
104 (void)assert_found_terminating_null; /* No unused parameters in release
105 builds. */
106 return result;
107}
108
109// Decode a string from a sequence of words in a vector, using the SPIR-V
110// encoding.

Callers 7

parseOperandMethod · 0.85
string>Method · 0.85
AsStringMethod · 0.85
TEST_PFunction · 0.85

Calls 2

cbeginMethod · 0.45
cendMethod · 0.45

Tested by 1

TEST_PFunction · 0.68