本文整理汇总了C++中BitString::setString方法的典型用法代码示例。如果您正苦于以下问题:C++ BitString::setString方法的具体用法?C++ BitString::setString怎么用?C++ BitString::setString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitString
的用法示例。
在下文中一共展示了BitString::setString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddDataElement
void CaptureData::AddDataElement( TargetHandle_t i_trgt, int i_scomId,
const BitString * i_bs,
Place i_place, RegType i_type )
{
// Initial values of the bit string buffer if i_bs has a zero value.
uint8_t * buf = nullptr;
size_t sz_buf = 0;
// Add buffer only if the value is non-zero.
if ( !i_bs->isZero() )
{
// Get the size of i_bs and ensure byte alignment.
sz_buf = (i_bs->getBitLen() + 8-1) / 8;
// Since we are using a BitString below, which does everything on a
// CPU_WORD boundary, we must make sure the buffer is CPU_WORD aligned.
const size_t sz_word = sizeof(CPU_WORD);
sz_buf = ((sz_buf + sz_word-1) / sz_word) * sz_word;
// Allocate memory for the buffer.
buf = new uint8_t[sz_buf];
memset( buf, 0x00, sz_buf );
// Use a BitString to copy i_bs to the buffer.
BitString bs ( i_bs->getBitLen(), (CPU_WORD *)buf );
bs.setString( *i_bs );
// Create the new data element.
Data element( i_trgt, i_scomId, sz_buf, buf );
element.registerType = i_type;
// Add the new element to the data.
if ( FRONT == i_place )
data.insert( data.begin(), element );
else
data.push_back( element );
}
}