Url.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 1999-2019 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_
  17. #define CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_
  18. #include "CoreExport.h"
  19. #include <string>
  20. namespace AlibabaCloud {
  21. class ALIBABACLOUD_CORE_EXPORT Url {
  22. public:
  23. explicit Url(const std::string &url = "");
  24. Url(const Url &other) = default;
  25. Url(Url &&other) = default;
  26. ~Url();
  27. Url &operator=(const Url &url) = default;
  28. Url &operator=(Url &&other) = default;
  29. bool operator==(const Url &url) const;
  30. bool operator!=(const Url &url) const;
  31. std::string authority() const;
  32. void clear();
  33. std::string fragment() const;
  34. void fromString(const std::string &url);
  35. bool hasFragment() const;
  36. bool hasQuery() const;
  37. std::string host() const;
  38. bool isEmpty() const;
  39. bool isValid() const;
  40. int port() const;
  41. std::string password() const;
  42. std::string path() const;
  43. std::string query() const;
  44. std::string scheme() const;
  45. void setAuthority(const std::string &authority);
  46. void setFragment(const std::string &fragment);
  47. void setHost(const std::string &host);
  48. void setPassword(const std::string &password);
  49. void setPath(const std::string &path);
  50. void setPort(int port);
  51. void setQuery(const std::string &query);
  52. void setScheme(const std::string &scheme);
  53. void setUserInfo(const std::string &userInfo);
  54. void setUserName(const std::string &userName);
  55. std::string toString() const;
  56. std::string userInfo() const;
  57. std::string userName() const;
  58. private:
  59. std::string scheme_;
  60. std::string userName_;
  61. std::string password_;
  62. std::string host_;
  63. std::string path_;
  64. int port_;
  65. std::string query_;
  66. std::string fragment_;
  67. };
  68. } // namespace AlibabaCloud
  69. #endif // CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_