uri.h 623 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <string>
  3. #include <string_view>
  4. #include <jvalidate/detail/compare.h>
  5. namespace jvalidate::detail {
  6. class URI {
  7. private:
  8. std::string content_;
  9. public:
  10. URI() = default;
  11. explicit URI(std::string_view content) : content_(content) {
  12. if (content_.back() == '#') {
  13. content_.pop_back();
  14. }
  15. }
  16. explicit operator std::string const &() const { return content_; }
  17. bool empty() const { return content_.empty(); }
  18. friend std::ostream & operator<<(std::ostream & os, URI const & self) {
  19. return os << self.content_;
  20. }
  21. auto operator<=>(URI const & lhs) const = default;
  22. };
  23. }