37void AliasMap::_apply(std::string& name)
const {
43 for (std::size_t count = 0;
count <= _internal.size(); ++
count) {
44 Iterator i = _internal.lower_bound(name);
45 if (i != _internal.end() && i->first.size() == name.
size() && i->first == name) {
48 }
else if (i != _internal.begin()) {
54 if (i->first.size() < name.
size() && name.
compare(0, i->first.size(), i->first) == 0) {
55 name.
replace(0, i->first.size(), i->second);
64 (boost::format(
"Cycle detected in schema aliases involving name '%s'") % name).str());
75 if (i == _internal.end()) {
77 (boost::format(
"Alias '%s' not found") % name).str());
83 _internal[alias] = target;
84 auto table = _table.lock();
86 table->handleAliasChange(alias);
91 bool result = _internal.erase(alias);
92 auto table = _table.lock();
94 table->handleAliasChange(alias);
105 for (
const auto& entry : _internal) {
#define LSST_EXCEPT(type,...)
bool contains(AliasMap const &other) const
Return true if all aliases in this are also in other (with the same targets).
std::string apply(std::string const &name) const
Apply any aliases that match the given field name and return a de-aliased name.
Iterator begin() const
Return a iterator to the beginning of the map.
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias->target pairs.
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
std::string get(std::string const &alias) const
Return the target of the given alias.
std::size_t hash_value() const noexcept
Return a hash of this object.
void set(std::string const &alias, std::string const &target)
Add an alias to the schema or replace an existing one.
bool operator==(AliasMap const &other) const
Equality comparison.
Iterator end() const
Return a iterator to one past the end of the map.
std::size_t hashCombine(std::size_t seed) noexcept