3 #include <wordring/whatwg/html/parsing/atom_defs.hpp>
4 #include <wordring/whatwg/html/parsing/atom_tbl.hpp>
6 #include <wordring/whatwg/infra/unicode.hpp>
10 #include <type_traits>
27 template <
typename String,
typename Name>
30 template <
typename String1,
typename Name1>
33 template <
typename String1,
typename Name1>
36 template <
typename String1,
typename Name1>
39 template <
typename String1,
typename Name1>
42 template <
typename String1,
typename Name1>
45 template <
typename String1,
typename Name1>
48 template <
typename String1,
typename Name1>
51 template <
typename String1,
typename Name1>
54 template <
typename String1,
typename Name1>
57 template <
typename String1,
typename Name1>
61 using string_type = String;
62 using name_type = Name;
67 , m_i(
static_cast<name_type
>(0))
73 , m_i(
static_cast<name_type
>(0))
77 if constexpr (std::is_same_v<name_type, ns_name>)
79 auto it = ns_uri_atom_tbl.find(encoding_cast<std::u32string>(s));
80 if (it != ns_uri_atom_tbl.end()) m_i = it->second;
82 else if constexpr (std::is_same_v<name_type, tag_name>)
84 auto it = tag_atom_tbl.find(encoding_cast<std::u32string>(s));
85 if (it != tag_atom_tbl.end()) m_i = it->second;
87 else if constexpr (std::is_same_v<name_type, attribute_name>)
89 auto it = attribute_atom_tbl.find(encoding_cast<std::u32string>(s));
90 if (it != attribute_atom_tbl.end()) m_i = it->second;
105 operator string_type()
const
109 if (!m_string.empty())
return m_string;
112 std::uint32_t i =
static_cast<std::uint32_t
>(m_i);
114 if constexpr (std::is_same_v<name_type, ns_name>) s = ns_uri_tbl[i];
115 else if constexpr (std::is_same_v<name_type, tag_name>) s = tag_name_tbl[i];
116 else s = attribute_name_tbl[i];
118 return encoding_cast<string_type>(s);
121 operator name_type()
const {
return m_i; }
124 string_type m_string;
128 template <
typename String1,
typename Name1>
129 inline bool operator==(basic_html_atom<String1, Name1>
const& lhs, basic_html_atom<String1, Name1>
const& rhs)
131 if (lhs.m_i !=
static_cast<Name1
>(0) && rhs.m_i !=
static_cast<Name1
>(0))
return lhs.m_i == rhs.m_i;
132 return static_cast<String1
>(lhs) ==
static_cast<String1
>(rhs);
135 template <
typename String1,
typename Name1>
136 inline bool operator==(basic_html_atom<String1, Name1>
const& lhs, Name1 i)
138 return lhs == basic_html_atom<String1, Name1>(i);
141 template <
typename String1,
typename Name1>
142 inline bool operator==(Name1 i, basic_html_atom<String1, Name1>
const& rhs)
144 return basic_html_atom<String1, Name1>(i) == rhs;
147 template <
typename String1,
typename Name1>
148 inline bool operator==(basic_html_atom<String1, Name1>
const& lhs, String1
const& s)
150 return lhs == basic_html_atom<String1, Name1>(s);
153 template <
typename String1,
typename Name1>
154 inline bool operator==(String1
const& s, basic_html_atom<String1, Name1>
const& rhs)
156 return basic_html_atom<String1, Name1>(s) == rhs;
159 template <
typename String1,
typename Name1>
160 inline bool operator!=(basic_html_atom<String1, Name1>
const& lhs, basic_html_atom<String1, Name1>
const& rhs)
162 return !(lhs == rhs);
165 template <
typename String1,
typename Name1>
166 inline bool operator!=(basic_html_atom<String1, Name1>
const& lhs, Name1 i)
172 template <
typename String1,
typename Name1>
173 inline bool operator!=(Name1 i, basic_html_atom<String1, Name1>
const& rhs)
178 template <
typename String1,
typename Name1>
179 inline bool operator!=(basic_html_atom<String1, Name1>
const& lhs, String1
const& s)
184 template <
typename String1,
typename Name1>
185 inline bool operator!=(String1
const& s, basic_html_atom<String1, Name1>
const& rhs)