MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / parse_string_map

Function parse_string_map

src/framework/io/safetensors.cpp:168–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 pos += 5;
167 return;
168 }
169 if (text.compare(pos, 4, "null") == 0) {
170 pos += 4;
171 return;
172 }
173 throw std::runtime_error("unsupported json value while skipping");
174}
175
176std::unordered_map<std::string, std::string> parse_string_map(const std::string & text, size_t & pos) {
177 std::unordered_map<std::string, std::string> values;
178 expect_char(text, pos, '{');
179 while (true) {
180 skip_ws(text, pos);
181 if (pos < text.size() && text[pos] == '}') {
182 ++pos;
183 return values;
184 }
185 const auto key = parse_string(text, pos);
186 expect_char(text, pos, ':');
187 const auto value = parse_string(text, pos);
188 values.emplace(key, value);
189 skip_ws(text, pos);
190 if (pos < text.size() && text[pos] == ',') {
191 ++pos;
192 continue;
193 }
194 if (pos < text.size() && text[pos] == '}') {
195 ++pos;

Callers 1

load_safetensors_indexFunction · 0.85

Calls 4

expect_charFunction · 0.85
skip_wsFunction · 0.85
parse_stringFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected