MCPcopy Create free account
hub / github.com/cactus-compute/cactus / parse_float_array

Function parse_float_array

tests/test_exhaustive.cpp:95–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95static std::vector<float> parse_float_array(const std::string& json, const std::string& key) {
96 std::string pat = "\"" + key + "\":";
97 size_t pos = json.find(pat);
98 if (pos == std::string::npos) return {};
99 size_t s = pos + pat.size();
100 while (s < json.size() && json[s] == ' ') s++;
101 if (s >= json.size() || json[s] != '[') return {};
102 int depth = 1; size_t e = s + 1;
103 while (e < json.size() && depth > 0) { if (json[e] == '[') depth++; else if (json[e] == ']') depth--; e++; }
104 std::vector<float> r;
105 std::istringstream iss(json.substr(s + 1, e - s - 2));
106 std::string tok;
107 while (std::getline(iss, tok, ',')) { try { r.push_back(std::stof(tok)); } catch (...) {} }
108 return r;
109}
110
111static std::string resolve_asset_paths(const std::string& messages) {
112 if (!g_assets_path) return messages;

Callers 1

test_embedding_goldenFunction · 0.70

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected