1 #ifndef CASM_ParsingDictionary
2 #define CASM_ParsingDictionary
7 namespace ParsingDictionary_impl {
43 std::unique_ptr<ParsingDictionary<value_type> >
clone()
const {
44 return notstd::make_unique<ParsingDictionary<value_type> >(*this);
53 return this->
find(_name) != this->end();
56 void print_help(std::ostream &_stream, std::function<
bool(T
const &)> filter,
57 int width = 60,
int separation = 8)
const;
68 auto res =
find(_name);
75 for (; it != end(); ++it) {
77 if (min_dist < 0 || dist < min_dist) {
84 throw std::runtime_error(
85 "Invalid " + T::class_desc() +
" \"" + _name +
"\" specified.\n" +
86 " Did you mean \"" + res->name() +
"\"?\n");
95 std::function<
bool(T
const &)> filter,
96 int width,
int separation)
const {
99 for (
auto it = it_begin; it != it_end; ++it) {
100 if (filter(*it)) len =
max(len, it->name().size());
102 for (
auto it = it_begin; it != it_end; ++it) {
103 if (!filter(*it))
continue;
104 _stream << std::string(5,
' ') << it->name()
105 << std::string(len - it->name().size() + separation,
' ');
107 std::string::const_iterator str_end(it->description().cend());
108 for (std::string::const_iterator str_it = it->description().cbegin();
109 str_it != str_end; ++str_it) {
110 if (wcount >= width && isspace(*str_it)) {
111 _stream << std::endl << std::string(5 + len + separation,
' ');
118 _stream << std::endl << std::endl;
Parsing dictionary for obtaining the correct MoleculeAttribute given a name.
void print_help(std::ostream &_stream, std::function< bool(T const &)> filter, int width=60, int separation=8) const
notstd::unique_cloneable_map< std::string, T > Base
std::unique_ptr< ParsingDictionary< value_type > > clone() const
Base::value_type value_type
T const & lookup(const key_type &_name) const
Equivalent to find, but set 'home' and throws error with suggestion if.
bool contains(const key_type &_name) const
True if dictionary contains entry for.
Base::const_iterator const_iterator
Base::size_type size_type
An iterator over a UniqueMap.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
std::map wrapper to enforce a 1-1 ValueType->KeyType relationship
MapType::size_type size_type
iterator find(const key_type &key)
std::pair< iterator, bool > insert(const value_type &value)
Insert single value.
ParsingDictionary< T > make_parsing_dictionary()
GenericDatumFormatter< std::string, DataObject > name()
int dl_string_dist(const std::string &a, const std::string &b)
Computes the Damerescau-Levenshtein distance – the number of edits (deletions, insertions,...
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
T max(const T &A, const T &B)
Conversion Functor for inserting BasicTraits into unique_cloneable_map.
notstd::cloneable_ptr< T > operator()(const T &_t)