BBS2chProxyURL.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <string>
  3. class BBS2chProxyURL {
  4. private:
  5. std::string _scheme;
  6. std::string _host;
  7. std::string _auth;
  8. std::string _pathAndOthers;
  9. int _port;
  10. bool _dirty;
  11. std::string _absoluteURLString;
  12. public:
  13. BBS2chProxyURL() : _port(0), _dirty(true) {};
  14. BBS2chProxyURL(const char *url);
  15. BBS2chProxyURL(const char *scheme, const char *host);
  16. BBS2chProxyURL(const char *scheme, const char *host, int port, const char *path);
  17. BBS2chProxyURL(const BBS2chProxyURL &baseURL, const char *path);
  18. const std::string& absoluteString();
  19. const std::string& getScheme() const;
  20. const std::string& getHost() const;
  21. const std::string& getPathAndOthers() const;
  22. std::string getPath() const;
  23. std::map<std::string, std::string> getQuery() const;
  24. int getPort() const;
  25. void setScheme(const std::string &scheme);
  26. void setPort(int port);
  27. bool isHttp() const;
  28. bool isValid() const;
  29. bool equalsTo(const BBS2chProxyURL &url, bool ignoreHttpOrHttps = false) const;
  30. bool isKindOfHost(const std::string &hostSuffix) const;
  31. bool replaceHost(const std::string &fromHost, const std::string &toHost);
  32. bool isFamilyOf5chNet() const;
  33. bool pathStartsWith(const std::string &prefix) const;
  34. bool pathEndsWith(const std::string &suffix) const;
  35. bool hostStartsWith(const std::string &prefix) const;
  36. int numberOfPathComponents() const;
  37. };