⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asner.cxx

📁 pwlib源码库
💻 CXX
📖 第 1 页 / 共 5 页
字号:
PINDEX PASN_Choice::GetDataLength() const{  if (CheckCreate())    return choice->GetDataLength();  return 0;}BOOL PASN_Choice::IsPrimitive() const{  if (CheckCreate())    return choice->IsPrimitive();  return FALSE;}BOOL PASN_Choice::Decode(PASN_Stream & strm){  return strm.ChoiceDecode(*this);}void PASN_Choice::Encode(PASN_Stream & strm) const{  strm.ChoiceEncode(*this);}///////////////////////////////////////////////////////////////////////PASN_Sequence::PASN_Sequence(unsigned tag, TagClass tagClass,                             unsigned nOpts, BOOL extend, unsigned nExtend)  : PASN_Object(tag, tagClass, extend){  optionMap.SetConstraints(PASN_ConstrainedObject::FixedConstraint, nOpts);  knownExtensions = nExtend;  totalExtensions = 0;  endBasicEncoding = 0;}PASN_Sequence::PASN_Sequence(const PASN_Sequence & other)  : PASN_Object(other),    fields(other.fields.GetSize()),    optionMap(other.optionMap),    extensionMap(other.extensionMap){  for (PINDEX i = 0; i < other.fields.GetSize(); i++)    fields.SetAt(i, other.fields[i].Clone());  knownExtensions = other.knownExtensions;  totalExtensions = other.totalExtensions;  endBasicEncoding = 0;}PASN_Sequence & PASN_Sequence::operator=(const PASN_Sequence & other){  PASN_Object::operator=(other);  fields.SetSize(other.fields.GetSize());  for (PINDEX i = 0; i < other.fields.GetSize(); i++)    fields.SetAt(i, other.fields[i].Clone());  optionMap = other.optionMap;  knownExtensions = other.knownExtensions;  totalExtensions = other.totalExtensions;  extensionMap = other.extensionMap;  return *this;}BOOL PASN_Sequence::HasOptionalField(PINDEX opt) const{  if (opt < (PINDEX)optionMap.GetSize())    return optionMap[opt];  else    return extensionMap[opt - optionMap.GetSize()];}void PASN_Sequence::IncludeOptionalField(PINDEX opt){  if (opt < (PINDEX)optionMap.GetSize())    optionMap.Set(opt);  else {    PAssert(extendable, "Must be extendable type");    opt -= optionMap.GetSize();    if (opt >= (PINDEX)extensionMap.GetSize())      extensionMap.SetSize(opt+1);    extensionMap.Set(opt);  }}void PASN_Sequence::RemoveOptionalField(PINDEX opt){  if (opt < (PINDEX)optionMap.GetSize())    optionMap.Clear(opt);  else {    PAssert(extendable, "Must be extendable type");    opt -= optionMap.GetSize();    extensionMap.Clear(opt);  }}PObject::Comparison PASN_Sequence::Compare(const PObject & obj) const{  PAssert(PIsDescendant(&obj, PASN_Sequence), PInvalidCast);  const PASN_Sequence & other = (const PASN_Sequence &)obj;  return fields.Compare(other.fields);}PObject * PASN_Sequence::Clone() const{  PAssert(IsClass(PASN_Sequence::Class()), PInvalidCast);  return new PASN_Sequence(*this);}void PASN_Sequence::PrintOn(ostream & strm) const{  int indent = strm.precision() + 2;  strm << "{\n";  for (PINDEX i = 0; i < fields.GetSize(); i++) {    strm << setw(indent+6) << "field[" << i << "] <";    switch (fields[i].GetTagClass()) {      case UniversalTagClass :        strm << "Universal";        break;      case ApplicationTagClass :        strm << "Application";        break;      case ContextSpecificTagClass :        strm << "ContextSpecific";        break;      case PrivateTagClass :        strm << "Private";      default :        break;    }    strm << '-' << fields[i].GetTag() << '-'         << fields[i].GetTypeAsString() << "> = "         << fields[i] << '\n';  }  strm << setw(indent-1) << "}";}PString PASN_Sequence::GetTypeAsString() const{  return "Sequence";}PINDEX PASN_Sequence::GetDataLength() const{  PINDEX len = 0;  for (PINDEX i = 0; i < fields.GetSize(); i++)    len += fields[i].GetObjectLength();  return len;}BOOL PASN_Sequence::IsPrimitive() const{  return FALSE;}BOOL PASN_Sequence::Decode(PASN_Stream & strm){  return PreambleDecode(strm) && UnknownExtensionsDecode(strm);}void PASN_Sequence::Encode(PASN_Stream & strm) const{  PreambleEncode(strm);  UnknownExtensionsEncode(strm);}BOOL PASN_Sequence::PreambleDecode(PASN_Stream & strm){  return strm.SequencePreambleDecode(*this);}void PASN_Sequence::PreambleEncode(PASN_Stream & strm) const{  strm.SequencePreambleEncode(*this);}BOOL PASN_Sequence::KnownExtensionDecode(PASN_Stream & strm, PINDEX fld, PASN_Object & field){  return strm.SequenceKnownDecode(*this, fld, field);}void PASN_Sequence::KnownExtensionEncode(PASN_Stream & strm, PINDEX fld, const PASN_Object & field) const{  strm.SequenceKnownEncode(*this, fld, field);}BOOL PASN_Sequence::UnknownExtensionsDecode(PASN_Stream & strm){  return strm.SequenceUnknownDecode(*this);}void PASN_Sequence::UnknownExtensionsEncode(PASN_Stream & strm) const{  strm.SequenceUnknownEncode(*this);}///////////////////////////////////////////////////////////////////////PASN_Set::PASN_Set(unsigned tag, TagClass tagClass,                   unsigned nOpts, BOOL extend, unsigned nExtend)  : PASN_Sequence(tag, tagClass, nOpts, extend, nExtend){}PObject * PASN_Set::Clone() const{  PAssert(IsClass(PASN_Set::Class()), PInvalidCast);  return new PASN_Set(*this);}PString PASN_Set::GetTypeAsString() const{  return "Set";}///////////////////////////////////////////////////////////////////////PASN_Array::PASN_Array(unsigned tag, TagClass tagClass)  : PASN_ConstrainedObject(tag, tagClass){}PASN_Array::PASN_Array(const PASN_Array & other)  : PASN_ConstrainedObject(other),    array(other.array.GetSize()){  for (PINDEX i = 0; i < other.array.GetSize(); i++)    array.SetAt(i, other.array[i].Clone());}PASN_Array & PASN_Array::operator=(const PASN_Array & other){  PASN_ConstrainedObject::operator=(other);  array.SetSize(other.array.GetSize());  for (PINDEX i = 0; i < other.array.GetSize(); i++)    array.SetAt(i, other.array[i].Clone());  return *this;}BOOL PASN_Array::SetSize(PINDEX newSize){  if (newSize > MaximumArraySize)    return FALSE;  PINDEX originalSize = array.GetSize();  if (!array.SetSize(newSize))    return FALSE;  for (PINDEX i = originalSize; i < newSize; i++) {    PASN_Object * obj = CreateObject();    if (obj == NULL)      return FALSE;    array.SetAt(i, obj);  }  return TRUE;}PObject::Comparison PASN_Array::Compare(const PObject & obj) const{  PAssert(PIsDescendant(&obj, PASN_Array), PInvalidCast);  const PASN_Array & other = (const PASN_Array &)obj;  return array.Compare(other.array);}void PASN_Array::PrintOn(ostream & strm) const{  int indent = strm.precision() + 2;  strm << array.GetSize() << " entries {\n";  for (PINDEX i = 0; i < array.GetSize(); i++)    strm << setw(indent+1) << "[" << i << "]=" << setprecision(indent) << array[i] << '\n';  strm << setw(indent-1) << "}";}void PASN_Array::SetConstraintBounds(ConstraintType type, int lower, unsigned upper){  if (lower < 0)    return;  PASN_ConstrainedObject::SetConstraintBounds(type, lower, upper);  if (constraint != Unconstrained) {    if (GetSize() < (PINDEX)lowerLimit)      SetSize(lowerLimit);    else if (GetSize() > (PINDEX)upperLimit)      SetSize(upperLimit);  }}PString PASN_Array::GetTypeAsString() const{  return "Array";}PINDEX PASN_Array::GetDataLength() const{  PINDEX len = 0;  for (PINDEX i = 0; i < array.GetSize(); i++)    len += array[i].GetObjectLength();  return len;}BOOL PASN_Array::IsPrimitive() const{  return FALSE;}BOOL PASN_Array::Decode(PASN_Stream & strm){  return strm.ArrayDecode(*this);}void PASN_Array::Encode(PASN_Stream & strm) const{  strm.ArrayEncode(*this);}///////////////////////////////////////////////////////////////////////PASN_Stream::PASN_Stream(){  Construct();}PASN_Stream::PASN_Stream(const PBYTEArray & bytes)  : PBYTEArray(bytes){  Construct();}PASN_Stream::PASN_Stream(const BYTE * buf, PINDEX size)  : PBYTEArray(buf, size){  Construct();}void PASN_Stream::Construct(){  byteOffset = 0;  bitOffset = 8;}void PASN_Stream::PrintOn(ostream & strm) const{  int indent = strm.precision() + 2;  strm << " size=" << GetSize()       << " pos=" << byteOffset << '.' << (8-bitOffset)       << " {\n";  PINDEX i = 0;  while (i < GetSize()) {    strm << setw(indent) << " " << hex << setfill('0');    PINDEX j;    for (j = 0; j < 16; j++)      if (i+j < GetSize())        strm << setw(2) << (unsigned)(BYTE)theArray[i+j] << ' ';      else        strm << "   ";    strm << "  ";    for (j = 0; j < 16; j++) {      if (i+j < GetSize()) {        BYTE c = theArray[i+j];        if (c < 128 && isprint(c))          strm << c;        else          strm << ' ';      }    }    strm << dec << setfill(' ') << '\n';    i += 16;  }  strm << setw(indent-1) << "}";}void PASN_Stream::SetPosition(PINDEX newPos){  if (!CheckByteOffset(byteOffset))    return;  if (newPos > GetSize())    byteOffset = GetSize();  else    byteOffset = newPos;  bitOffset = 8;}void PASN_Stream::ResetDecoder(){  byteOffset = 0;  bitOffset = 8;}void PASN_Stream::BeginEncoding(){  bitOffset = 8;  byteOffset = 0;  PBYTEArray::operator=(PBYTEArray(20));}void PASN_Stream::CompleteEncoding(){  if (byteOffset != P_MAX_INDEX) {    if (bitOffset != 8) {      bitOffset = 8;      byteOffset++;    }    SetSize(byteOffset);    byteOffset = P_MAX_INDEX;  }}BYTE PASN_Stream::ByteDecode(){  if (!CheckByteOffset(byteOffset, GetSize()))    return 0;  bitOffset = 8;  return theArray[byteOffset++];}void PASN_Stream::ByteEncode(unsigned value){  if (!CheckByteOffset(byteOffset))    return;  if (bitOffset != 8) {    bitOffset = 8;    byteOffset++;  }  if (byteOffset >= GetSize())    SetSize(byteOffset+10);  theArray[byteOffset++] = (BYTE)value;}unsigned PASN_Stream::BlockDecode(BYTE * bufptr, unsigned nBytes){  if (nBytes == 0 || bufptr == NULL || !CheckByteOffset(byteOffset+nBytes))    return 0;  ByteAlign();  if (byteOffset+nBytes > (unsigned)GetSize()) {    nBytes = GetSize() - byteOffset;    if (nBytes <= 0)      return 0;  }  memcpy(bufptr, &theArray[byteOffset], nBytes);  byteOffset += nBytes;  return nBytes;}void PASN_Stream::BlockEncode(const BYTE * bufptr, PINDEX nBytes){  if (!CheckByteOffset(byteOffset, GetSize()))    return;  if (nBytes == 0)    return;  ByteAlign();  if (byteOffset+nBytes >= GetSize())    SetSize(byteOffset+nBytes+10);  memcpy(theArray+byteOffset, bufptr, nBytes);  byteOffset += nBytes;}void PASN_Stream::ByteAlign(){  if (!CheckByteOffset(byteOffset, GetSize()))    return;  if (bitOffset != 8) {    bitOffset = 8;    byteOffset++;  }}///////////////////////////////////////////////////////////////////////#ifdef  P_INCLUDE_PER#include "asnper.cxx"#endif#ifdef  P_INCLUDE_BER#include "asnber.cxx"#endif#ifdef  P_INCLUDE_XER#include "asnxer.cxx"#endif// End of file ////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -