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;
294 const char *sep =
"";
298 if (! this->is_letter(l))
300 this->
print(l, o, fmt);
301 if (! this->is_letter(l))
306 o << sep <<
"\\ldots";
std::ostream & print_set(std::ostream &o, format fmt={}) const
set_alphabet & add_letter(letter_t l)
Modify this by adding l, and return *this.
Print as is. For instance, don't try to escape labels.
char eat(std::istream &is, char c)
Check lookahead character and advance.
const_iterator find(letter_t l) const
Print as a parsable type string.
const_iterator begin() const
typename L::word_t word_t
boost::container::flat_set< letter_t, vcsn::less< L, letter_t >> letters_t
word_t get_word(std::istream &i) const
Extract and return the next word from i.
size_t size() const
Number of letters.
const_iterator cend() const
friend set_alphabet set_intersection(const set_alphabet &lhs, const set_alphabet &rhs)
Compute the intersection with another alphabet.
An input/output format for valuesets.
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
set_alphabet &bool has(letter_t l) const
Whether l is a letter.
static set_alphabet make(std::istream &is)
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
bool empty() const
Whether this alphabet has no letters.
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
Print as rich UTF-8 text, escaped.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
auto add_range_(Letter l1, Letter l2) -> std::enable_if_t< has_range< Letter >
const_iterator cbegin() const
set_alphabet(std::initializer_list< letter_t > l)
Print as plain (ASCII) text, escaped.
A set of letters of type L.
letter_t value_type
The type of our values, when seen as a container.
set_alphabet(const letters_t &l)
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
auto add_range_(Letter, Letter) -> std::enable_if_t<!has_range< Letter >
typename letters_t::const_iterator const_iterator
friend set_alphabet set_union(const set_alphabet &lhs, const set_alphabet &rhs)
Compute the union with another alphabet.
Whether the genset supports the range concept: whether we can use '++' on letters.
auto add_range(letter_t l1, letter_t l2) -> set_alphabet &
Add a range of letters, if it is accepted by the labelset.
const_iterator end() const
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
typename letters_t::const_iterator iterator
typename L::letter_t letter_t