]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/metaparse/doc/one_char_except_c.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / one_char_except_c.qbk
CommitLineData
7c673cae
FG
1[#one_char_except_c]
2[section one_char_except_c]
3
4[h1 Synopsis]
5
6 template <char C1, char C2, /* ... */, char Cn>
7 struct one_char_except_c;
8
9This is a [link parser parser].
10
11[table Arguments
12 [[Name] [Type]]
13 [[`C1`..`Cn`] [character values]]
14]
15
16[h1 Description]
17
18`one_char_except_c` accepts one character except any of `C1` ... `Cn`. When the
19input is empty or begins with one of the non-accepted characters,
20`one_char_except_c` rejects the input. Otherwise it accepts the input and the
21result of parsing is the character value.
22
23The maximum number of template arguments this class can have is the value the
24macro `BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE` expands to. Its default value
25is 10.
26
27[h1 Header]
28
29 #include <boost/metaparse/one_char_except_c.hpp>
30
31[h1 Expression semantics]
32
33For any `s` compile-time string and `c1`, ..., `cn` characters the following are
34equivalent
35
36 one_char_except_c<c1, ..., cn>::apply<s, pos>
37
38 boost::metaparse::one_char::apply<s, pos>
39
40when `s` is empty or it begins with a character other than `c1`, ..., `cn`.
41Otherwise `one_char_except_c<c1, ..., cn>::appl<s, pos>` returns a parsing
42error.
43
44[h1 Example]
45
46 #include <boost/metaparse/one_char_except_c.hpp>
47 #include <boost/metaparse/lit_c.hpp>
48 #include <boost/metaparse/middle_of.hpp>
49 #include <boost/metaparse/repeated.hpp>
50 #include <boost/metaparse/start.hpp>
51 #include <boost/metaparse/string.hpp>
52 #include <boost/metaparse/get_result.hpp>
53
54 #include <boost/mpl/vector.hpp>
55 #include <boost/mpl/char.hpp>
56 #include <boost/mpl/equal.hpp>
57
58 using namespace boost::metaparse;
59
60 using string_literal_parser =
61 middle_of<lit_c<'"'>, repeated<one_char_except_c<'"'>>, lit_c<'"'>>;
62
63 static_assert(
64 boost::mpl::equal<
65 boost::mpl::vector<
66 boost::mpl::char_<'h'>,
67 boost::mpl::char_<'e'>,
68 boost::mpl::char_<'l'>,
69 boost::mpl::char_<'l'>,
70 boost::mpl::char_<'o'>
71 >,
72 get_result<
73 string_literal_parser::apply<BOOST_METAPARSE_STRING("\"hello\""), start>
74 >::type
75 >::type::value,
76 "it should return the content of the string literal"
77 );
78
79[endsect]
80