示例#1
0
 //--- 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;
 }
示例#2
0
文件: parser.hpp 项目: zoq/nn-demos
  /*
   * 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;
  }
示例#3
0
 static inline std::string ExtractPassword(std::string &userpass) { return TailSlice(userpass, ":"); }
示例#4
0
 static inline std::string ExtractSearch(std::string &in) { return TailSlice(in, "?"); }
示例#5
0
 static inline std::string ExtractPath(std::string &in) { return TailSlice(in, "/", true); }