144 #ifndef HH_SENF_Packets_PacketParser_ 145 #define HH_SENF_Packets_PacketParser_ 1 148 #include <boost/utility/enable_if.hpp> 149 #include <boost/type_traits/is_base_of.hpp> 150 #include <boost/optional.hpp> 253 data_iterator
i()
const;
259 data_iterator
i(size_type offset)
const;
270 state_type
state()
const;
319 bool check(size_type size)
const;
323 void validate(size_type size)
const;
328 template <
class Parser> Parser
parse(data_iterator
i)
const;
333 template <
class Parser,
class Arg> Parser
parse(Arg
const & arg, data_iterator
i)
const;
339 template <
class Parser> Parser
parse(size_type n)
const;
344 template <
class Parser,
class Arg> Parser
parse(Arg
const & arg, size_type n)
const;
359 void resize(size_type oldSize, size_type newSize);
370 data_iterator end()
const;
393 template <
class Parser>
414 template <
class Parser>
432 template <
class Parser>
438 template <
class Parser>
439 typename boost::enable_if_c<
440 boost::is_base_of<PacketParserBase, Parser>::value
443 operator<<(Parser
const & target, Parser
const & source);
445 template <
class Parser>
446 typename boost::enable_if_c<
447 boost::is_base_of<PacketParserBase, Parser>::value
448 && ! senf::is_fixed<Parser>::value,
450 operator<<(Parser
const & target, Parser
const & source);
465 template <
class Parser>
466 Parser
operator<<(Parser
const & target, Parser
const & source);
470 template <
class Parser,
class Value>
471 typename boost::enable_if_c <
472 boost::is_base_of<PacketParserBase, Parser>::value
473 && ! boost::is_base_of<PacketParserBase, Value>::value,
475 operator<<(Parser target, Value
const & value);
485 template <
class Parser,
class Value>
486 Parser
operator<<(Parser target, Value
const & value);
490 template <
class Parser,
class Value>
491 typename boost::enable_if_c <
492 boost::is_base_of<PacketParserBase, Parser>::value
493 && ! boost::is_base_of<PacketParserBase, Value>::value,
495 operator<<(Parser target, boost::optional<Value>
const & value);
507 template <
class Parser,
class Value>
508 Parser operator<<(Parser target, boost::optional<Value>
const & value);
516 # include SENF_FIXED_PARSER() 521 template <
class Parser,
typename ValueType>
526 static size_type const fixed_bytes = ValueType::static_size;
531 value_type
value()
const {
return value_type::from_data(
i()); }
534 operator value_type ()
const;
537 Parser
const & operator= (value_type
const & other);
542 template <
class Parser,
typename ValueType>
545 template <
class Parser,
typename ValueType>
548 template <
class Parser,
typename ValueType>
551 template <
class Parser,
typename ValueType>
558 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_PacketParser_i_) 559 #define HH_SENF_Packets_PacketParser_i_ Packet packet() const
Get packet this parser is parsing from.
ParseHelpers public header.
void copy(ListParser< ListPolicy > const &listParser, OutputIterator result)
void value(value_type const &v)
PacketTypes public header.
PacketData * state_type
Type of the 'state' parameter.
SafeIterator public header.
PacketData public header.
unspecified_keyword_type parser
Parser parse(data_iterator i) const
Create sub-parser.
std::ostream & operator<<(std::ostream &os, Packet const &packet)
Return number of bytes to allocate to new object of given type.
PacketParserBase parser_base_type
Base type of the next parser.
Test, whether a parser is a fixed-size parser.
PacketParserBase::size_type bytes(Parser const &p)
Return raw size parsed by the given parser object.
PacketParserBase(data_iterator i, state_type s)
Standard constructor.
#define SENF_PARSER_FINALIZE(name)
Generate parser control members.
detail::packet::byte byte
Unsigned 8bit value, the raw value type.
bool operator==(ArrayValueParserBase< Parser, ValueType > const &parser, ValueType const &value)
void defaultInit() const
Default implementation.
Packet data STL-sequence view.
raw_container::size_type size_type
detail::packet::difference_type difference_type
Signed integral type.
data_iterator i() const
Return beginning of data to parse.
Default parser parsing nothing.
raw_container::iterator iterator
void init() const
Default implementation.
Re-validating data iterator.
detail::packet::size_type size_type
Unsigned integral type.
bool operator!=(ArrayValueParserBase< Parser, ValueType > const &parser, ValueType const &value)
bool check(size_type size) const
Check size of data container.
friend struct ParserProtector
raw_container::difference_type difference_type
void resize(size_type oldSize, size_type newSize)
Resize data container.
PacketData & data() const
Access the packets raw data container.
Iterator re-validating Parser wrapper.
void validate(size_type size) const
Validate size of data container.
state_type state() const
Return state of this parser.
ArrayValueParserBase< Parser, ValueType > Base
ParserProtector protect() const
detail::packet::iterator data_iterator
Raw data iterator type.