| 171 | } |
| 172 | |
| 173 | static int config_get_int(const std::string& json, const std::string& key, int default_val) { |
| 174 | auto pos = json.find("\"" + key + "\""); |
| 175 | if (pos == std::string::npos) return default_val; |
| 176 | auto colon = json.find(':', pos); |
| 177 | if (colon == std::string::npos) return default_val; |
| 178 | size_t start = colon + 1; |
| 179 | while (start < json.size() && (json[start] == ' ' || json[start] == '\t')) start++; |
| 180 | if (start >= json.size()) return default_val; |
| 181 | return std::atoi(json.c_str() + start); |
| 182 | } |
| 183 | |
| 184 | RCLIHandle rcli_create(const char* config_json) { |
| 185 | auto* engine = new (std::nothrow) RCLIEngine(); |