17 #ifndef AWALI_LABELSET_LETTERSET_HH
18 # define AWALI_LABELSET_LETTERSET_HH
24 #include <awali/common/json/node.cc>
28 #include <awali/common/parse_exception.cc>
41 template <
typename GenSet>
61 : genset_(std::make_shared<const genset_t>(gs))
64 letterset(
const std::initializer_list<letter_t>& letters)
65 : genset_(std::make_shared<const
genset_t>(letters))
69 : genset_(std::make_shared<const
genset_t>(letters))
78 return "lal_" + genset_t::sname();
95 auto gs = genset_t::make(is);
104 return this->
genset().open(o);
113 template <
typename... Args>
116 return value_t{std::forward<Args>(args)...};
135 return genset_t::special_letter();
151 static constexpr
bool
157 static constexpr
bool
163 static constexpr
bool
175 static constexpr
bool
220 throw std::domain_error(
"invalid label");
225 parse(
const std::string& s,
size_t& p,
bool fixed_domain=
true)
const {
230 const_cast<genset_t&
>(*genset_).add_letter(v);
233 throw std::domain_error(
"invalid label");
239 std::set<value_t> res;
240 for (
auto r : this->convs_(i))
247 const std::string& =
"text")
const
259 else if (
format ==
"text")
262 raise(
"invalid format: ",
format);
267 template<
unsigned version = version::fsm_json>
269 version::check_fsmjson<version>();
275 = this->
genset().template to_json<version>()->object();
282 template<
unsigned version = version::fsm_json>
285 return this->
genset().template letter_to_json<version>(v);
289 template<
unsigned version = version::fsm_json>
292 return genset().template letter_from_json<version>(p);
293 raise(
"json parser Letterset");
299 return genset().transpose(v);
319 template <
typename GenSet>
327 template <
typename GenSet>
334 template<
typename T,
typename U>
336 std::string message{
"Impossible join : "};
337 message+=T::sname()+
","+U::sname();
338 throw std::runtime_error(message);
object_t * push_front(std::string key, node_t *node)
Implementation of labels are letters.
Definition: letterset.hh:43
std::set< letter_t > letters_t
Definition: letterset.hh:51
static value_t special() ATTRIBUTE_PURE
Definition: letterset.hh:133
value_t transpose(const value_t &v) const
Definition: letterset.hh:298
std::string vname(bool full=true) const
Definition: letterset.hh:81
static size_t hash(value_t v)
Definition: letterset.hh:192
value_t parse(const std::string &s, size_t &p, bool fixed_domain=true) const
Definition: letterset.hh:225
const genset_t & genset() const
Definition: letterset.hh:72
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: letterset.hh:255
static bool is_special(value_t v) ATTRIBUTE_PURE
Definition: letterset.hh:170
static bool equals(const value_t l, const value_t r)
Whether l == r.
Definition: letterset.hh:140
letterset(const genset_t &gs={})
Definition: letterset.hh:60
static constexpr bool has_one()
Definition: letterset.hh:152
bool open(bool o) const
Whether unknown letters should be added, or rejected.
Definition: letterset.hh:102
static size_t size(value_t)
Definition: letterset.hh:187
static letterset make(std::istream &is)
Build from the description in is.
Definition: letterset.hh:88
value_t conv(std::istream &i) const
Read one letter from i, return the corresponding label.
Definition: letterset.hh:214
std::ostream & print(const value_t &l, std::ostream &o, const std::string &="text") const
Definition: letterset.hh:246
bool is_valid(value_t v) const
Definition: letterset.hh:182
typename genset_t::letter_t letter_t
Definition: letterset.hh:49
typename wordset< genset_t >::word_t word_t
Definition: letterset.hh:50
static std::string sname()
Definition: letterset.hh:76
static constexpr bool is_letterized()
Definition: letterset.hh:164
std::shared_ptr< const genset_t > genset_ptr
Definition: letterset.hh:46
letter_t value_t
Definition: letterset.hh:53
static bool less_than(const value_t l, const value_t r)
Whether l < r.
Definition: letterset.hh:146
json::node_t * value_to_json(value_t v) const
Definition: letterset.hh:283
value_t value(Args &&... args) const
Value constructor.
Definition: letterset.hh:114
static constexpr bool is_free()
Definition: letterset.hh:107
word_t word(value_t v) const
Convert to a word.
Definition: letterset.hh:120
letterset(const std::initializer_list< letter_t > &letters)
Definition: letterset.hh:64
std::set< value_t > convs(std::istream &i) const
Definition: letterset.hh:237
static constexpr bool is_ratexpset()
Definition: letterset.hh:158
value_t value_from_json(json::node_t const *p) const
Definition: letterset.hh:291
static word_t letters_of(word_t v)
Prepare to iterate over the letters of v.
Definition: letterset.hh:127
json::node_t * to_json() const
Definition: letterset.hh:268
static constexpr bool is_one(value_t)
Definition: letterset.hh:176
GenSet genset_t
Definition: letterset.hh:45
letterset(const letters_t &letters)
Definition: letterset.hh:68
static value_t conv(self_type, value_t v)
Definition: letterset.hh:198
The semiring of floating Numbers.
Definition: r.hh:35
typename genset_t::word_t word_t
Definition: wordset.hh:42
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
Definition: map.hh:53
void eat(std::istream &is, char c)
Check lookahead character and advance.
Definition: stream.hh:62
auto join(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< join_t< Ctx1, Ctx2 >>
The union of two ratexpsets.
Definition: ratexpset.hh:445
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
Definition: ratexpset.hh:434
set_alphabet< L2 > get_union(const set_alphabet< L2 > &lhs, const set_alphabet< L2 > &rhs)
Definition: setalpha.hh:364
set_alphabet< L2 > intersection(const set_alphabet< L2 > &lhs, const set_alphabet< L2 > &rhs)
Definition: setalpha.hh:357
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
std::size_t hash_value(const T &v)
Definition: hash.hh:76
static const std::string full
Completely version of Awali as a std::string.
Definition: version.hh:42
Main namespace of Awali.
Definition: ato.hh:22
marker type for labelsets where labels are letters
Definition: kind.hh:76
static void make(std::istream &is)
Definition: kind.hh:76