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

📄 main.cxx

📁 radius协议源码÷The Radius Stack will connect to a Radius Server. This stack implementation is built upo
💻 CXX
📖 第 1 页 / 共 5 页
字号:
}/////////////////////////////////////////////////////////SingleValueConstraintElement::SingleValueConstraintElement(ValueBase * val){  value = val;}SingleValueConstraintElement::~SingleValueConstraintElement(){  delete value;}void SingleValueConstraintElement::PrintOn(ostream & strm) const{  strm << *value;}void SingleValueConstraintElement::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){  if (value->IsDescendant(IntegerValue::Class())) {    cxx << fn << ", ";    value->GenerateCplusplus(hdr, cxx);    cxx << ", ";    value->GenerateCplusplus(hdr, cxx);    cxx << ");\n";    return;  }  if (value->IsDescendant(CharacterStringValue::Class())) {    cxx << fn << ", ";    value->GenerateCplusplus(hdr, cxx);    cxx << ");\n";    return;  }  PError << StdError(Warning) << "Unsupported constraint type, ignoring." << endl;}/////////////////////////////////////////////////////////ValueRangeConstraintElement::ValueRangeConstraintElement(ValueBase * lowerBound, ValueBase * upperBound){  lower = lowerBound;  upper = upperBound;}ValueRangeConstraintElement::~ValueRangeConstraintElement(){  delete lower;  delete upper;}void ValueRangeConstraintElement::PrintOn(ostream & strm) const{  strm << *lower << ".." << *upper;}void ValueRangeConstraintElement::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){  cxx << fn << ", ";  lower->GenerateCplusplus(hdr, cxx);  cxx << ", ";  upper->GenerateCplusplus(hdr, cxx);  cxx << ");\n";}/////////////////////////////////////////////////////////SubTypeConstraintElement::SubTypeConstraintElement(TypeBase * typ){  subtype = typ;}SubTypeConstraintElement::~SubTypeConstraintElement(){  delete subtype;}void SubTypeConstraintElement::PrintOn(ostream & strm) const{  strm << subtype->GetTypeName();}void SubTypeConstraintElement::GenerateCplusplus(const PString &, ostream & hdr, ostream &){  hdr << subtype->GetTypeName();}BOOL SubTypeConstraintElement::ReferencesType(const TypeBase & type){  return subtype->ReferencesType(type);}/////////////////////////////////////////////////////////NestedConstraintConstraintElement::NestedConstraintConstraintElement(Constraint * con){  constraint = con;}NestedConstraintConstraintElement::~NestedConstraintConstraintElement(){  delete constraint;}BOOL NestedConstraintConstraintElement::ReferencesType(const TypeBase & type){  if (constraint == NULL)    return FALSE;  return constraint->ReferencesType(type);}/////////////////////////////////////////////////////////SizeConstraintElement::SizeConstraintElement(Constraint * constraint)  : NestedConstraintConstraintElement(constraint){}void SizeConstraintElement::PrintOn(ostream & strm) const{  strm << "SIZE" << *constraint;}void SizeConstraintElement::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){  constraint->GenerateCplusplus(fn, hdr, cxx);}/////////////////////////////////////////////////////////FromConstraintElement::FromConstraintElement(Constraint * constraint)  : NestedConstraintConstraintElement(constraint){}void FromConstraintElement::PrintOn(ostream & strm) const{  strm << "FROM" << *constraint;}void FromConstraintElement::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){  PString newfn = fn;  newfn.Replace("SetConstraints(", "SetCharacterSet(");  constraint->GenerateCplusplus(newfn, hdr, cxx);}/////////////////////////////////////////////////////////WithComponentConstraintElement::WithComponentConstraintElement(PString * newName,                                                               Constraint * constraint,                                                               int pres)  : NestedConstraintConstraintElement(constraint){  if (newName != NULL) {    name = *newName;    delete newName;  }  presence = pres;}void WithComponentConstraintElement::PrintOn(ostream & strm) const{  if (name.IsEmpty())    strm << "WITH COMPONENT";  else    strm << name;  if (constraint != NULL)    strm << *constraint;  switch (presence) {    case Present :      strm << " PRESENT";      break;    case Absent :      strm << " ABSENT";      break;    case Optional :      strm << " OPTIONAL";      break;  }}void WithComponentConstraintElement::GenerateCplusplus(const PString &, ostream &, ostream & cxx){  if (presence == Present)    cxx << "  IncludeOptionalField(e_" << name << ");\n";}/////////////////////////////////////////////////////////InnerTypeConstraintElement::InnerTypeConstraintElement(ConstraintElementList * list,                                                       BOOL part)  : ElementListConstraintElement(list){  partial = part;}void InnerTypeConstraintElement::PrintOn(ostream & strm) const{  strm << "WITH COMPONENTS { ";  if (partial)    strm << "..., ";  for (PINDEX i = 0; i < elements.GetSize(); i++) {    if (i > 0)      strm << ", ";    elements[i].PrintOn(strm);  }  strm << " }";}void InnerTypeConstraintElement::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){  for (PINDEX i = 0; i < elements.GetSize(); i++)    elements[i].GenerateCplusplus(fn, hdr, cxx);}/////////////////////////////////////////////////////////UserDefinedConstraintElement::UserDefinedConstraintElement(TypesList * t){  if (t != NULL) {    types = *t;    delete t;  }}void UserDefinedConstraintElement::PrintOn(ostream & strm) const{  strm << "CONSTRAINED BY { ";  for (PINDEX i = 0; i < types.GetSize(); i++) {    if (i > 0)      strm << ", ";    strm << types[i].GetTypeName();  }  strm << " }";}void UserDefinedConstraintElement::GenerateCplusplus(const PString &, ostream &, ostream &){}/////////////////////////////////////////////////////////TypeBase::TypeBase(unsigned tagNum)  : tag(tagNum), defaultTag(tagNum){  isOptional = FALSE;  defaultValue = NULL;  isGenerated = FALSE;}TypeBase::TypeBase(TypeBase * copy)  : name(copy->name),    identifier(MakeIdentifierC(name)),    tag(copy->tag),    defaultTag(copy->tag){  isOptional = copy->isOptional;  defaultValue = NULL;  isGenerated = FALSE;}PObject::Comparison TypeBase::Compare(const PObject & obj) const{  return name.Compare(((const TypeBase &)obj).name);}void TypeBase::PrintOn(ostream & strm) const{  PrintStart(strm);  PrintFinish(strm);}void TypeBase::PrintStart(ostream & strm) const{  strm << indent();  if (!name) {    strm << name;    if (!parameters.IsEmpty()) {      strm << " { ";      for (PINDEX i = 0; i < parameters.GetSize(); i++) {        if (i > 0)          strm << ", ";        strm << parameters[i];      }      strm << " } ";    }    strm << ": ";  }  strm << tag << GetClass() << ' ';  Module->SetIndentLevel(1);}void TypeBase::PrintFinish(ostream & strm) const{  Module->SetIndentLevel(-1);  strm << ' ' << constraints;  if (isOptional)    strm << " OPTIONAL";  if (defaultValue != NULL)    strm << " DEFAULT " << *defaultValue;  strm << '\n';}int TypeBase::GetIdentifierTokenContext() const{  return IDENTIFIER;}int TypeBase::GetBraceTokenContext() const{  return '{';}void TypeBase::SetName(PString * newName){  name = *newName;  delete newName;  identifier = MakeIdentifierC(name);}void TypeBase::AdjustIdentifier(){  identifier = Module->GetPrefix() + MakeIdentifierC(name);}void TypeBase::SetTag(Tag::Type type, unsigned num, Tag::Mode mode){  tag.type = type;  tag.number = num;  tag.mode = mode;}void TypeBase::SetParameters(PStringList * list){  parameters = *list;  delete list;}void TypeBase::MoveConstraints(TypeBase * from){  from->constraints.DisallowDeleteObjects();  while (!from->constraints.IsEmpty())    constraints.Append(from->constraints.RemoveAt(0));  from->constraints.AllowDeleteObjects();}void TypeBase::FlattenUsedTypes(){}TypeBase * TypeBase::FlattenThisType(const TypeBase &){  return this;}BOOL TypeBase::IsChoice() const{  return FALSE;}BOOL TypeBase::IsParameterizedType() const{  return FALSE;}BOOL TypeBase::IsPrimitiveType() const{  return TRUE;}void TypeBase::GenerateCplusplus(ostream & hdr, ostream & cxx){  BeginGenerateCplusplus(hdr, cxx);  // Close off the constructor implementation  cxx << ")\n"         "{\n";  GenerateCplusplusConstraints(PString(), hdr, cxx);  EndGenerateCplusplus(hdr, cxx);}void TypeBase::GenerateForwardDecls(ostream &){}void TypeBase::GenerateOperators(ostream &, ostream &, const TypeBase &){}PString TypeBase::GetTypeName() const{  return GetAncestorClass();}BOOL TypeBase::CanReferenceType() const{  return FALSE;}BOOL TypeBase::ReferencesType(const TypeBase &){  return FALSE;}void TypeBase::SetImportPrefix(const PString &){}BOOL TypeBase::IsParameterisedImport() const{  return FALSE;}void TypeBase::BeginGenerateCplusplus(ostream & hdr, ostream & cxx){  classNameString = GetIdentifier();  if (!parameters.IsEmpty()) {    templatePrefix = "template <";    classNameString += '<';    for (PINDEX i = 0; i < parameters.GetSize(); i++) {      if (i > 0) {        templatePrefix += ", ";        classNameString += ", ";      }      PString ident = MakeIdentifierC(parameters[i]);      templatePrefix += "class " + ident;      classNameString += ident;    }    templatePrefix += ">\n";    classNameString += '>';  }  // Output header file declaration of class  hdr << "//\n"         "// " << GetName() << "\n"         "//\n"         "\n";  GenerateForwardDecls(hdr);  hdr << templatePrefix      << "class " << GetIdentifier() << " : public " << GetTypeName() << "\n"         "{\n"         "#ifndef PASN_LEANANDMEAN\n"         "    PCLASSINFO(" << GetIdentifier() << ", " << GetTypeName() << ");\n"         "#endif\n"         "  public:\n"         "    " << GetIdentifier() << "(unsigned tag = ";  if (tag.type == Tag::Universal &&      tag.number < PARRAYSIZE(UniversalTagNames) &&      UniversalTagNames[tag.number] != NULL)    hdr << UniversalTagNames[tag.number];  else    hdr << tag.number;  hdr << ", TagClass tagClass = " << UniversalTagClassNames[tag.type] << ");\n\n";  // Output cxx file implementation of class  cxx << "//\n"         "// " << GetName() << "\n"         "//\n"         "\n"      << GetTemplatePrefix()      << GetClassNameString() << "::" << GetIdentifier() << "(unsigned tag, PASN_Object::TagClass tagClass)\n"         "  : " << GetTypeName() << "(tag, tagClass";}void TypeBase::EndGenerateCplusplus(ostream & hdr, ostream & cxx){  cxx << "}\n"         "\n"         "\n";  GenerateOperators(hdr, cxx, *this);  // Output header file declaration of class  hdr << "    PObject * Clone() const;\n"         "};\n"         "\n"         "\n";  // Output cxx file implementation of class  cxx << GetTemplatePrefix()      << "PObject * " << GetClassNameString() << "::Clone() const\n"         "{\n"         "#ifndef PASN_LEANANDMEAN\n"         "  PAssert(IsClass(" << GetClassNameString() << "::Class()), PInvalidCast);\n"         "#endif\n"         "  return new " << GetClassNameString() << "(*this);\n"         "}\n"         "\n"         "\n";  isGenerated = TRUE;}void TypeBase::GenerateCplusplusConstructor(ostream &, ostream & cxx){  cxx << '(';  if (HasNonStandardTag()) {    if (tag.type == Tag::Universal &&        tag.number < PARRAYSIZE(UniversalTagNames) &&        UniversalTagNames[tag.number] != NULL)      cxx << UniversalTagNames[tag.number];    else      cxx << tag.number;    cxx << ", " << UniversalTagClassNames[tag.type];  }  cxx << ')';}void TypeBase::GenerateCplusplusConstraints(const PString & prefix, ostream & hdr, ostream & cxx){  for (PINDEX i = 0; i < constraints.GetSize(); i++)    constraints[i].GenerateCplusplus("  " + prefix + "SetConstraints(", hdr, cxx);}/////////////////////////////////////////////////////////

⌨️ 快捷键说明

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