|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
Block identifier with alias support. More...
#include <BlockName.h>
Public Member Functions | |
| BlockName ()=default | |
| Default constructor. | |
| BlockName (const std::string &name) | |
| Constructs a BlockName from a single std::string. | |
| BlockName (const char *name) | |
| Constructs a BlockName from a C-style string. | |
| BlockName (std::initializer_list< std::string > names) | |
| Constructs a BlockName from an initializer list of aliases. | |
| BlockName (const std::unordered_set< std::string > &names) | |
| Constructs a BlockName from an existing set of aliases. | |
| std::unordered_set< std::string > | get_alias () const |
| Returns the set of aliases associated with this block. | |
| const std::string & | canonical () const |
| operator std::string () const | |
| Implicit conversion to std::string. | |
| bool | hasAlias (const std::string &alias) const |
| Checks whether a given alias is registered for this block. | |
| std::string | to_string () const |
| Returns a string representation of the block name. | |
| bool | operator== (const BlockName &other) const |
| Equality comparison between two BlockName objects. | |
| bool | operator!= (const BlockName &other) const |
| Inequality comparison between two BlockName objects. | |
| bool | operator== (const std::string &name) const |
| Comparison between a BlockName and a std::string. | |
| bool | operator== (const char *name) const |
| Comparison between a BlockName and a C-style string. | |
| bool | operator!= (const std::string &name) const |
| Inequality comparison between a BlockName and a std::string. | |
| BlockName & | addAlias (const std::string &alias) |
| Adds a new alias to this block. | |
| BlockName & | addAliases (const std::unordered_set< std::string > &as) |
| void | to_upper () |
| Converts all aliases to upper-case in-place. | |
| bool | operator< (const BlockName &other) const |
| Strict ordering operator for BlockName. | |
Friends | |
| BlockName | operator+ (const std::string &lhs, const BlockName &rhs) |
| Concatenation operator between a prefix string and a BlockName. | |
| std::ostream & | operator<< (std::ostream &os, const BlockName &block) |
| Stream output operator for BlockName. | |
Block identifier with alias support.
A BlockName internally stores a set of strings, each string being an alias that can refer to the same physical block. This is useful when supporting multiple conventions or legacy naming schemes (e.g. "SMINPUTS" vs "SMINPUT" or different capitalization).
Key design points:
Definition at line 59 of file BlockName.h.
|
default |
Default constructor.
Creates an empty BlockName without any aliases.
| BlockName::BlockName | ( | const std::string & | name | ) |
Constructs a BlockName from a single std::string.
The provided string is inserted as the only alias of the block.
| name | Initial block name / alias. |
Definition at line 3 of file BlockName.cpp.
| BlockName::BlockName | ( | const char * | name | ) |
Constructs a BlockName from a C-style string.
The provided C-string is converted to std::string and stored as the only alias of the block.
| name | Initial block name / alias (C-string). |
Definition at line 7 of file BlockName.cpp.
| BlockName::BlockName | ( | std::initializer_list< std::string > | names | ) |
Constructs a BlockName from an initializer list of aliases.
All strings in names are inserted into the internal alias set.
Example:
| names | List of aliases to associate with the block. |
Definition at line 11 of file BlockName.cpp.
| BlockName::BlockName | ( | const std::unordered_set< std::string > & | names | ) |
Constructs a BlockName from an existing set of aliases.
The provided set is copied into the internal representation.
| names | Set of aliases for the block. |
Definition at line 15 of file BlockName.cpp.
| BlockName & BlockName::addAlias | ( | const std::string & | alias | ) |
Adds a new alias to this block.
Inserts alias into the internal alias set. If the alias already exists, the set is unchanged.
| alias | New alias to add. |
Definition at line 68 of file BlockName.cpp.
| BlockName & BlockName::addAliases | ( | const std::unordered_set< std::string > & | as | ) |
| const std::string & BlockName::canonical | ( | ) | const |
Return the stable primary alias used for serialization.
Definition at line 26 of file BlockName.cpp.
| std::unordered_set< std::string > BlockName::get_alias | ( | ) | const |
Returns the set of aliases associated with this block.
The returned set is a copy; modifications to it do not affect the original BlockName instance.
Definition at line 22 of file BlockName.cpp.
| bool BlockName::hasAlias | ( | const std::string & | alias | ) | const |
Checks whether a given alias is registered for this block.
| alias | Alias to look for. |
alias is in the internal alias set, false otherwise. Definition at line 37 of file BlockName.cpp.
| BlockName::operator std::string | ( | ) | const |
Implicit conversion to std::string.
If the block has exactly one alias, that alias is returned. If multiple aliases are present, a warning is emitted via LOG_WARN and one arbitrary alias (the first element of the internal set) is returned, thus potentially discarding information.
Definition at line 33 of file BlockName.cpp.
| bool BlockName::operator!= | ( | const BlockName & | other | ) | const |
Inequality comparison between two BlockName objects.
| other | BlockName to compare with. |
Definition at line 52 of file BlockName.cpp.
| bool BlockName::operator!= | ( | const std::string & | name | ) | const |
Inequality comparison between a BlockName and a std::string.
| name | Alias to check. |
name is not a known alias of this block. Definition at line 64 of file BlockName.cpp.
| bool BlockName::operator< | ( | const BlockName & | other | ) | const |
Strict ordering operator for BlockName.
The ordering is defined by:
*this and other, andThis makes BlockName usable as a key in ordered containers such as std::map or std::set.
| other | BlockName to compare with. |
*this is lexicographically smaller than that of other. Definition at line 103 of file BlockName.cpp.
| bool BlockName::operator== | ( | const BlockName & | other | ) | const |
Equality comparison between two BlockName objects.
Two BlockName objects are considered equal if they share at least one common alias. In particular, this means that:
| other | BlockName to compare with. |
Definition at line 45 of file BlockName.cpp.
| bool BlockName::operator== | ( | const char * | name | ) | const |
Comparison between a BlockName and a C-style string.
Equivalent to comparing with a std::string constructed from name.
| name | Alias to check (C-string). |
name is a known alias, false otherwise. Definition at line 60 of file BlockName.cpp.
| bool BlockName::operator== | ( | const std::string & | name | ) | const |
Comparison between a BlockName and a std::string.
Returns true if name is one of the aliases of this block.
| name | Alias to check. |
name is a known alias, false otherwise. Definition at line 56 of file BlockName.cpp.
| std::string BlockName::to_string | ( | ) | const |
Returns a string representation of the block name.
Equivalent to the implicit conversion operator to std::string. Mainly provided for explicit, non-implicit usage.
Definition at line 41 of file BlockName.cpp.
| void BlockName::to_upper | ( | ) |
Converts all aliases to upper-case in-place.
For each stored alias, all characters are transformed using std::toupper. The resulting set of upper-case aliases replaces the original one.
This is often used to enforce the conventional SLHA behavior that block names are case-insensitive but typically stored in upper case.
Definition at line 92 of file BlockName.cpp.
Concatenation operator between a prefix string and a BlockName.
Creates a new BlockName whose aliases are obtained by prefixing each alias of rhs with lhs.
Example:
| lhs | Prefix string. |
| rhs | BlockName whose aliases will be prefixed. |
Definition at line 74 of file BlockName.cpp.
|
friend |
Stream output operator for BlockName.
All aliases are written to the stream, separated by '/'. The order is determined by the iteration order of the internal unordered_set and is therefore not guaranteed to be stable.
Example output: "SMINPUTS/sminputs".
| os | Output stream. |
| block | BlockName to print. |
Definition at line 82 of file BlockName.cpp.