10 std::string& crest_server, std::string& crest_api, std::string& dbname) {
12 if(!db_connection_string.starts_with(
"http")) {
16 std::string url = db_connection_string;
17 std::size_t protocol_end = url.find(
"://");
21 if (protocol_end != std::string::npos) {
22 protocol = url.substr(0, protocol_end);
29 std::size_t host_start = protocol_end + 3;
30 std::size_t host_end = url.find(
'/', host_start);
31 std::string host = (host_end == std::string::npos) ? \
32 url.substr(host_start) : url.substr(host_start, host_end - host_start);
34 crest_server = std::format(
"{}://{}", protocol, host);
37 std::string path = (host_end != std::string::npos) ? url.substr(host_end) :
"";
40 while (!path.empty() && path.back() ==
'/')
44 std::vector<std::string> path_parts;
45 std::stringstream
ss(path);
48 while (std::getline(
ss, segment,
'/')) {
49 if (!segment.empty()) {
50 path_parts.push_back(segment);
53 if(path_parts.empty()) {
54 throw std::runtime_error(
"TrigConfJobOptionsSvc: crest connection '" + db_connection_string +
"' is missing the database name.");
58 if(path_parts.size()==1) {
59 dbname = path_parts[0];
60 }
else if(path_parts.size()==2) {
61 crest_api = path_parts[0];
62 dbname = path_parts[1];
bool isCrestConnection(const std::string &db_connection_string, std::string &crest_server, std::string &crest_api, std::string &dbname)
Function to interpret the trigger connection string for CREST connections Format of the connections s...