#pragma once #include #include #include #include #include #include #include namespace jvalidate::detail { class Anchor { private: std::string content_; public: Anchor() = default; explicit Anchor(std::string_view content) : content_(content) { EXPECT_M(content.empty() || content[0] == '_' || std::isalpha(content[0]), "First character of an Anchor must be alphabetic or '_'"); EXPECT_M( std::all_of(content.begin(), content.end(), [](char c) { return std::isalnum(c) || c == '_' || c == '.' || c == '-'; }), "Illegal character(s) in anchor"); } explicit operator std::string const &() const { return content_; } bool empty() const { return content_.empty(); } friend std::ostream & operator<<(std::ostream & os, Anchor const & self) { return os << self.content_; } auto operator<=>(Anchor const & lhs) const = default; }; }