1 #ifndef VCSN_LABELSET_LETTERSET_HH
2 # define VCSN_LABELSET_LETTERSET_HH
20 template <
typename GenSet>
21 class letterset:
public detail::genset_labelset<GenSet>
30 using word_t =
typename genset_t::word_t;
42 :
letterset(std::make_shared<const genset_t>(gs))
45 letterset(
const std::initializer_list<letter_t>& letters)
54 std::string
vname(
bool full =
true)
const
65 eat(is,
"letterset<");
66 auto gs = genset_t::make(is);
76 return this->
genset().open(o);
85 template <
typename... Args>
88 return value_t{std::forward<Args>(args)...};
107 return genset_t::template special<value_t>();
123 static constexpr
bool
129 static constexpr
bool
135 static constexpr
bool
147 static constexpr
bool
188 std::set<value_t> res;
196 const std::string& =
"text")
const
206 if (format ==
"latex")
207 this->
genset().print_set(o, format);
208 else if (format ==
"text")
211 raise(
"invalid format: ", format);
219 template <
typename GenSet>
230 template <
typename GenSet>
244 template <
typename GenSet>
251 return {
get_union(lhs.genset(), rhs.genset())};
257 template <
typename GenSet>
265 #endif // !VCSN_LABELSET_LETTERSET_HH
value_t value(Args &&...args) const
Value constructor.
static std::string sname()
static type value(const letterset< GenSet > &ls)
std::shared_ptr< const genset_t > genset_ptr
std::set< T, Compare, Alloc > get_union(const std::set< T, Compare, Alloc > &set1, const std::set< T, Compare, Alloc > &set2)
The union of two sets.
word_t word(value_t v) const
Convert to a word.
static constexpr bool is_one(value_t)
letterset(const genset_ptr &gs)
static type value(const letterset< GenSet > &ls)
std::set< letter_t > letters_t
std::ostream & print(const value_t &l, std::ostream &o, const std::string &="text") const
static size_t hash(value_t v)
value_t conv(std::istream &i) const
Read one letter from i, return the corresponding label.
Implementation of labels are nullables (letter or empty).
static value_t conv(self_type, value_t v)
boost::flyweight< std::string, boost::flyweights::no_tracking > symbol
An internalized string.
typename genset_t::word_t word_t
std::ostream & str_escape(std::ostream &os, const std::string &str)
Output a string, escaping special characters.
static letterset make(std::istream &is)
Build from the description in is.
This class has no modeling purpose, it only serves to factor code common to letterset, nullableset and wordset.
std::string vname(bool full=true) const
std::size_t hash_value(const T &v)
std::set< value_t > convs(std::istream &i) const
typename genset_t::letter_t letter_t
static constexpr bool is_free()
static bool is_special(value_t v) ATTRIBUTE_PURE
static std::string sname()
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
std::istringstream is
The input stream: the specification to translate.
static value_t special() ATTRIBUTE_PURE
static constexpr bool has_one()
std::set< letter_t > convs_(std::istream &i) const
Read a range of letters.
static size_t size(value_t)
A structure that implements the computation of join(V1, V2).
typename genset_t::word_t word_t
ATTRIBUTE_PURE auto has(Args &&...args) const -> decltype(this->genset().has(std::forward< Args >(args)...))
bool is_valid(value_t v) const
static type join(const letterset< GenSet > &lhs, const letterset< GenSet > &rhs)
static bool less_than(const value_t l, const value_t r)
Whether l < r.
Provide a variadic mul on top of a binary mul(), and one().
letterset(const genset_t &gs={})
std::set< T, Compare, Alloc > intersection(const std::set< T, Compare, Alloc > &set1, const std::set< T, Compare, Alloc > &set2)
The intersection of two sets.
char eat(std::istream &is, char c)
Check lookahead character and advance.
letterset(const std::initializer_list< letter_t > &letters)
static bool equals(const value_t l, const value_t r)
Whether l == r.
static constexpr bool is_ratexpset()
std::ostream & print_set(std::ostream &o, symbol format=symbol{"text"}) const
typename genset_t::letter_t letter_t
Implementation of labels are letters.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
Implementation of labels are words.
The smallest nullableset which includes LabelSet.
static word_t letters_of(word_t v)
Prepare to iterate over the letters of v.
const genset_t & genset() const
variadic_mul_mixin< detail::r_impl > r
static constexpr bool is_letterized()
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
std::string vname(bool full=true) const