14 std::string& crest_server,
15 std::string& crest_api,
18 if (!db_connection_string.starts_with(
"http")) {
22 const std::string& url = db_connection_string;
23 const std::size_t protocol_end = url.find(
"://");
26 std::size_t host_start = 0;
28 if (protocol_end != std::string::npos) {
29 protocol = url.substr(0, protocol_end);
30 host_start = protocol_end + 3;
33 const std::size_t host_end = url.find(
'/', host_start);
34 const std::string host =
35 (host_end == std::string::npos)
36 ? url.substr(host_start)
37 : url.substr(host_start, host_end - host_start);
39 crest_server = protocol.empty()
41 : std::format(
"{}://{}", protocol, host);
44 (host_end != std::string::npos) ? url.substr(host_end) :
"";
46 while (!path.empty() && path.back() ==
'/') {
50 std::vector<std::string> path_parts;
51 std::stringstream
ss(path);
54 while (std::getline(
ss, segment,
'/')) {
55 if (!segment.empty()) {
56 path_parts.push_back(segment);
60 if (path_parts.empty()) {
61 throw std::runtime_error(
62 "TrigConfJobOptionsSvc: crest connection '" + db_connection_string +
63 "' is missing the database name.");
69 if (path_parts.size() == 1) {
70 dbname = path_parts[0];
72 else if (path_parts.size() == 2) {
73 crest_api = path_parts[0];
74 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...