hurl.h 845 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef HV_URL_H_
  2. #define HV_URL_H_
  3. #include <string> // import std::string
  4. #include "hexport.h"
  5. class HV_EXPORT HUrl {
  6. public:
  7. static std::string escape(const std::string& str, const char* unescaped_chars = "");
  8. static std::string unescape(const std::string& str);
  9. HUrl() : port(0) {}
  10. ~HUrl() {}
  11. void reset();
  12. bool parse(const std::string& url);
  13. const std::string& dump();
  14. std::string url;
  15. std::string scheme;
  16. std::string username;
  17. std::string password;
  18. std::string host;
  19. int port;
  20. std::string path;
  21. std::string query;
  22. std::string fragment;
  23. };
  24. namespace hv {
  25. HV_INLINE std::string escapeURL(const std::string& url) {
  26. return HUrl::escape(url, ":/@?=&#+");
  27. }
  28. HV_EXPORT std::string escapeHTML(const std::string& str);
  29. } // end namespace hv
  30. #endif // HV_URL_H_