4 #include <initializer_list>
7 #include <boost/container/flat_set.hpp>
8 #include <boost/optional.hpp>
9 #include <boost/version.hpp>
22 template <
typename Key,
typename Compare,
typename Allocator>
25 has(
const boost::container::flat_set<Key, Compare, Allocator>& s,
28 return s.find(e) != s.end();
41 = boost::container::flat_set<letter_t, vcsn::less<L, letter_t>>;
72 boost::optional<letter_t> prev;
77 raise(
sname(),
": make: invalid end-of-file");
100 prev = L::get_letter(is);
117 #if 105700 <= BOOST_VERSION
142 ": add_letter: the special letter is reserved: ",
150 template <
typename Letter,
typename Enable =
void>
153 template <
typename Letter>
155 decltype((++
std::declval<Letter&>(),
void()))>
163 return add_range_<letter_t>(l1, l2);
166 template <
typename Letter>
170 for (; L::less(l1, l2); ++l1)
175 if (L::equal(l1, l2))
180 template <
typename Letter>
182 -> std::enable_if_t<!has_range<Letter>{},
set_alphabet&>
184 raise(*
this,
": does not support letter ranges");
205 require(!i.bad(), *
this,
": conv: invalid stream");
207 if (i.good() && i.peek() ==
'\\')
229 && (c = i.peek()) != EOF
237 letter_t l = L::get_letter(i,
true);
241 res = this->mul(res, l);
246 using iterator =
typename letters_t::const_iterator;
288 const char *sep =
"";
292 if (! this->is_letter(l))
294 this->
print(l, o, fmt);
295 if (! this->is_letter(l))
300 o << sep <<
"\\ldots";
const_iterator cend() const
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
set_alphabet & add_letter(letter_t l)
Modify this by adding l, and return *this.
static set_alphabet make(std::istream &is)
Whether the genset supports the range concept: whether we can use '++' on letters.
friend set_alphabet set_union(const set_alphabet &lhs, const set_alphabet &rhs)
Compute the union with another alphabet.
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
const_iterator end() const
A set of letters of type L.
set_alphabet(const letters_t &l)
Print as a parsable type string.
const_iterator find(letter_t l) const
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
typename letters_t::const_iterator const_iterator
auto add_range_(Letter l1, Letter l2) -> std::enable_if_t< has_range< Letter >
const_iterator begin() const
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
An input/output format for valuesets.
auto add_range(letter_t l1, letter_t l2) -> set_alphabet &
Add a range of letters, if it is accepted by the labelset.
set_alphabet &bool has(letter_t l) const
Whether l is a letter.
typename L::word_t word_t
Print as is. For instance, don't try to escape labels.
const_iterator cbegin() const
Print as rich UTF-8 text, escaped.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
word_t get_word(std::istream &i) const
Extract and return the next word from i.
friend set_alphabet set_intersection(const set_alphabet &lhs, const set_alphabet &rhs)
Compute the intersection with another alphabet.
boost::container::flat_set< letter_t, vcsn::less< L, letter_t >> letters_t
typename L::letter_t letter_t
typename letters_t::const_iterator iterator
auto add_range_(Letter, Letter) -> std::enable_if_t<!has_range< Letter >
bool empty() const
Whether this alphabet has no letters.
Print as plain (ASCII) text, escaped.
char eat(std::istream &is, char c)
Check lookahead character and advance.
std::ostream & print_set(std::ostream &o, format fmt={}) const
set_alphabet(std::initializer_list< letter_t > l)
letter_t value_type
The type of our values, when seen as a container.