本文整理汇总了C++中AsnBuf::PutByteRvs方法的典型用法代码示例。如果您正苦于以下问题:C++ AsnBuf::PutByteRvs方法的具体用法?C++ AsnBuf::PutByteRvs怎么用?C++ AsnBuf::PutByteRvs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsnBuf
的用法示例。
在下文中一共展示了AsnBuf::PutByteRvs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BEncContent
// Encodes the content (included unused bits octet) of the BIT STRING
// to the given buffer.
AsnLen AsnBits::BEncContent (AsnBuf &b) const
{
size_t unusedBits;
size_t byteLen;
unsigned int i;
//bool bStop;
// IF bitstring is a NamedBitList
if (nblFlag)
{
// Calculate last octet.
//
size_t finalOctet;
if (bitLen <= 8)
finalOctet = 0;
else if (bitLen % 8 == 0)
finalOctet = ((bitLen / 8) - 1);
else
finalOctet = bitLen / 8;
// The final octet is the last octet which has at least
// one bit set. Loop backwards starting with the
// last octet (calculated above) until you find an
// that has at least one bit set (it's value is not 0).
//
if (bits != NULL)
for (; finalOctet > 0 && bits[finalOctet] == 0; finalOctet--);
// Calculate unsigned bits in final octet
//
if (bits == NULL || (finalOctet == 0 && bits[0] == 0))
{
byteLen = 0;
unusedBits = 0;
}
else
{
// Calculate how many trailing bits are unset in the
// last octet.
unusedBits=0;
for (i = 0; i < 8 && ! (bits[finalOctet] & (0x01 << i)); i++)
unusedBits++;
byteLen = finalOctet + 1;
}
}
else
{
// If this is not a NamedBitList Calculate the unusedBits
// as ( (BitLen() / 8) + 1) * 8 ) - BitLen();
//
// In other words it's the number of bits not used by
// the BIT STRING specification, not the number of unset
// bits in the the final subsequent octet.
unusedBits = bitLen % 8;
if (unusedBits != 0)
unusedBits = 8 - unusedBits;
byteLen = (bitLen+7)/8;
}
b.PutSegRvs (bits, byteLen);
// unusedBits = (bitLen % 8);
// if (unusedBits != 0)
// unusedBits = 8 - unusedBits;
b.PutByteRvs ((unsigned char)unusedBits);
return byteLen + 1;
} /* AsnBits::BEncContent */