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

Function parse_string

src/framework/io/safetensors.cpp:22–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22std::string parse_string(const std::string & text, size_t & pos) {
23 skip_ws(text, pos);
24 if (pos >= text.size() || text[pos] != '"') {
25 throw std::runtime_error("expected json string");
26 }
27 ++pos;
28 std::string out;
29 while (pos < text.size()) {
30 const char ch = text[pos++];
31 if (ch == '\\') {
32 if (pos >= text.size()) {
33 throw std::runtime_error("invalid string escape");
34 }
35 out.push_back(text[pos++]);
36 continue;
37 }
38 if (ch == '"') {
39 return out;
40 }
41 out.push_back(ch);
42 }
43 throw std::runtime_error("unterminated json string");
44}
45
46int64_t parse_int64(const std::string & text, size_t & pos) {
47 skip_ws(text, pos);

Callers 3

skip_json_valueFunction · 0.70
parse_string_mapFunction · 0.70
load_safetensors_indexFunction · 0.70

Calls 2

skip_wsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected