8#include <unordered_set>
9#include <initializer_list>
21namespace fs = std::filesystem;
67 std::unordered_set<std::string> block_names;
70 static inline std::string upper_copy(std::string s) {
71 std::transform(s.begin(), s.end(), s.begin(),
72 [](
unsigned char c){ return static_cast<char>(std::toupper(c)); });
76 static inline std::unordered_set<std::string> split_aliases(
const std::string& s) {
77 std::unordered_set<std::string> out;
81 if (!cur.empty()) out.insert(cur);
83 }
else cur.push_back(ch);
85 if (!cur.empty()) out.insert(cur);
89 static std::unordered_set<std::string> split_slash_aliases(
const std::string& s) {
90 std::unordered_set<std::string> out;
92 cur.reserve(s.size());
95 if (!cur.empty()) { out.insert(cur); cur.clear(); }
100 if (!cur.empty()) out.insert(cur);
142 BlockName(std::initializer_list<std::string> names);
151 BlockName(
const std::unordered_set<std::string>& names);
161 std::unordered_set<std::string>
get_alias()
const;
177 operator std::string()
const;
185 bool hasAlias(
const std::string& alias)
const;
226 bool operator==(
const std::string& name)
const;
244 bool operator!=(
const std::string& name)
const;
347 return !(rhs == lhs);
387 for (
const auto& name : p.get_alias()) {
388 h ^= std::hash<std::string>{}(name) + 0x9e3779b9 + (h << 6) + (h >> 2);
bool operator!=(const std::string &lhs, const BlockName &rhs)
Symmetric inequality between std::string and BlockName.
bool operator==(const std::string &lhs, const BlockName &rhs)
Symmetric comparison between std::string and BlockName.
Block identifier with alias support.
bool hasAlias(const std::string &alias) const
Checks whether a given alias is registered for this block.
BlockName & addAlias(const std::string &alias)
Adds a new alias to this block.
std::string to_string() const
Returns a string representation of the block name.
BlockName & addAliases(const std::unordered_set< std::string > &as)
std::unordered_set< std::string > get_alias() const
Returns the set of aliases associated with this block.
BlockName()=default
Default constructor.
const std::string & canonical() const
bool operator!=(const BlockName &other) const
Inequality comparison between two BlockName objects.
friend std::ostream & operator<<(std::ostream &os, const BlockName &block)
Stream output operator for BlockName.
friend BlockName operator+(const std::string &lhs, const BlockName &rhs)
Concatenation operator between a prefix string and a BlockName.
bool operator==(const BlockName &other) const
Equality comparison between two BlockName objects.
bool operator<(const BlockName &other) const
Strict ordering operator for BlockName.
void to_upper()
Converts all aliases to upper-case in-place.
Hash specialization for SymbolId<Tag>.
std::size_t operator()(const BlockName &p) const noexcept
Computes a hash value for a BlockName.