当前位置: 首页>>代码示例>>C++>>正文


C++ AsnBuf::PutByteRvs方法代码示例

本文整理汇总了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 */
开发者ID:,项目名称:,代码行数:73,代码来源:


注:本文中的AsnBuf::PutByteRvs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。