![]() |
Home | Libraries | People | FAQ | More |
The library has the full repertoire of single character generators for
character classification. This includes the usual alnum,
alpha, digit, xdigit,
etc. generators. These generators have an associated Character
Encoding Namespace. This is needed when doing basic operations
such as forcing lower or upper case.
// forwards to <boost/spirit/home/karma/char/char_class.hpp> #include <boost/spirit/include/karma_char_class.hpp>
Also, see Include Structure.
|
Name |
|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In the table above, ns
represents a Character
Encoding Namespace used by the corresponding character class generator.
All listed generators have a mandatory attribute Ch
and will not compile if no attribute is associated.
Notation
Semantics of an expression is defined only where it differs from, or
is not defined in PrimitiveGenerator.
|
Expression |
Semantics |
|---|---|
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the mandatory attribute satisfies the concept of |
|
|
If the optional attribute satisfies the concept of |
Possible values for ns
are described in the section Character
Encoding Namespace.
![]() |
Note |
|---|---|
|
The generators std::string s; std::back_insert_iterator<std::string> out(s); generate(out, lower[alpha], 'a'); // succeeds emitting 'a' generate(out, lower[alpha], 'A'); // fails
The generator directive |
All listed character class generators can take any attribute
Ch. All character class generators (exceptspace) require an attribute and will fail compiling otherwise.
![]() |
Note |
|---|---|
In addition to their usual attribute of type |
O(1)
The complexity is constant as the generators emit not more than one character per invocation.
![]() |
Note |
|---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some includes:
#include <boost/spirit/include/karma.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/fusion/include/std_pair.hpp> #include <iostream> #include <string>
Some using declarations:
using boost::spirit::karma::alpha; using boost::spirit::karma::upper;
Basic usage of an alpha
generator:
test_generator_attr("a", alpha, 'a'); test_generator_attr("A", alpha, 'A'); test_generator_attr("", alpha, '1'); // fails (as isalpha('1') is false) test_generator_attr("A", upper[alpha], 'A'); test_generator_attr("", upper[alpha], 'a'); // fails (as isupper('a') is false)