The Road to Clang-Format part 1
Whitespace: The Darkening
Change-Id: I9c0c355ddf22f9b27763c97e3e85079c135ae7a7
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/util/hei_bit_string.cpp b/src/util/hei_bit_string.cpp
index 55da5cd..25443a6 100755
--- a/src/util/hei_bit_string.cpp
+++ b/src/util/hei_bit_string.cpp
@@ -22,23 +22,23 @@
//------------------------------------------------------------------------------
-uint64_t BitString::getFieldRight( uint64_t i_pos, uint64_t i_len ) const
+uint64_t BitString::getFieldRight(uint64_t i_pos, uint64_t i_len) const
{
- HEI_ASSERT( nullptr != getBufAddr() ); // must to have a valid address
- HEI_ASSERT( 0 < i_len ); // must have at least one bit
- HEI_ASSERT( i_len <= UINT64_BIT_LEN ); // i_len length must be valid
- HEI_ASSERT( i_pos + i_len <= getBitLen() ); // field must be within range
+ HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
+ HEI_ASSERT(0 < i_len); // must have at least one bit
+ HEI_ASSERT(i_len <= UINT64_BIT_LEN); // i_len length must be valid
+ HEI_ASSERT(i_pos + i_len <= getBitLen()); // field must be within range
// Get the relative address of this byte and the relative starting position
// within the byte.
uint64_t relPos = 0;
- uint8_t * relAddr = getRelativePosition( relPos, i_pos );
+ uint8_t * relAddr = getRelativePosition(relPos, i_pos);
// Get the length of the target bit field within this byte and the length of
// the bit field for any remaining bits.
uint64_t bf_len = i_len;
uint64_t remain_len = 0;
- if ( UINT8_BIT_LEN < relPos + i_len )
+ if (UINT8_BIT_LEN < relPos + i_len)
{
// The target bit field crosses a byte boundary. So truncate the bit
// length for this byte and update the remaining length.
@@ -52,12 +52,12 @@
bf >>= UINT8_BIT_LEN - bf_len; // Right justify the value.
// Check for any remaining bits after this target byte.
- if ( 0 != remain_len )
+ if (0 != remain_len)
{
// Recursively call this function on the remaining bits and push them
// into the right side of the return value.
uint64_t val = static_cast<uint64_t>(bf) << remain_len;
- return val | getFieldRight( i_pos + bf_len, remain_len );
+ return val | getFieldRight(i_pos + bf_len, remain_len);
}
// Nothing more to do. Simply return this bit field.
@@ -66,23 +66,23 @@
//------------------------------------------------------------------------------
-void BitString::setFieldLeft( uint64_t i_pos, uint64_t i_len, uint64_t i_val )
+void BitString::setFieldLeft(uint64_t i_pos, uint64_t i_len, uint64_t i_val)
{
- HEI_ASSERT( nullptr != getBufAddr() ); // must to have a valid address
- HEI_ASSERT( 0 < i_len ); // must have at least one bit
- HEI_ASSERT( i_len <= UINT64_BIT_LEN ); // i_len length must be valid
- HEI_ASSERT( i_pos + i_len <= getBitLen() ); // field must be within range
+ HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
+ HEI_ASSERT(0 < i_len); // must have at least one bit
+ HEI_ASSERT(i_len <= UINT64_BIT_LEN); // i_len length must be valid
+ HEI_ASSERT(i_pos + i_len <= getBitLen()); // field must be within range
// Get the relative address of this byte and the relative starting position
// within the byte.
uint64_t relPos = 0;
- uint8_t * relAddr = getRelativePosition( relPos, i_pos );
+ uint8_t * relAddr = getRelativePosition(relPos, i_pos);
// Get the length of the target bit field within this byte and the length of
// the bit field for any remaining bits.
uint64_t bf_len = i_len;
uint64_t remain_len = 0;
- if ( UINT8_BIT_LEN < relPos + i_len )
+ if (UINT8_BIT_LEN < relPos + i_len)
{
// The target bit field crosses a byte boundary. So truncate the bit
// length for this byte and update the remaining length.
@@ -109,24 +109,24 @@
*relAddr = bf_l | bf | bf_r;
// Check for any remaining bits after this target byte.
- if ( 0 != remain_len )
+ if (0 != remain_len)
{
// Recursively call this function on the remaining bits.
- setFieldLeft( i_pos + bf_len, remain_len, i_val << bf_len );
+ setFieldLeft(i_pos + bf_len, remain_len, i_val << bf_len);
}
}
//------------------------------------------------------------------------------
-void BitString::setPattern( uint64_t i_sPos, uint64_t i_sLen,
- uint64_t i_pattern, uint64_t i_pLen )
+void BitString::setPattern(uint64_t i_sPos, uint64_t i_sLen, uint64_t i_pattern,
+ uint64_t i_pLen)
{
HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
HEI_ASSERT(0 < i_sLen); // must have at least one bit
HEI_ASSERT(i_sPos + i_sLen <= getBitLen()); // field must be within range
HEI_ASSERT(0 < i_pLen); // must have at least one bit
- HEI_ASSERT(i_pLen <= UINT64_BIT_LEN); // i_pLen length must be valid
+ HEI_ASSERT(i_pLen <= UINT64_BIT_LEN); // i_pLen length must be valid
// Get a bit string for the pattern subset (right justified).
// Note that we cannot use a BitStringBuffer here because this function
@@ -138,105 +138,105 @@
// Iterate the range in chunks the size of i_pLen.
uint64_t endPos = i_sPos + i_sLen;
- for ( uint64_t pos = i_sPos; pos < endPos; pos += i_pLen )
+ for (uint64_t pos = i_sPos; pos < endPos; pos += i_pLen)
{
// The true chunk size is either i_pLen or the leftovers at the end.
- uint64_t len = std::min( i_pLen, endPos - pos );
+ uint64_t len = std::min(i_pLen, endPos - pos);
// Get this chunk's pattern value, truncate (right justified) if needed.
- uint64_t pattern = bs.getFieldRight( 0, len );
+ uint64_t pattern = bs.getFieldRight(0, len);
// Set the pattern in this string.
- setFieldRight( pos, len, pattern );
+ setFieldRight(pos, len, pattern);
}
}
//------------------------------------------------------------------------------
-void BitString::setString( const BitString & i_sStr, uint64_t i_sPos,
- uint64_t i_sLen, uint64_t i_dPos )
+void BitString::setString(const BitString & i_sStr, uint64_t i_sPos,
+ uint64_t i_sLen, uint64_t i_dPos)
{
// Ensure the source parameters are valid.
- HEI_ASSERT( nullptr != i_sStr.getBufAddr() );
- HEI_ASSERT( 0 < i_sLen ); // at least one bit to copy
- HEI_ASSERT( i_sPos + i_sLen <= i_sStr.getBitLen() );
+ HEI_ASSERT(nullptr != i_sStr.getBufAddr());
+ HEI_ASSERT(0 < i_sLen); // at least one bit to copy
+ HEI_ASSERT(i_sPos + i_sLen <= i_sStr.getBitLen());
// Ensure the destination has at least one bit available to copy.
- HEI_ASSERT( nullptr != getBufAddr() );
- HEI_ASSERT( i_dPos < getBitLen() );
+ HEI_ASSERT(nullptr != getBufAddr());
+ HEI_ASSERT(i_dPos < getBitLen());
// If the source length is greater than the destination length than the
// extra source bits are ignored.
- uint64_t actLen = std::min( i_sLen, getBitLen() - i_dPos );
+ uint64_t actLen = std::min(i_sLen, getBitLen() - i_dPos);
// The bit strings may be in overlapping memory spaces. So we need to copy
// the data in the correct direction to prevent overlapping.
uint64_t sRelOffset = 0, dRelOffset = 0;
- uint8_t * sRelAddr = i_sStr.getRelativePosition( sRelOffset, i_sPos );
- uint8_t * dRelAddr = getRelativePosition( dRelOffset, i_dPos );
+ uint8_t * sRelAddr = i_sStr.getRelativePosition(sRelOffset, i_sPos);
+ uint8_t * dRelAddr = getRelativePosition(dRelOffset, i_dPos);
// Copy the data.
- if ( (dRelAddr == sRelAddr) && (dRelOffset == sRelOffset) )
+ if ((dRelAddr == sRelAddr) && (dRelOffset == sRelOffset))
{
// Do nothing. The source and destination are the same.
}
- else if ( (dRelAddr < sRelAddr) ||
- ((dRelAddr == sRelAddr) && (dRelOffset < sRelOffset)) )
+ else if ((dRelAddr < sRelAddr) ||
+ ((dRelAddr == sRelAddr) && (dRelOffset < sRelOffset)))
{
// Copy the data forward.
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t value = i_sStr.getFieldRight( i_sPos + pos, len );
- setFieldRight( i_dPos + pos, len, value );
+ uint64_t value = i_sStr.getFieldRight(i_sPos + pos, len);
+ setFieldRight(i_dPos + pos, len, value);
}
}
else // Copy the data backwards.
{
// Get the first position of the last chunk (byte aligned).
- uint64_t lastPos = ((actLen-1) / UINT64_BIT_LEN) * UINT64_BIT_LEN;
+ uint64_t lastPos = ((actLen - 1) / UINT64_BIT_LEN) * UINT64_BIT_LEN;
// Start with the last chunk and work backwards.
- for ( int32_t pos = lastPos; 0 <= pos; pos -= UINT64_BIT_LEN )
+ for (int32_t pos = lastPos; 0 <= pos; pos -= UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
- uint64_t value = i_sStr.getFieldRight( i_sPos + pos, len );
- setFieldRight( i_dPos + pos, len, value );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
+ uint64_t value = i_sStr.getFieldRight(i_sPos + pos, len);
+ setFieldRight(i_dPos + pos, len, value);
}
}
}
//------------------------------------------------------------------------------
-void BitString::maskString( const BitString & i_mask )
+void BitString::maskString(const BitString & i_mask)
{
// Get the length of the smallest string.
- uint64_t actLen = std::min( getBitLen(), i_mask.getBitLen() );
+ uint64_t actLen = std::min(getBitLen(), i_mask.getBitLen());
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
- uint64_t sVal = i_mask.getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
+ uint64_t sVal = i_mask.getFieldRight(pos, len);
- setFieldRight( pos, len, dVal & ~sVal );
+ setFieldRight(pos, len, dVal & ~sVal);
}
}
//------------------------------------------------------------------------------
-bool BitString::isEqual( const BitString & i_str ) const
+bool BitString::isEqual(const BitString & i_str) const
{
- if ( getBitLen() != i_str.getBitLen() )
+ if (getBitLen() != i_str.getBitLen())
return false; // size not equal
- for ( uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( getBitLen() - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(getBitLen() - pos, UINT64_BIT_LEN);
- if ( getFieldRight(pos, len) != i_str.getFieldRight(pos, len) )
+ if (getFieldRight(pos, len) != i_str.getFieldRight(pos, len))
return false; // bit strings do not match
}
@@ -247,11 +247,11 @@
bool BitString::isZero() const
{
- for ( uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( getBitLen() - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(getBitLen() - pos, UINT64_BIT_LEN);
- if ( 0 != getFieldRight(pos, len) )
+ if (0 != getFieldRight(pos, len))
return false; // something is non-zero
}
@@ -260,17 +260,17 @@
//------------------------------------------------------------------------------
-uint64_t BitString::getSetCount( uint64_t i_pos, uint64_t i_len ) const
+uint64_t BitString::getSetCount(uint64_t i_pos, uint64_t i_len) const
{
uint64_t endPos = i_pos + i_len;
- HEI_ASSERT( endPos <= getBitLen() );
+ HEI_ASSERT(endPos <= getBitLen());
uint64_t count = 0;
- for ( uint64_t i = i_pos; i < endPos; i++ )
+ for (uint64_t i = i_pos; i < endPos; i++)
{
- if ( isBitSet(i) ) count++;
+ if (isBitSet(i)) count++;
}
return count;
@@ -280,15 +280,15 @@
BitStringBuffer BitString::operator~() const
{
- BitStringBuffer bsb( getBitLen() );
+ BitStringBuffer bsb(getBitLen());
- for ( uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( getBitLen() - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(getBitLen() - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
- bsb.setFieldRight( pos, len, ~dVal );
+ bsb.setFieldRight(pos, len, ~dVal);
}
return bsb;
@@ -296,21 +296,21 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator&( const BitString & i_bs ) const
+BitStringBuffer BitString::operator&(const BitString & i_bs) const
{
// Get the length of the smallest string.
- uint64_t actLen = std::min( getBitLen(), i_bs.getBitLen() );
+ uint64_t actLen = std::min(getBitLen(), i_bs.getBitLen());
- BitStringBuffer bsb( actLen );
+ BitStringBuffer bsb(actLen);
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
- uint64_t sVal = i_bs.getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
+ uint64_t sVal = i_bs.getFieldRight(pos, len);
- bsb.setFieldRight( pos, len, dVal & sVal );
+ bsb.setFieldRight(pos, len, dVal & sVal);
}
return bsb;
@@ -318,21 +318,21 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator|( const BitString & i_bs ) const
+BitStringBuffer BitString::operator|(const BitString & i_bs) const
{
// Get the length of the smallest string.
- uint64_t actLen = std::min( getBitLen(), i_bs.getBitLen() );
+ uint64_t actLen = std::min(getBitLen(), i_bs.getBitLen());
- BitStringBuffer bsb( actLen );
+ BitStringBuffer bsb(actLen);
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
- uint64_t sVal = i_bs.getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
+ uint64_t sVal = i_bs.getFieldRight(pos, len);
- bsb.setFieldRight( pos, len, dVal | sVal );
+ bsb.setFieldRight(pos, len, dVal | sVal);
}
return bsb;
@@ -340,17 +340,17 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator>>( uint64_t i_shift ) const
+BitStringBuffer BitString::operator>>(uint64_t i_shift) const
{
- BitStringBuffer bsb( getBitLen() ); // default all zeros
+ BitStringBuffer bsb(getBitLen()); // default all zeros
- if ( i_shift < getBitLen() )
+ if (i_shift < getBitLen())
{
// bso overlays bsb, containing the shifted offset.
- BitString bso ( bsb.getBitLen() - i_shift, bsb.getBufAddr(), i_shift );
+ BitString bso (bsb.getBitLen() - i_shift, bsb.getBufAddr(), i_shift);
// Copy this into bso.
- bso.setString( *this );
+ bso.setString(*this);
}
return bsb;
@@ -358,18 +358,18 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator<<( uint64_t i_shift ) const
+BitStringBuffer BitString::operator<<(uint64_t i_shift) const
{
- BitStringBuffer bsb( getBitLen() ); // default all zeros
+ BitStringBuffer bsb(getBitLen()); // default all zeros
- if ( i_shift < getBitLen() )
+ if (i_shift < getBitLen())
{
// bso overlays *this, containing the shifted offset.
- BitString bso ( this->getBitLen() - i_shift, this->getBufAddr(),
- i_shift );
+ BitString bso (this->getBitLen() - i_shift, this->getBufAddr(),
+ i_shift);
// Copy bso into bsb.
- bsb.setString( bso );
+ bsb.setString(bso);
}
return bsb;
@@ -377,11 +377,11 @@
//------------------------------------------------------------------------------
-uint8_t * BitString::getRelativePosition( uint64_t & o_relPos,
- uint64_t i_absPos ) const
+uint8_t * BitString::getRelativePosition(uint64_t & o_relPos,
+ uint64_t i_absPos) const
{
- HEI_ASSERT( nullptr != getBufAddr() ); // must to have a valid address
- HEI_ASSERT( i_absPos < getBitLen() ); // must be a valid position
+ HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
+ HEI_ASSERT(i_absPos < getBitLen()); // must be a valid position
o_relPos = (i_absPos + iv_offset) % UINT8_BIT_LEN;
@@ -392,8 +392,8 @@
// BitStringBuffer class
//##############################################################################
-BitStringBuffer::BitStringBuffer( uint64_t i_bitLen ) :
- BitString( i_bitLen, nullptr )
+BitStringBuffer::BitStringBuffer(uint64_t i_bitLen) :
+ BitString(i_bitLen, nullptr)
{
initBuffer();
}
@@ -407,52 +407,52 @@
//------------------------------------------------------------------------------
-BitStringBuffer::BitStringBuffer( const BitString & i_bs ) :
- BitString( i_bs.getBitLen(), nullptr )
+BitStringBuffer::BitStringBuffer(const BitString & i_bs) :
+ BitString(i_bs.getBitLen(), nullptr)
{
initBuffer();
- if ( !i_bs.isZero() ) setString( i_bs );
+ if (!i_bs.isZero()) setString(i_bs);
}
//------------------------------------------------------------------------------
-BitStringBuffer::BitStringBuffer( const BitStringBuffer & i_bsb ) :
- BitString( i_bsb.getBitLen(), nullptr )
+BitStringBuffer::BitStringBuffer(const BitStringBuffer & i_bsb) :
+ BitString(i_bsb.getBitLen(), nullptr)
{
initBuffer();
- if ( !i_bsb.isZero() ) setString( i_bsb );
+ if (!i_bsb.isZero()) setString(i_bsb);
}
//------------------------------------------------------------------------------
-BitStringBuffer & BitStringBuffer::operator=( const BitString & i_bs )
+BitStringBuffer & BitStringBuffer::operator=(const BitString & i_bs)
{
// The initBuffer() function will deallocate the buffer as well, however we
// also need to deallocate the buffer here before we set the length.
delete [] (uint8_t *)getBufAddr();
- setBufAddr( nullptr );
+ setBufAddr(nullptr);
- setBitLen( i_bs.getBitLen() );
+ setBitLen(i_bs.getBitLen());
initBuffer();
- if ( !i_bs.isZero() ) setString( i_bs );
+ if (!i_bs.isZero()) setString(i_bs);
return *this;
}
//------------------------------------------------------------------------------
-BitStringBuffer & BitStringBuffer::operator=( const BitStringBuffer & i_bsb )
+BitStringBuffer & BitStringBuffer::operator=(const BitStringBuffer & i_bsb)
{
- if ( this != &i_bsb ) // Check for assignment to self
+ if (this != &i_bsb) // Check for assignment to self
{
// The initBuffer() function will deallocate the buffer as well, however
// we also need to deallocate the buffer here before we set the length.
delete [] (uint8_t *)getBufAddr();
- setBufAddr( nullptr );
+ setBufAddr(nullptr);
- setBitLen( i_bsb.getBitLen() );
+ setBitLen(i_bsb.getBitLen());
initBuffer();
- if ( !i_bsb.isZero() ) setString( i_bsb );
+ if (!i_bsb.isZero()) setString(i_bsb);
}
return *this;
@@ -466,7 +466,7 @@
delete [] (uint8_t *)getBufAddr();
// create new buffer, initialized to 0's
- setBufAddr( new uint8_t[ getMinBytes(getBitLen()) ]() );
+ setBufAddr(new uint8_t[ getMinBytes(getBitLen()) ]());
}
} // end namespace libhei
diff --git a/src/util/hei_bit_string.hpp b/src/util/hei_bit_string.hpp
index 127ce61..7f83624 100755
--- a/src/util/hei_bit_string.hpp
+++ b/src/util/hei_bit_string.hpp
@@ -33,7 +33,7 @@
*
* uint8_t a[2]; // 16 bits of memory
* BitString bs { 16, a }; // init BitString for a
- * bs.setFieldRight( 0, 16, 0x1122 ); // set all 16 bits to 0x1122
+ * bs.setFieldRight(0, 16, 0x1122); // set all 16 bits to 0x1122
*
* Results in:
*
@@ -76,8 +76,7 @@
* @pre Use getMinBytes() to calulate the minimum number of bytes needed
* to allocate sufficient memory space for this bit string.
*/
- BitString( uint64_t i_bitLen, void * i_bufAddr,
- uint64_t i_offset = 0 ) :
+ BitString(uint64_t i_bitLen, void * i_bufAddr, uint64_t i_offset = 0) :
iv_bitLen(i_bitLen), iv_bufAddr(i_bufAddr), iv_offset(i_offset)
{}
@@ -98,9 +97,9 @@
* @return The minimum number of bytes required to allocate sufficient
* memory space for a bit string.
*/
- static uint64_t getMinBytes( uint64_t i_bitLen, uint64_t i_offset = 0 )
+ static uint64_t getMinBytes(uint64_t i_bitLen, uint64_t i_offset = 0)
{
- return (i_bitLen + i_offset + UINT8_BIT_LEN-1) / UINT8_BIT_LEN;
+ return (i_bitLen + i_offset + UINT8_BIT_LEN - 1) / UINT8_BIT_LEN;
}
/**
@@ -114,7 +113,7 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- uint64_t getFieldLeft( uint64_t i_pos, uint64_t i_len ) const
+ uint64_t getFieldLeft(uint64_t i_pos, uint64_t i_len) const
{
return getFieldRight(i_pos, i_len) << (UINT64_BIT_LEN - i_len);
}
@@ -130,7 +129,7 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- uint64_t getFieldRight( uint64_t i_pos, uint64_t i_len ) const;
+ uint64_t getFieldRight(uint64_t i_pos, uint64_t i_len) const;
/**
* @brief Sets a left-justified value of the given length into the bit
@@ -143,7 +142,7 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- void setFieldLeft( uint64_t i_pos, uint64_t i_len, uint64_t i_val );
+ void setFieldLeft(uint64_t i_pos, uint64_t i_len, uint64_t i_val);
/**
* @brief Sets a right-justified value of the given length into the bit
@@ -156,9 +155,9 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- void setFieldRight( uint64_t i_pos, uint64_t i_len, uint64_t i_val )
+ void setFieldRight(uint64_t i_pos, uint64_t i_len, uint64_t i_val)
{
- setFieldLeft( i_pos, i_len, i_val << (UINT64_BIT_LEN - i_len) );
+ setFieldLeft(i_pos, i_len, i_val << (UINT64_BIT_LEN - i_len));
}
/**
@@ -166,7 +165,7 @@
* @return True if the bit at the given position is set(1), false otherwise.
* @pre i_pos < getBitLen().
*/
- bool isBitSet( uint64_t i_pos ) const
+ bool isBitSet(uint64_t i_pos) const
{
return 0 != getFieldRight(i_pos, 1);
}
@@ -176,7 +175,7 @@
* @param i_pos The target position.
* @pre i_pos < getBitLen().
*/
- void setBit( uint64_t i_pos ) { setFieldRight( i_pos, 1, 1 ); }
+ void setBit(uint64_t i_pos) { setFieldRight(i_pos, 1, 1); }
/** @brief Sets the entire bit string to 1's. */
void setAll() { setPattern(UINT64_MAX); }
@@ -186,7 +185,7 @@
* @param i_pos The target position.
* @pre i_pos < getBitLen().
*/
- void clearBit( uint64_t i_pos ) { setFieldRight( i_pos, 1, 0 ); }
+ void clearBit(uint64_t i_pos) { setFieldRight(i_pos, 1, 0); }
/** @brief Sets the entire bit string to 0's. */
void clearAll() { setPattern(0); }
@@ -212,8 +211,8 @@
* Old String: 0001001000
* New String: 0000110000
*/
- void setPattern( uint64_t i_sPos, uint64_t i_sLen,
- uint64_t i_pattern, uint64_t i_pLen );
+ void setPattern(uint64_t i_sPos, uint64_t i_sLen, uint64_t i_pattern,
+ uint64_t i_pLen);
/**
* @brief Sets entire string based on the pattern and length provided.
@@ -223,9 +222,9 @@
* @post The entire string is filled with the pattern.
* @post The pattern is repeated/truncated as needed.
*/
- void setPattern( uint64_t i_pattern, uint64_t i_pLen )
+ void setPattern(uint64_t i_pattern, uint64_t i_pLen)
{
- setPattern( 0, getBitLen(), i_pattern, i_pLen );
+ setPattern(0, getBitLen(), i_pattern, i_pLen);
}
/**
@@ -235,9 +234,9 @@
* @post The entire string is filled with the pattern.
* @post The pattern is repeated/truncated as needed.
*/
- void setPattern( uint64_t i_pattern )
+ void setPattern(uint64_t i_pattern)
{
- setPattern( i_pattern, sizeof(i_pattern) * 8 );
+ setPattern(i_pattern, sizeof(i_pattern) * 8);
}
/**
@@ -258,8 +257,8 @@
* string, then the extra bits in this string are not modified.
* @note This string and the source string may specify overlapping memory.
*/
- void setString( const BitString & i_sStr, uint64_t i_sPos,
- uint64_t i_sLen, uint64_t i_dPos = 0 );
+ void setString(const BitString & i_sStr, uint64_t i_sPos, uint64_t i_sLen,
+ uint64_t i_dPos = 0);
/**
* @brief Set bits in this string based on the provided string.
@@ -269,9 +268,9 @@
* @note See the other definition of this function for details and
* restrictions.
*/
- void setString( const BitString & i_sStr )
+ void setString(const BitString & i_sStr)
{
- setString( i_sStr, 0, i_sStr.getBitLen() );
+ setString(i_sStr, 0, i_sStr.getBitLen());
}
/**
@@ -283,7 +282,7 @@
* @note If the length of the given string is less than the length of this
* string, then the extra bits in this string are not modified.
*/
- void maskString( const BitString & i_mask );
+ void maskString(const BitString & i_mask);
/**
* @param i_str The string to compare.
@@ -291,7 +290,7 @@
* @pre Both strings must be of equal length and have same values to be
* equal.
*/
- bool isEqual( const BitString & i_str ) const;
+ bool isEqual(const BitString & i_str) const;
/** @return True if there are no bit set(1) in this bit string, false
* otherwise. */
@@ -304,28 +303,28 @@
* @pre nullptr != getBufAddr()
* @pre i_pos + i_len <= getBitLen()
*/
- uint64_t getSetCount( uint64_t i_pos, uint64_t i_len ) const;
+ uint64_t getSetCount(uint64_t i_pos, uint64_t i_len) const;
/** @return The number of bits that are set(1) in this string. */
- uint64_t getSetCount() const { return getSetCount( 0, getBitLen() ); }
+ uint64_t getSetCount() const { return getSetCount(0, getBitLen()); }
/** @brief Comparison operator. */
- bool operator==( const BitString & i_str ) const { return isEqual(i_str); }
+ bool operator==(const BitString & i_str) const { return isEqual(i_str); }
/** @brief Bitwise NOT operator. */
BitStringBuffer operator~() const;
/** @brief Bitwise AND operator. */
- BitStringBuffer operator&( const BitString & i_bs ) const;
+ BitStringBuffer operator&(const BitString & i_bs) const;
/** @brief Bitwise OR operator. */
- BitStringBuffer operator|( const BitString & i_bs ) const;
+ BitStringBuffer operator|(const BitString & i_bs) const;
/** @brief Right shift operator. */
- BitStringBuffer operator>>( uint64_t i_shift ) const;
+ BitStringBuffer operator>>(uint64_t i_shift) const;
/** @brief Left shift operator. */
- BitStringBuffer operator<<( uint64_t i_shift ) const;
+ BitStringBuffer operator<<(uint64_t i_shift) const;
/**
* @brief Explicitly disables copy from BitString.
@@ -333,7 +332,7 @@
* Prevents assigning a BitString & to a BitString, which would strip
* polymorphism.
*/
- BitString( const BitString & i_bs ) = delete;
+ BitString(const BitString & i_bs) = delete;
/**
* @brief Explicitly disables assignment from BitStringBuffer.
@@ -341,7 +340,7 @@
* Allowing this would be dangerous if the BitStringBuffer goes out of scope
* because the BitString would point to memory that is no longer in context.
*/
- BitString & operator=( const BitStringBuffer & i_bsb ) = delete;
+ BitString & operator=(const BitStringBuffer & i_bsb) = delete;
/**
* @brief Explicitly disables copy from BitStringBuffer.
@@ -349,7 +348,7 @@
* Allowing this would be dangerous if the BitStringBuffer goes out of scope
* because the BitString would point to memory that is no longer in context.
*/
- BitString( const BitStringBuffer & i_bsb ) = delete;
+ BitString(const BitStringBuffer & i_bsb) = delete;
protected: // functions
@@ -358,10 +357,10 @@
* @pre Before calling this function, make sure you deallocate the old
* buffer to avoid memory leaks.
*/
- void setBufAddr( void * i_newBufAddr ) { iv_bufAddr = i_newBufAddr; }
+ void setBufAddr(void * i_newBufAddr) { iv_bufAddr = i_newBufAddr; }
/** @param i_newBitLen The new bit length of this bit string buffer. */
- void setBitLen( uint64_t i_newBitLen ) { iv_bitLen = i_newBitLen; }
+ void setBitLen(uint64_t i_newBitLen) { iv_bitLen = i_newBitLen; }
private: // functions
@@ -375,8 +374,8 @@
* @pre nullptr != getBufAddr()
* @pre i_absPos < getBitLen()
*/
- uint8_t * getRelativePosition( uint64_t & o_relPos,
- uint64_t i_absPos ) const;
+ uint8_t * getRelativePosition(uint64_t & o_relPos,
+ uint64_t i_absPos) const;
private: // instance variables
@@ -402,22 +401,22 @@
* @brief Constructor
* @param i_bitLen Number of bits in the string.
*/
- explicit BitStringBuffer( uint64_t i_bitLen );
+ explicit BitStringBuffer(uint64_t i_bitLen);
/** @brief Destructor */
~BitStringBuffer();
/** @brief Copy constructor from BitString */
- BitStringBuffer( const BitString & i_bs );
+ BitStringBuffer(const BitString & i_bs);
/** @brief Copy constructor from BitStringBuffer */
- BitStringBuffer( const BitStringBuffer & i_bsb );
+ BitStringBuffer(const BitStringBuffer & i_bsb);
/** @brief Assignment from BitString */
- BitStringBuffer & operator=( const BitString & i_bs );
+ BitStringBuffer & operator=(const BitString & i_bs);
/** @brief Assignment from BitStringBuffer */
- BitStringBuffer & operator=( const BitStringBuffer & i_bsb );
+ BitStringBuffer & operator=(const BitStringBuffer & i_bsb);
private: // functions
@@ -427,4 +426,3 @@
};
} // end namespace libhei
-
diff --git a/src/util/hei_flyweight.hpp b/src/util/hei_flyweight.hpp
index f308e3c..cd56d82 100644
--- a/src/util/hei_flyweight.hpp
+++ b/src/util/hei_flyweight.hpp
@@ -20,10 +20,10 @@
~Flyweight() { clear(); }
/** @brief Default copy constructor. */
- Flyweight( const Flyweight & ) = delete;
+ Flyweight(const Flyweight &) = delete;
/** @brief Default assignment operator. */
- Flyweight & operator=( const Flyweight & ) = delete;
+ Flyweight & operator=(const Flyweight &) = delete;
public:
@@ -40,20 +40,21 @@
* @param The target entry.
* @return A reference to this entry in the factory.
*/
- T & get( const T & i_entry )
+ T & get(const T & i_entry)
{
// The index is sorted by the value of the T objects. Check to see if
// this entry already exists in the factory.
- auto itr = std::lower_bound( iv_index.begin(), iv_index.end(), &i_entry,
- [](const T * a, const T * b) { return *a < *b; } );
+ auto itr =
+ std::lower_bound(iv_index.begin(), iv_index.end(), &i_entry,
+ [](const T * a, const T * b) { return *a < *b; });
// std::lower_bound() will return the first element that does not
// compare less than i_entry. So if an entry is found, we must make sure
// it does not have the same value as i_entry.
- if ( iv_index.end() == itr || !(i_entry == *(*itr)) )
+ if (iv_index.end() == itr || !(i_entry == *(*itr)))
{
// Create a new entry and store the pointer in the sorted index.
- itr = iv_index.insert( itr, new T { i_entry } );
+ itr = iv_index.insert(itr, new T { i_entry });
}
// Return a reference to this entry in the factory.
@@ -67,7 +68,7 @@
*/
void clear()
{
- for ( auto i : iv_index ) { delete i; }
+ for (auto i : iv_index) { delete i; }
iv_index.clear();
}
@@ -105,4 +106,3 @@
};
} // end namespace libhei
-