From: Guilherme Maciel Ferreira Date: Sun, 19 Feb 2012 18:02:04 +0000 (-0200) Subject: Added index suffix to the parameters names. X-Git-Tag: v1.3~11^2~7 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=b11fcd7293bca947899d1bd45c3d9e0b0458983a;p=pingcheck Added index suffix to the parameters names. --- diff --git a/src/host/messagepayload.cpp b/src/host/messagepayload.cpp index 8a46bae..ab738bc 100644 --- a/src/host/messagepayload.cpp +++ b/src/host/messagepayload.cpp @@ -198,24 +198,24 @@ void MessagePayload::append( /** * @brief Retrieve 16 bits from the payload buffer. * - * @param left_byte The index of the left byte. - * @param right_byte The index of the right byte. + * @param left_byte_index The index of the left byte. + * @param right_byte_index The index of the right byte. * - * @return a concatenation of the byte indexed by @a left_byte with the byte - * indexed by @a right_byte. + * @return A concatenation of the byte indexed by @a left_byte_index with the byte + * indexed by @a right_byte_index. */ uint16_t MessagePayload::decode16( - const int left_byte, - const int right_byte + const int left_byte_index, + const int right_byte_index ) const { - BOOST_ASSERT( ( 0 <= left_byte ) && ( left_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( ( 0 <= right_byte ) && ( right_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( left_byte < right_byte ); - BOOST_ASSERT( ( ( right_byte - left_byte ) + 1 ) == sizeof(uint16_t) ); + BOOST_ASSERT( ( 0 <= left_byte_index ) && ( left_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( ( 0 <= right_byte_index ) && ( right_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( left_byte_index < right_byte_index ); + BOOST_ASSERT( ( ( right_byte_index - left_byte_index ) + 1 ) == sizeof(uint16_t) ); - uint32_t value = static_cast( Payload[ left_byte ] << 8 ); - value += static_cast( Payload[ right_byte ] ); + uint32_t value = static_cast( Payload[ left_byte_index ] << 8 ); + value += static_cast( Payload[ right_byte_index ] ); BOOST_ASSERT( value <= numeric_limits::max() ); @@ -225,56 +225,56 @@ uint16_t MessagePayload::decode16( /** * @brief Store 16 bits in the payload buffer. * - * @param left_byte The index of the left byte. - * @param right_byte The index of the right byte. - * @param value a 16 bits data be saved in the bytes indexed by @a left_byte and - * @a right_byte. + * @param left_byte_index The index of the left byte. + * @param right_byte_index The index of the right byte. + * @param value A 16-bit data to be saved in the bytes indexed by + * @a left_byte_index and @a right_byte_index. * * @return void */ void MessagePayload::encode16( - const int left_byte, - const int right_byte, + const int left_byte_index, + const int right_byte_index, const uint16_t value ) { - BOOST_ASSERT( ( 0 <= left_byte ) && ( left_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( ( 0 <= right_byte ) && ( right_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( left_byte < right_byte ); - BOOST_ASSERT( ( ( right_byte - left_byte ) + 1 ) == sizeof(uint16_t) ); + BOOST_ASSERT( ( 0 <= left_byte_index ) && ( left_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( ( 0 <= right_byte_index ) && ( right_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( left_byte_index < right_byte_index ); + BOOST_ASSERT( ( ( right_byte_index - left_byte_index ) + 1 ) == sizeof(uint16_t) ); - Payload[ left_byte ] = static_cast( value >> 8 ); - Payload[ right_byte ] = static_cast( value & 0xFF ); + Payload[ left_byte_index ] = static_cast( value >> 8 ); + Payload[ right_byte_index ] = static_cast( value & 0xFF ); } /** * @brief Retrieve 32 bits from the payload buffer. * - * @param first_byte The index of the first byte out of 4. - * @param last_byte The index of the last byte out of 4. + * @param first_byte_index The index of the first byte out of 4. + * @param last_byte_index The index of the last byte out of 4. * - * @return a concatenation of 4 bytes, from the byte indexed by @a first_byte to - * the byte indexed by @a last_byte. + * @return a concatenation of 4 bytes, from the byte indexed by + * @a first_byte_index to the byte indexed by @a last_byte_index. */ uint32_t MessagePayload::decode32( - const int first_byte, - const int last_byte + const int first_byte_index, + const int last_byte_index ) const { - BOOST_ASSERT( ( 0 <= first_byte ) && ( first_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( ( 0 <= last_byte ) && ( last_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( first_byte < last_byte ); - BOOST_ASSERT( ( ( last_byte - first_byte ) + 1 ) == sizeof(uint32_t) ); + BOOST_ASSERT( ( 0 <= first_byte_index ) && ( first_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( ( 0 <= last_byte_index ) && ( last_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( first_byte_index < last_byte_index ); + BOOST_ASSERT( ( ( last_byte_index - first_byte_index ) + 1 ) == sizeof(uint32_t) ); - int current_byte = first_byte; + int current_byte_index = first_byte_index; - uint64_t value = static_cast( Payload[ current_byte ] << 24 ); - value += static_cast( Payload[ ++current_byte ] << 16 ); - value += static_cast( Payload[ ++current_byte ] << 8 ); - value += static_cast( Payload[ ++current_byte ] ); + uint64_t value = static_cast( Payload[ current_byte_index ] << 24 ); + value += static_cast( Payload[ ++current_byte_index ] << 16 ); + value += static_cast( Payload[ ++current_byte_index ] << 8 ); + value += static_cast( Payload[ ++current_byte_index ] ); BOOST_ASSERT( value <= numeric_limits::max() ); - BOOST_ASSERT( current_byte == last_byte ); + BOOST_ASSERT( current_byte_index == last_byte_index ); return static_cast( value ); } @@ -282,32 +282,32 @@ uint32_t MessagePayload::decode32( /** * @brief Store 32 bits in the payload buffer. * - * @param first_byte The index of the first byte out of 4. - * @param last_byte The index of the last byte out of 4. - * @param value a 32 bits data be saved in the bytes indexed from the @a first_byte - * to the @a last_byte. + * @param first_byte_index The index of the first byte out of 4. + * @param last_byte_index The index of the last byte out of 4. + * @param value A 32-bit data to be saved in the bytes indexed from + * the @a first_byte_index to the @a last_byte_index. * * @return void */ void MessagePayload::encode32( - const int first_byte, - const int last_byte, + const int first_byte_index, + const int last_byte_index, const uint32_t value ) { - BOOST_ASSERT( ( 0 <= first_byte ) && ( first_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( ( 0 <= last_byte ) && ( last_byte < static_cast(PayloadSizeInBytes) ) ); - BOOST_ASSERT( first_byte < last_byte ); - BOOST_ASSERT( ( ( last_byte - first_byte ) + 1 ) == sizeof(uint32_t) ); + BOOST_ASSERT( ( 0 <= first_byte_index ) && ( first_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( ( 0 <= last_byte_index ) && ( last_byte_index < static_cast(PayloadSizeInBytes) ) ); + BOOST_ASSERT( first_byte_index < last_byte_index ); + BOOST_ASSERT( ( ( last_byte_index - first_byte_index ) + 1 ) == sizeof(uint32_t) ); - int current_byte = first_byte; + int current_byte_index = first_byte_index; - Payload[ current_byte ] = static_cast( ( value >> 24 ) & 0xFF ); - Payload[ ++current_byte ] = static_cast( ( value >> 16 ) & 0xFF ); - Payload[ ++current_byte ] = static_cast( ( value >> 8 ) & 0xFF ); - Payload[ ++current_byte ] = static_cast( value & 0xFF ); + Payload[ current_byte_index ] = static_cast( ( value >> 24 ) & 0xFF ); + Payload[ ++current_byte_index ] = static_cast( ( value >> 16 ) & 0xFF ); + Payload[ ++current_byte_index ] = static_cast( ( value >> 8 ) & 0xFF ); + Payload[ ++current_byte_index ] = static_cast( value & 0xFF ); - BOOST_ASSERT( current_byte == last_byte ); + BOOST_ASSERT( current_byte_index == last_byte_index ); } /** diff --git a/src/host/messagepayload.h b/src/host/messagepayload.h index e88cb9c..7425bf7 100644 --- a/src/host/messagepayload.h +++ b/src/host/messagepayload.h @@ -44,12 +44,12 @@ public: ); uint16_t decode16( - const int left_byte, - const int right_byte + const int left_byte_index, + const int right_byte_index ) const; void encode16( - const int left_byte, - const int right_byte, + const int left_byte_index, + const int right_byte_index, const uint16_t value );