|  | Home | Libraries | People | FAQ | More | 
The string generators described in this section are:
            The string generator
            emits a string of characters. The string
            generator is implicitly verbatim: the delimit
            parser is not applied in between characters of the string. The string generator has an associated
            Character
            Encoding Namespace. This is needed when doing basic operations
            such as forcing lower or upper case. Examples:
          
string("Hello") string(L"Hello") string(s) // s is a std::string
            lit, like string, also emits a string of characters.
            The main difference is that lit
            does not consumes an attribute. A plain string like "hello"
            or a std::basic_string is equivalent to a lit. Examples:
          
"Hello" lit("Hello") lit(L"Hello") lit(s) // s is a std::string
// forwards to <boost/spirit/home/karma/string/lit.hpp> #include <boost/spirit/include/karma_string.hpp>
Also, see Include Structure.
| Name | 
|---|
| 
                       | 
| 
                       | 
            In the table above, ns
            represents a Character
            Encoding Namespace used by the corresponding string generator.
          
Notation
sCharacter-class specific string (See Character Class Types), or a Lazy Argument that evaluates to a character-class specific string value
S
                  The type of a character-class specific string s.
                
ns
            Semantics of an expression is defined only where it differs from, or
            is not defined in PrimitiveGenerator.
          
| Expression | Description | 
|---|---|
| 
                       | 
                      Generate the string literal  | 
| 
                       | 
                      Generate the string literal  | 
| 
                       | 
                      Generate the string provided by a mandatory attribute interpreted
                      in the character set defined by  | 
| 
                       | 
                      Generate the string  | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
              The generators  | 
| ![[Caution]](../../../../images/caution.png) | Caution | 
|---|---|
| 
              The generator  | 
| Expression | Attribute | 
|---|---|
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
              In addition to their usual attribute of type  | 
O(N), where N is the number of characters emitted by the string generator
| ![[Note]](../../../../images/note.png) | 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/support_utree.hpp> #include <boost/phoenix/core.hpp> #include <boost/phoenix/operator.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/proto/deep_copy.hpp> #include <iostream> #include <string>
Some using declarations:
using boost::spirit::karma::lit; using boost::spirit::ascii::string;
            Basic usage of string
            generators:
          
test_generator("abc", "abc"); test_generator("abc", lit("abc")); test_generator("abc", lit(std::string("abc"))); test_generator_attr("abc", string, "abc"); test_generator("abc", string("abc")); test_generator("abc", string(std::string("abc"))); test_generator_attr("abc", string("abc"), "abc"); test_generator_attr("", string("abc"), "cba"); // fails (as "abc" != "cba")