#include <senf/Packets/VariantParser.hh>
This is not really a collection parser (it does not provide a collection interface). However, it is not a composite parser or value parser either.
A variant parser will parse any number of sub-parsers discriminated by an arbitrary, policy defined condition. This is the parser to use, if the type and/or number of fields of a packet change depending on some condition.
typedef senf::VariantParser< MyAuxPolicy, senf::mpl::vector<senf::VoidPacketParser, TypeAParser, TypeBParser> > MyVariantParser;
When creating a new packet containing a variant parser, the variant parser will always be initialized to the first sub-parser.
Definition at line 80 of file VariantParser.hh.
Public Member Functions |
|
unsigned | variant () const |
Get current variant. |
|
template<unsigned N> | |
boost::mpl::at< parsers, boost::mpl::int_< N > >::type |
get () const |
Access sub-parser. |
|
template<unsigned N> | |
void | init () |
Re-initialize field. |
|
Parser interface |
|
static const size_type | init_bytes |
VariantParser (data_iterator i, state_type s) | |
VariantParser (AuxPolicy policy, data_iterator i, state_type s) | |
size_type | bytes () const |
void | init () |
senf::VariantParser< AuxPolicy, Parsers >:: | ||||
VariantParser | ( | data_iterator | i, | |
state_type | s | ) | ||
Definition at line 40 of file VariantParser.cti.
senf::VariantParser< AuxPolicy, Parsers >:: | ||||
VariantParser | ( | AuxPolicy | policy, | |
data_iterator | i, | |||
state_type | s | ) | ||
Definition at line 46 of file VariantParser.cti.
senf::PacketParserBase::size_type senf::VariantParser< AuxPolicy, Parsers >:: | ||||
bytes | () | |||
Definition at line 52 of file VariantParser.cti.
boost::mpl::at< typename senf::VariantParser< AuxPolicy, Parsers >::parsers, boost::mpl::int_< N > >::type senf::VariantParser< AuxPolicy, Parsers >:: | ||||
get | () | |||
Access sub-parser.
This call will return the sub-parser at index N. This call will fail, if the currently active variant() is not N.
Definition at line 79 of file VariantParser.cti.
void senf::VariantParser< AuxPolicy, Parsers >:: | ||||
init | () | |||
Re-initialize field.
This will reinitialize the field to the variant sub-parser at index N changing the currently selected variant.
void senf::VariantParser< AuxPolicy, Parsers >:: | ||||
init | () | |||
Definition at line 36 of file VariantParser.ct.
unsigned senf::VariantParser< AuxPolicy, Parsers >:: | ||||
variant | () | |||
Get current variant.
Get the currently selected variant index. The returned number directly indexes the list of sub parsers.
Definition at line 68 of file VariantParser.cti.
const size_type senf::VariantParser< AuxPolicy, Parsers >::init_bytes | ||||
[static] | ||||
Initial value:
senf::init_bytes< typename boost::mpl::at<parsers, boost::mpl::int_<0> >::type>::value + AuxPolicy::aux_bytes
Definition at line 95 of file VariantParser.hh.