X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketParser.hh;h=3e568438acdef2ecac06a726c2aba9b59ba37258;hb=80c83d2565c50f8ad33af2be0f4cb3e5735cafcf;hp=5265872b717be22ef7faee360fa8aeb8787517e6;hpb=a1001797645cc68c869ef296f5e9ba13aa8e80c4;p=senf.git diff --git a/Packets/PacketParser.hh b/Packets/PacketParser.hh index 5265872..3e56843 100644 --- a/Packets/PacketParser.hh +++ b/Packets/PacketParser.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -264,10 +264,23 @@ namespace senf { here. The size of the interpreted is given by senf::bytes(parser instance). */ + + data_iterator i(size_type offset) const; ///< Return iterator \a offset bytes from the start + /**< The return value is the same as i() + \a + offset. However, the parser checks, that the iterator is + still within range of the raw data + container. Otherwise a TruncatedPacketException is + thrown. + + \throws TruncatedPacketException if the raw data + container does not hold at least \a offset bytes + starting at i(). */ + state_type state() const; ///< Return state of this parser /**< The value returned should be interpreted as an opaque value provided just to be forwarded to other parsers. */ + PacketData & data() const; ///< Access the packets raw data container /**< This member will return the raw data container holding the data which is parsed by \c this parser. */ @@ -282,6 +295,7 @@ namespace senf { /**< This is the constructor used by most parsers. The parameters are just forwarded from the derived classes constructor parameters. */ + PacketParserBase(data_iterator i, state_type s, size_type size); ///< Size checking constructor /**< In addition to the standard constructor, this @@ -303,6 +317,7 @@ namespace senf { bool check(size_type size) const; ///< Check size of data container /**< \returns \c true, if the data container holds at least \a size beginning at i(), \c false otherwise. */ + void validate(size_type size) const; ///< Validate size of data container /**< \throws TruncatedPacketException if the raw data container does not hold at least \a size bytes @@ -312,6 +327,7 @@ namespace senf { /**< Creates a new instance of \a Parser to parse data beginning at \a i. Automatically passes \a state() to the new parser. */ + template Parser parse(size_type n) const; ///< Create sub-parser /**< Creates a new instance of \a Parser to parse data * beginning at i() + \a n. Automatically passes \a @@ -323,7 +339,7 @@ namespace senf { parsers if needed. */ Packet packet() const; ///< Get packet this parser is parsing from - /**< \important This member should only be used from packet + /**< \note This member should only be used from packet parsers when access to previous or following packets is needed e.g. for calculating checksums etc. */