From: Guilherme Maciel Ferreira Date: Sun, 21 Aug 2011 01:07:06 +0000 (-0300) Subject: Implemented a method to access the inner array pointer, this is necessary for memory... X-Git-Tag: v1.1^2~8 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=e2ca2bac85f0f7005a4a95e6319b90bebd329d20;p=pingcheck Implemented a method to access the inner array pointer, this is necessary for memory copies. --- diff --git a/src/host/messagepayload.cpp b/src/host/messagepayload.cpp index 1626301..d6cc358 100644 --- a/src/host/messagepayload.cpp +++ b/src/host/messagepayload.cpp @@ -111,6 +111,16 @@ uint8_t& MessagePayload::operator[]( size_t offset ) } /** + * @brief Get a pointer to the underlying array. + * + * @return a pointer to the array encapsulated by this class. + */ +uint8_t* MessagePayload::get() const +{ + return Payload.get(); +} + +/** * @brief Retrieve 16 bits from the payload buffer. * * @param left_byte the index of the left byte diff --git a/src/host/messagepayload.h b/src/host/messagepayload.h index 5b66a0a..85a226b 100644 --- a/src/host/messagepayload.h +++ b/src/host/messagepayload.h @@ -19,9 +19,10 @@ //----------------------------------------------------------------------------- /** - * @brief This class represents the contents of a network message. It provides - * means to encode and to decode data to network format (i.e. deal with - * endianness), and also can be treated like an ordinary array. + * @brief This class represents the contents of a network message. + * + * It provides means to encode and to decode data to network format (i.e. deal + * with endianness), and also can be treated like an ordinary array. */ class MessagePayload { @@ -35,6 +36,8 @@ public: const uint8_t& operator[]( std::size_t offset ) const; uint8_t& operator[]( std::size_t offset ); + uint8_t* get() const; + uint16_t decode16( const int left_byte, const int right_byte