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

📄 asner.cxx

📁 pwlib源码库
💻 CXX
📖 第 1 页 / 共 5 页
字号:
                               "\010\011\012\013\014\015\016\017"                               "\020\021\022\023\024\025\026\027"                               "\030\031\032\033\034\035\036\037"                               " !\"#$%&'()*+,-./0123456789:;<=>?"                               "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"                               "`abcdefghijklmnopqrstuvwxyz{|}~\177")DEFINE_STRING_CLASS(General,   "\000\001\002\003\004\005\006\007"                               "\010\011\012\013\014\015\016\017"                               "\020\021\022\023\024\025\026\027"                               "\030\031\032\033\034\035\036\037"                               " !\"#$%&'()*+,-./0123456789:;<=>?"                               "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"                               "`abcdefghijklmnopqrstuvwxyz{|}~\177"                               "\200\201\202\203\204\205\206\207"                               "\210\211\212\213\214\215\216\217"                               "\220\221\222\223\224\225\226\227"                               "\230\231\232\233\234\235\236\237"                               "\240\241\242\243\244\245\246\247"                               "\250\251\252\253\254\255\256\257"                               "\260\261\262\263\264\265\266\267"                               "\270\271\272\273\274\275\276\277"                               "\300\301\302\303\304\305\306\307"                               "\310\311\312\313\314\315\316\317"                               "\320\321\322\323\324\325\326\327"                               "\330\331\332\333\334\335\336\337"                               "\340\341\342\343\344\345\346\347"                               "\350\351\352\353\354\355\356\357"                               "\360\361\362\363\364\365\366\367"                               "\370\371\372\373\374\375\376\377")///////////////////////////////////////////////////////////////////////PASN_BMPString::PASN_BMPString(const char * str)  : PASN_ConstrainedObject(UniversalBMPString, UniversalTagClass){  Construct();  if (str != NULL)    SetValue(str);}PASN_BMPString::PASN_BMPString(const PWORDArray & wstr)  : PASN_ConstrainedObject(UniversalBMPString, UniversalTagClass){  Construct();  SetValue(wstr);}PASN_BMPString::PASN_BMPString(unsigned tag, TagClass tagClass)  : PASN_ConstrainedObject(tag, tagClass){  Construct();}void PASN_BMPString::Construct(){  firstChar = 0;  lastChar = 0xffff;  charSetAlignedBits = 16;  charSetUnalignedBits = 16;}PASN_BMPString::PASN_BMPString(const PASN_BMPString & other)  : PASN_ConstrainedObject(other),    value(other.value, other.value.GetSize()),    characterSet(other.characterSet){  firstChar = other.firstChar;  lastChar = other.lastChar;  charSetAlignedBits = other.charSetAlignedBits;  charSetUnalignedBits = other.charSetUnalignedBits;}PASN_BMPString & PASN_BMPString::operator=(const PASN_BMPString & other){  PASN_ConstrainedObject::operator=(other);  value = PWORDArray(other.value, other.value.GetSize());  characterSet = other.characterSet;  firstChar = other.firstChar;  lastChar = other.lastChar;  charSetAlignedBits = other.charSetAlignedBits;  charSetUnalignedBits = other.charSetUnalignedBits;  return *this;}BOOL PASN_BMPString::IsLegalCharacter(WORD ch){  if (ch < firstChar)    return FALSE;  if (ch > lastChar)    return FALSE;  if (characterSet.IsEmpty())    return TRUE;  const WORD * wptr = characterSet;  PINDEX count = characterSet.GetSize();  while (count-- > 0) {    if (*wptr == ch)      return TRUE;    wptr++;  }  return FALSE;}PASN_BMPString & PASN_BMPString::operator=(const PWORDArray & array){  PINDEX paramSize = array.GetSize();  // Can't copy any more than the upper constraint  if ((unsigned)paramSize > upperLimit)    paramSize = upperLimit;  // Number of bytes must be at least lhe lower constraint  PINDEX newSize = (int)paramSize < lowerLimit ? lowerLimit : paramSize;  value.SetSize(newSize);  PINDEX count = 0;  for (PINDEX i = 0; i < paramSize; i++) {    WORD c = array[i];    if (IsLegalCharacter(c))      value[count++] = c;  }  // Pad out with the first character till required size  while (count < newSize)    value[count++] = firstChar;  return *this;}void PASN_BMPString::SetCharacterSet(ConstraintType ctype, const char * charSet){  PWORDArray array(strlen(charSet));  PINDEX count = 0;  while (*charSet != '\0')    array[count++] = (BYTE)*charSet++;  SetCharacterSet(ctype, array);}void PASN_BMPString::SetCharacterSet(ConstraintType ctype, const PWORDArray & charSet){  if (ctype == Unconstrained) {    firstChar = 0;    lastChar = 0xffff;    characterSet.SetSize(0);  }  else {    characterSet = charSet;    charSetUnalignedBits = CountBits(lastChar - firstChar + 1);    if (!charSet.IsEmpty()) {      unsigned count = 0;      for (PINDEX i = 0; i < charSet.GetSize(); i++) {        if (characterSet[i] >= firstChar && characterSet[i] <= lastChar)          count++;      }      count = CountBits(count);      if (charSetUnalignedBits > count)        charSetUnalignedBits = count;    }    charSetAlignedBits = 1;    while (charSetUnalignedBits > charSetAlignedBits)      charSetAlignedBits <<= 1;    SetValue(value);  }}void PASN_BMPString::SetCharacterSet(ConstraintType ctype, unsigned first, unsigned last){  if (ctype != Unconstrained) {    PAssert(first < 0x10000 && last < 0x10000 && last > first, PInvalidParameter);    firstChar = (WORD)first;    lastChar = (WORD)last;  }  SetCharacterSet(ctype, characterSet);}PObject * PASN_BMPString::Clone() const{  PAssert(IsClass(PASN_BMPString::Class()), PInvalidCast);  return new PASN_BMPString(*this);}PObject::Comparison PASN_BMPString::Compare(const PObject & obj) const{  PAssert(PIsDescendant(&obj, PASN_BMPString), PInvalidCast);  const PASN_BMPString & other = (const PASN_BMPString &)obj;  return value.Compare(other.value);}void PASN_BMPString::PrintOn(ostream & strm) const{  int indent = strm.precision() + 2;  PINDEX sz = value.GetSize();  strm << ' ' << sz << " characters {\n";  PINDEX i = 0;  while (i < sz) {    strm << setw(indent) << " " << hex << setfill('0');    PINDEX j;    for (j = 0; j < 8; j++)      if (i+j < sz)        strm << setw(4) << value[i+j] << ' ';      else        strm << "     ";    strm << "  ";    for (j = 0; j < 8; j++) {      if (i+j < sz) {        WORD c = value[i+j];        if (c < 128 && isprint(c))          strm << (char)c;        else          strm << ' ';      }    }    strm << dec << setfill(' ') << '\n';    i += 8;  }  strm << setw(indent-1) << "}";}PString PASN_BMPString::GetTypeAsString() const{  return "BMP String";}PINDEX PASN_BMPString::GetDataLength() const{  return value.GetSize()*2;}BOOL PASN_BMPString::Decode(PASN_Stream & strm){  return strm.BMPStringDecode(*this);}void PASN_BMPString::Encode(PASN_Stream & strm) const{  strm.BMPStringEncode(*this);}///////////////////////////////////////////////////////////////////////PASN_GeneralisedTime & PASN_GeneralisedTime::operator=(const PTime & time){  value = time.AsString("yyyyMMddhhmmss.uz");  value.Replace("GMT", "Z");  return *this;}PTime PASN_GeneralisedTime::GetValue() const{  int year = value(0,3).AsInteger();  int month = value(4,5).AsInteger();  int day = value(6,7).AsInteger();  int hour = value(8,9).AsInteger();  int minute = value(10,11).AsInteger();  int seconds = 0;  int zonePos = 12;  if (isdigit(value[12])) {    seconds = value(12,13).AsInteger();    if (value[14] != '.')      zonePos = 14;    else {      zonePos = 15;      while (isdigit(value[zonePos]))        zonePos++;    }  }  int zone = PTime::Local;  switch (value[zonePos]) {    case 'Z' :      zone = PTime::UTC;      break;    case '+' :    case '-' :      zone = value(zonePos+1,zonePos+2).AsInteger()*60 +             value(zonePos+3,zonePos+4).AsInteger();  }  return PTime(seconds, minute, hour, day, month, year, zone);}///////////////////////////////////////////////////////////////////////PASN_UniversalTime & PASN_UniversalTime::operator=(const PTime & time){  value = time.AsString("yyMMddhhmmssz");  value.Replace("GMT", "Z");  value.MakeMinimumSize();  return *this;}PTime PASN_UniversalTime::GetValue() const{  int year = value(0,1).AsInteger();  if (year < 36)    year += 2000;  else    year += 1900;  int month = value(2,3).AsInteger();  int day = value(4,5).AsInteger();  int hour = value(6,7).AsInteger();  int minute = value(8,9).AsInteger();  int seconds = 0;  int zonePos = 10;  if (isdigit(value[10])) {    seconds = value(10,11).AsInteger();    zonePos = 12;  }  int zone = PTime::UTC;  if (value[zonePos] != 'Z')    zone = value(zonePos+1,zonePos+2).AsInteger()*60 +           value(zonePos+3,zonePos+4).AsInteger();  return PTime(seconds, minute, hour, day, month, year, zone);}///////////////////////////////////////////////////////////////////////PASN_Choice::PASN_Choice(unsigned nChoices, BOOL extend)  : PASN_Object(0, ApplicationTagClass, extend),names(NULL),namesCount(0){  numChoices = nChoices;  choice = NULL;}PASN_Choice::PASN_Choice(unsigned tag, TagClass tagClass,                         unsigned upper, BOOL extend)  : PASN_Object(tag, tagClass, extend),names(NULL),namesCount(0){  numChoices = upper;  choice = NULL;}PASN_Choice::PASN_Choice(unsigned tag, TagClass tagClass,                         unsigned upper, BOOL extend, const PASN_Names * nameSpec,unsigned namesCnt)  : PASN_Object(tag, tagClass, extend),    names(nameSpec),namesCount(namesCnt){  numChoices = upper;  choice = NULL;}PASN_Choice::PASN_Choice(const PASN_Choice & other)  : PASN_Object(other),  names(other.names),namesCount(other.namesCount){  numChoices = other.numChoices;  if (other.CheckCreate())    choice = (PASN_Object *)other.choice->Clone();  else    choice = NULL;}PASN_Choice & PASN_Choice::operator=(const PASN_Choice & other){  if (&other == this) // Assigning to ourself, just do nothing.    return *this;  delete choice;  PASN_Object::operator=(other);  numChoices = other.numChoices;  names = other.names;  namesCount = other.namesCount;  if (other.CheckCreate())    choice = (PASN_Object *)other.choice->Clone();  else    choice = NULL;  return *this;}PASN_Choice::~PASN_Choice(){  delete choice;}void PASN_Choice::SetTag(unsigned newTag, TagClass tagClass){  PASN_Object::SetTag(newTag, tagClass);  delete choice;  if (CreateObject())    choice->SetTag(newTag, tagClass);}PString PASN_Choice::GetTagName() const{  PINDEX idx = FindNameByValue(names, namesCount, tag);  if (idx != P_MAX_INDEX)    return names[idx].name;  if (CheckCreate() &&      PIsDescendant(choice, PASN_Choice) &&      choice->GetTag() == tag &&      choice->GetTagClass() == tagClass)    return PString(choice->GetClass()) + "->" + ((PASN_Choice *)choice)->GetTagName();  return psprintf("<%u>", tag);}BOOL PASN_Choice::CheckCreate() const{  if (choice != NULL)    return TRUE;  return ((PASN_Choice *)this)->CreateObject();}PASN_Object & PASN_Choice::GetObject() const{  PAssert(CheckCreate(), "NULL Choice");  return *choice;}#if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9#define CHOICE_CAST_OPERATOR(cls) \  PASN_Choice::operator cls &() const \  { \    PAssert(CheckCreate(), "Cast of NULL choice"); \    PAssert(choice->IsDescendant(cls::Class()), PInvalidCast); \    return *(cls *)choice; \  } \#else#define CHOICE_CAST_OPERATOR(cls) \  PASN_Choice::operator cls &() \  { \    PAssert(CheckCreate(), "Cast of NULL choice"); \    PAssert(PIsDescendant(choice, cls), PInvalidCast); \    return *(cls *)choice; \  } \  PASN_Choice::operator const cls &() const \  { \    PAssert(CheckCreate(), "Cast of NULL choice"); \    PAssert(PIsDescendant(choice, cls), PInvalidCast); \    return *(const cls *)choice; \  } \#endifCHOICE_CAST_OPERATOR(PASN_Null)CHOICE_CAST_OPERATOR(PASN_Boolean)CHOICE_CAST_OPERATOR(PASN_Integer)CHOICE_CAST_OPERATOR(PASN_Enumeration)CHOICE_CAST_OPERATOR(PASN_Real)CHOICE_CAST_OPERATOR(PASN_ObjectId)CHOICE_CAST_OPERATOR(PASN_BitString)CHOICE_CAST_OPERATOR(PASN_OctetString)CHOICE_CAST_OPERATOR(PASN_NumericString)CHOICE_CAST_OPERATOR(PASN_PrintableString)CHOICE_CAST_OPERATOR(PASN_VisibleString)CHOICE_CAST_OPERATOR(PASN_IA5String)CHOICE_CAST_OPERATOR(PASN_GeneralString)CHOICE_CAST_OPERATOR(PASN_BMPString)CHOICE_CAST_OPERATOR(PASN_Sequence)PObject::Comparison PASN_Choice::Compare(const PObject & obj) const{  PAssert(PIsDescendant(&obj, PASN_Choice), PInvalidCast);  const PASN_Choice & other = (const PASN_Choice &)obj;  CheckCreate();  other.CheckCreate();  if (choice == other.choice)    return EqualTo;  if (choice == NULL)    return LessThan;  if (other.choice == NULL)    return GreaterThan;  if (tag < other.tag)    return LessThan;  if (tag > other.tag)    return GreaterThan;  return choice->Compare(*other.choice);}void PASN_Choice::PrintOn(ostream & strm) const{  strm << GetTagName();  if (choice != NULL)    strm << ' ' << *choice;  else    strm << " (NULL)";}PString PASN_Choice::GetTypeAsString() const{  return "Choice";}

⌨️ 快捷键说明

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