Vcsn
2.0
Be Rational
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
kind.hh
Go to the documentation of this file.
1
#ifndef VCSN_CORE_KIND_HH
2
# define VCSN_CORE_KIND_HH
3
4
# include <istream>
5
# include <stdexcept>
6
# include <type_traits>
7
8
# include <
vcsn/misc/escape.hh
>
9
10
namespace
vcsn
11
{
12
26
27
# define DEFINE(Abbrev, Name) \
28
struct labels_are_ ## Name \
29
{ \
30
static std::string name() \
31
{ \
32
return "labels_are_" #Name; \
33
} \
34
static std::string sname() \
35
{ \
36
return #Abbrev; \
37
} \
38
\
39
static void make(std::istream& is) \
40
{ \
41
/* \
42
* name: lal_char(abc), ratexpset<law_char(xyz), b>. \
43
* ^^^ ^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ \
44
* | | | weightset \
45
* | | +-- gens \
46
* | +-- letter_type \
47
* +-- kind \
48
* \
49
* name: lao, ratexpset<law_char(xyz), b> \
50
* ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ \
51
* kind weightset \
52
*/
\
53
char kind[4]; \
54
is.get(kind, sizeof kind); \
55
if (sname() != kind) \
56
throw std::runtime_error("kind::make: unexpected: " \
57
+ str_escape(kind) \
58
+ ", expected: " + sname()); \
59
} \
60
\
61
}; \
62
\
63
template <typename Kinded> \
64
struct is_ ## Abbrev \
65
: std::is_same<typename Kinded::kind_t, labels_are_ ## Name>::type \
66
{}; \
67
\
68
template <typename Kinded, typename R = Kinded> \
69
using if_ ## Abbrev \
70
= typename std::enable_if<is_ ## Abbrev<Kinded>::value, R>::type
71
72
DEFINE
(lal, letters);
73
DEFINE
(lan, nullable);
74
DEFINE
(lao, one);
75
DEFINE
(lar, ratexps);
76
DEFINE
(lat, tuples);
77
DEFINE
(law, words);
78
79
# undef DEFINE
80
}
81
82
#endif // !VCSN_CORE_KIND_HH
DEFINE
#define DEFINE(Abbrev, Name)
Define the kinds, and auxiliary tools.
Definition:
kind.hh:27
escape.hh
vcsn
core
kind.hh
Generated by
1.8.7