X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParserBase.hh;h=6cf4f8e736d766f6855417a70365b6737cd775ff;hb=9a988902090d28007578e93bffd809f6bd913155;hp=69508b7cd3cb06d2cbd66b795494b66973ec90fa;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Packets/ParserBase.hh b/Packets/ParserBase.hh index 69508b7..6cf4f8e 100644 --- a/Packets/ParserBase.hh +++ b/Packets/ParserBase.hh @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -29,17 +29,30 @@ // Custom includes #include +#include #include #include "ParserBase.ih" ///////////////////////////////hh.p//////////////////////////////////////// -namespace satcom { -namespace pkf { - +namespace senf { + + namespace impl { struct ParserBase; } - struct nil {}; + struct nil + : public boost::iterator_facade + { + // Theese are declared to make nil a valid iterator. All + // access to an instance of this iterator however is invalid + // (these members are not implemented only declared) + char & dereference() const; + bool equal(nil other) const; + void increment(); + void decrement(); + void advance(int n); + int distance_to(nil other) const; + }; /** \brief Parser framework @@ -64,11 +77,11 @@ namespace pkf { To implement a new parser, write a template implementing the following members: - + \code template struct Parser_Example - : protected satcom::pkf::ParserBase + : protected senf::ParserBase { // fixed interface of all parser classes @@ -78,7 +91,7 @@ namespace pkf { Parse_Example() {} Parse_Example(Iterator const & i) : ParserBase(i) {} - + [static] unsigned bytes() { // return the size of the parsed header. This @@ -94,7 +107,7 @@ namespace pkf { // return true, if the data in the range [begin,end) // can be safely interpreted by the parser without // causing invalid memory access. This means, - // check, wether the data is truncated + // check, whether the data is truncated return static_cast(end-begin) >= bytes(); } @@ -128,9 +141,9 @@ namespace pkf { Parse_Field2 field2() const { return Parse_Field2 (this->i()+2); } }; \endcode - + Every parser must have some mandatory fixed members which are: - + - struct rebind: This structure allows the parser to be converted to a parser of the same type but with a different iterator. Parser may have more than the two standard @@ -140,10 +153,10 @@ namespace pkf { parameters must be provided from the outside template - byte_iterator: A typedef for the Iterator class used - + - Non Iterator constructor: This constructor is only used when the parser is inherited into a Packet class. - + - Iterator constructor: This constructor must call the corresponding ParserBase constructor. @@ -210,7 +223,7 @@ namespace pkf { /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ - + // default default constructor // default copy constructor // default copy assignment @@ -224,7 +237,7 @@ namespace pkf { static void init() {}; private: - + }; template @@ -250,15 +263,15 @@ namespace pkf { static void init() {} template static void init(typename SomePacket::ptr) {} - + private: Iterator i_; }; /** \brief Addtiional Parser information - - Parser_traits provids abstract information about an unknown + + Parser_traits provides abstract information about an unknown parser. Besides the information already available within the Parser it provides an additional 'fixed_sized' member which is true if and only if the Parser has a static bytes() member. @@ -280,8 +293,8 @@ namespace pkf { template unsigned min_bytes(); - -}} + +} ///////////////////////////////hh.e//////////////////////////////////////// //#include "ParserBase.cci" @@ -292,5 +305,8 @@ namespace pkf { // Local Variables: // mode: c++ -// c-file-style: "satcom" +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" // End: