//--- Extractors -------------------------------------------------------------------~ static inline int ExtractPort(std::string &hostport) { int port; std::string portstring = TailSlice(hostport, ":"); try { port = atoi(portstring.c_str()); } catch (std::exception e) { port = -1; } return port; }
/* * Function to extract the event id (uri := domain.tld/{event}={event id}. * * @param uri - The input uri. * @param event - The event that should be used to extract the id. * @return The event id. */ static inline int ExtractEventID(std::string uri, std::string event) { int id = -1; std::string idString = HeadSlice(uri, event + "="); if (idString.length() > 0) { TailSlice(uri, "&"); try { id = atoi(uri.c_str()); } catch (std::exception e) { id = -1; } } return id; }
static inline std::string ExtractPassword(std::string &userpass) { return TailSlice(userpass, ":"); }
static inline std::string ExtractSearch(std::string &in) { return TailSlice(in, "?"); }
static inline std::string ExtractPath(std::string &in) { return TailSlice(in, "/", true); }