1 #ifndef VCSN_ALPHABETS_SETALPHA_HH
2 # define VCSN_ALPHABETS_SETALPHA_HH
5 # include <initializer_list>
8 # include <boost/optional.hpp>
32 virtual std::string
vname(
bool full =
true)
const
34 std::string res =
sname();
63 boost::optional<letter_t> prev;
69 raise(
"invalid end-of-file");
77 if (prev == boost::none)
83 for (
letter_t l = prev.get(); l <= l2; ++l)
91 prev = L::get_letter(is);
125 assert(l != this->
template special<letter_t>());
150 "conv: invalid stream");
152 if (i.good() && i.peek() ==
'\\')
157 "invalid label: unexpected \\",
str_escape(c));
165 && (c = i.peek()) != EOF
174 res = this->concat(res, l);
180 using iterator =
typename letters_t::const_iterator;
211 if (format ==
"latex")
214 const char *sep =
"";
222 else if (format ==
"text")
225 raise(
"invalid format: ", format);
230 template <
typename L2>
231 friend set_alphabet<L2>
238 template <
typename L2>
252 #endif // !VCSN_ALPHABETS_SETALPHA_HH
const_iterator cend() const
typename letters_t::const_iterator iterator
std::ostream & print_set(std::ostream &o, symbol format=symbol{"text"}) const
set_alphabet(const letters_t &l)
typename L::word_t word_t
set_alphabet & add_letter(letter_t l)
Modify this by adding l, and return *this.
boost::flyweight< std::string, boost::flyweights::no_tracking > symbol
An internalized string.
friend set_alphabet< L2 > intersection(const set_alphabet< L2 > &lhs, const set_alphabet< L2 > &rhs)
Compute the intersection with another alphabet.
typename letters_t::const_iterator const_iterator
std::ostream & str_escape(std::ostream &os, const std::string &str)
Output a string, escaping special characters.
static set_alphabet make(std::istream &is)
static std::string sname()
word_t get_word(std::istream &i) const
Extract and return the next word from i.
letter_t value_type
The type of our values, when seen as a container.
const_iterator begin() const
friend set_alphabet< L2 > get_union(const set_alphabet< L2 > &lhs, const set_alphabet< L2 > &rhs)
Compute the union with another alphabet.
std::set< letter_t > letters_t
std::istringstream is
The input stream: the specification to translate.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
const_iterator find(letter_t l) const
const_iterator end() const
bool has(letter_t l) const
Whether l is a letter.
char eat(std::istream &is, char c)
Check lookahead character and advance.
virtual std::string vname(bool full=true) const
set_alphabet(const std::initializer_list< letter_t > &l)
const_iterator cbegin() const
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
typename L::letter_t letter_t