libpniio
|
![]() |
Modules | |
Internal classes used by the parsers | |
Data Structures | |
class | pni::io::parser< T, ITERT > |
parser for primitive types More... | |
These classes are dedicated for generating objects from strings using the boost spirit parser framework. The heart of the parser fraemwork is the parser<T,ITERT> template. To use it include pni/io/parsers.hpp
in your source file. The pni::io::parser<T,ITERT> template currently works for
libpnicore
libpnicore
In general the usage of the template is fairly easy. The following code snipped reads a single scalar from a string
The ITERT template parameter normaly must not be set by the user. Its default value is pni::core::string::const_iterator
which should meet the most common use cases. In the same manner as a scalare one can read a comman separated list of floating point numbers from a string
When parsing a list of items to a vector all whitespace characters before or after the items are ignored or interpreted es separator symbols when whitespaces are used as separators. This is true for all types except for strings. Strings get some special treatment as described in the next section.
As always strings are different. When parsing a single string the input string is passed unchanged with all leading and trailing whitspace characters to the output. When parsing a list of strings to a std::vector some special rules apply