From e2ca2bac85f0f7005a4a95e6319b90bebd329d20 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 20 Aug 2011 22:07:06 -0300 Subject: [PATCH] Implemented a method to access the inner array pointer, this is necessary for memory copies. --- src/host/messagepayload.cpp | 10 ++++++++++ src/host/messagepayload.h | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) 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 -- 1.7.1