/**
* @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<int>(PayloadSizeInBytes) ) );
- BOOST_ASSERT( ( 0 <= right_byte ) && ( right_byte < static_cast<int>(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<int>(PayloadSizeInBytes) ) );
+ BOOST_ASSERT( ( 0 <= right_byte_index ) && ( right_byte_index < static_cast<int>(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<uint16_t>( Payload[ left_byte ] << 8 );
- value += static_cast<uint16_t>( Payload[ right_byte ] );
+ uint32_t value = static_cast<uint16_t>( Payload[ left_byte_index ] << 8 );
+ value += static_cast<uint16_t>( Payload[ right_byte_index ] );
BOOST_ASSERT( value <= numeric_limits<uint16_t>::max() );
/**
* @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<int>(PayloadSizeInBytes) ) );
- BOOST_ASSERT( ( 0 <= right_byte ) && ( right_byte < static_cast<int>(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<int>(PayloadSizeInBytes) ) );
+ BOOST_ASSERT( ( 0 <= right_byte_index ) && ( right_byte_index < static_cast<int>(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<uint8_t>( value >> 8 );
- Payload[ right_byte ] = static_cast<uint8_t>( value & 0xFF );
+ Payload[ left_byte_index ] = static_cast<uint8_t>( value >> 8 );
+ Payload[ right_byte_index ] = static_cast<uint8_t>( 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<int>(PayloadSizeInBytes) ) );
- BOOST_ASSERT( ( 0 <= last_byte ) && ( last_byte < static_cast<int>(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<int>(PayloadSizeInBytes) ) );
+ BOOST_ASSERT( ( 0 <= last_byte_index ) && ( last_byte_index < static_cast<int>(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<uint32_t>( Payload[ current_byte ] << 24 );
- value += static_cast<uint32_t>( Payload[ ++current_byte ] << 16 );
- value += static_cast<uint32_t>( Payload[ ++current_byte ] << 8 );
- value += static_cast<uint32_t>( Payload[ ++current_byte ] );
+ uint64_t value = static_cast<uint32_t>( Payload[ current_byte_index ] << 24 );
+ value += static_cast<uint32_t>( Payload[ ++current_byte_index ] << 16 );
+ value += static_cast<uint32_t>( Payload[ ++current_byte_index ] << 8 );
+ value += static_cast<uint32_t>( Payload[ ++current_byte_index ] );
BOOST_ASSERT( value <= numeric_limits<uint32_t>::max() );
- BOOST_ASSERT( current_byte == last_byte );
+ BOOST_ASSERT( current_byte_index == last_byte_index );
return static_cast<uint32_t>( value );
}
/**
* @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<int>(PayloadSizeInBytes) ) );
- BOOST_ASSERT( ( 0 <= last_byte ) && ( last_byte < static_cast<int>(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<int>(PayloadSizeInBytes) ) );
+ BOOST_ASSERT( ( 0 <= last_byte_index ) && ( last_byte_index < static_cast<int>(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<uint8_t>( ( value >> 24 ) & 0xFF );
- Payload[ ++current_byte ] = static_cast<uint8_t>( ( value >> 16 ) & 0xFF );
- Payload[ ++current_byte ] = static_cast<uint8_t>( ( value >> 8 ) & 0xFF );
- Payload[ ++current_byte ] = static_cast<uint8_t>( value & 0xFF );
+ Payload[ current_byte_index ] = static_cast<uint8_t>( ( value >> 24 ) & 0xFF );
+ Payload[ ++current_byte_index ] = static_cast<uint8_t>( ( value >> 16 ) & 0xFF );
+ Payload[ ++current_byte_index ] = static_cast<uint8_t>( ( value >> 8 ) & 0xFF );
+ Payload[ ++current_byte_index ] = static_cast<uint8_t>( value & 0xFF );
- BOOST_ASSERT( current_byte == last_byte );
+ BOOST_ASSERT( current_byte_index == last_byte_index );
}
/**