Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

WORD PASNObjectID::GetEncodedLength (  )  [virtual]

Virtual function used to get the length of object when encoded into ASN format

Reimplemented from PASNObject.

Definition at line 823 of file pasn.cxx.

References PASNObject::GetASNHeaderLength().

{
  PASNOid    subId, mask, testmask;
  int        bits, testbits;
  PINDEX     objIdLen = value.GetSize();
  WORD       theLen = 0;
  PASNOid    *objId = value.GetPointer();

  if (objIdLen < 2) {
    theLen++;
    objIdLen = 0;
  } else {
    theLen++;
    objIdLen -= 2;
    objId += 2;
  }

  while (objIdLen-- > 0) {
    subId = *objId++;
    if (subId < 128) 
      theLen++;
    else {
      mask = 0x7F; /* handle subid == 0 case */
      bits = 0;

      /* testmask *MUST* !!!! be of an unsigned type */
      for (testmask = 0x7F, testbits = 0;
           testmask != 0;
           testmask <<= 7, testbits += 7) {
        if (subId & testmask) {  /* if any bits set */
          mask = testmask;
          bits = testbits;
        }
      }

      /* mask can't be zero here */
      for(;mask != 0x7F; mask >>= 7, bits -= 7) {
        /* fix a mask that got truncated above */
        if (mask == 0x1E00000)
          mask = 0xFE00000;
        theLen++;
      }
      theLen++;
    }
  }

  return (WORD)(theLen + GetASNHeaderLength(theLen));
}


Generated by  Doxygen 1.6.0   Back to index