📄 main.cxx
字号:
"\n" << classToHeader[className] << "\n" "\n" "// end of added code\n" "\n"; }}///////////////////////////////////////////// miscellaneous//class indent{ public: indent() { } friend ostream & operator<<(ostream & s, const indent &) { return s << setw(Module->GetIndentLevel()*3) << ' '; }};///////////////////////////////////////////// intermediate structures from parser//NamedNumber::NamedNumber(PString * nam) : name(*nam){ delete nam; number = 0; autonumber = TRUE;}NamedNumber::NamedNumber(PString * nam, int num) : name(*nam){ delete nam; number = num; autonumber = FALSE;}NamedNumber::NamedNumber(PString * nam, const PString & ref) : name(*nam), reference(ref){ delete nam; number = 0; autonumber = FALSE;}void NamedNumber::PrintOn(ostream & strm) const{ strm << name << " ("; if (reference.IsEmpty()) strm << number; else strm << reference; strm << ')';}void NamedNumber::SetAutoNumber(const NamedNumber & prev){ if (autonumber) { number = prev.number + 1; autonumber = FALSE; }}/////////////////////////////////////////////////////////Tag::Tag(unsigned tagNum){ type = Universal; number = tagNum; mode = Module->GetDefaultTagMode();}const char * Tag::classNames[] = { "UNIVERSAL", "APPLICATION", "CONTEXTSPECIFIC", "PRIVATE"};const char * Tag::modeNames[] = { "IMPLICIT", "EXPLICIT", "AUTOMATIC"};void Tag::PrintOn(ostream & strm) const{ if (type != Universal || number != IllegalUniversalTag) { strm << '['; if (type != ContextSpecific) strm << classNames[type] << ' '; strm << number << "] " << modeNames[mode] << ' '; }}/////////////////////////////////////////////////////////Constraint::Constraint(ConstraintElementBase * elmt){ standard.Append(elmt); extendable = FALSE;}Constraint::Constraint(ConstraintElementList * stnd, BOOL extend, ConstraintElementList * ext){ if (stnd != NULL) { standard = *stnd; delete stnd; } extendable = extend; if (ext != NULL) { extensions = *ext; delete ext; }}void Constraint::PrintOn(ostream & strm) const{ strm << '('; for (PINDEX i = 0; i < standard.GetSize(); i++) strm << standard[i]; if (extendable) { strm << indent(); if (standard.GetSize() > 0) strm << ", "; strm << "..., "; for (PINDEX i = 0; i < extensions.GetSize(); i++) strm << extensions[i]; } strm << ')';}void Constraint::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){ switch (standard.GetSize()) { case 0 : return; case 1 : break; default : PError << StdError(Warning) << "unsupported UNION constraints, ignored." << endl; } if (extensions.GetSize() > 0) PError << StdError(Warning) << "unsupported extension constraints, ignored." << endl; PString fn2 = fn; if (fn.Find("PASN_Object::") == P_MAX_INDEX) { if (extendable) fn2 += "PASN_Object::ExtendableConstraint"; else fn2 += "PASN_Object::FixedConstraint"; } standard[0].GenerateCplusplus(fn2, hdr, cxx);}BOOL Constraint::ReferencesType(const TypeBase & type){ PINDEX i; for (i = 0; i < standard.GetSize(); i++) { if (standard[i].ReferencesType(type)) return TRUE; } for (i = 0; i < extensions.GetSize(); i++) { if (extensions[i].ReferencesType(type)) return TRUE; } return FALSE;}/////////////////////////////////////////////////////////ConstraintElementBase::ConstraintElementBase(){ exclusions = NULL;}void ConstraintElementBase::GenerateCplusplus(const PString &, ostream &, ostream &){ PError << StdError(Warning) << "unsupported constraint, ignored." << endl;}BOOL ConstraintElementBase::ReferencesType(const TypeBase &){ return FALSE;}/////////////////////////////////////////////////////////ConstrainAllConstraintElement::ConstrainAllConstraintElement(ConstraintElementBase * excl){ SetExclusions(excl);}/////////////////////////////////////////////////////////ElementListConstraintElement::ElementListConstraintElement(ConstraintElementList * list) : elements(*list){ delete list;}void ElementListConstraintElement::PrintOn(ostream & strm) const{ elements.PrintOn(strm);}void ElementListConstraintElement::GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx){ for (PINDEX i = 0; i < elements.GetSize(); i++) elements[i].GenerateCplusplus(fn, hdr, cxx);}BOOL ElementListConstraintElement::ReferencesType(const TypeBase & type){ for (PINDEX i = 0; i < elements.GetSize(); i++) { if (elements[i].ReferencesType(type)) return TRUE; } return FALSE;}/////////////////////////////////////////////////////////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){ cxx << fn << ", "; value->GenerateCplusplus(hdr, cxx); cxx << ");\n";}/////////////////////////////////////////////////////////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;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -