コード例 #1
0
ファイル: parser.hpp プロジェクト: zoq/nn-demos
  /*
   * Function to extract the first event (uri := domain.tld/{event}={job id}
   * using the uri as input. All events are defined in the events vector.
   *
   * @param uri - The input uri.
   * @return The event string.
   */
  static inline std::string ExtractEvent(std::string uri)
  {
    for (std::string event : events)
    {
      std::string eventString = HeadSlice(uri, event + "=");
      if (eventString.length() > 0)
      {
        return event;
      }
    }

    return "";
  }
コード例 #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 ExtractUserpass(std::string &in) { return HeadSlice(in, "@"); }
コード例 #4
0
 static inline std::string ExtractProtocol(std::string &in) { return HeadSlice(in, "://"); }