📄 main.h
字号:
/* * main.h * * PWLib application header file for asnparser * * ASN.1 compiler to produce C++ classes. * * Copyright (c) 1997-1999 Equivalence Pty. Ltd. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is ASN Parser. * * The Initial Developer of the Original Code is Equivalence Pty. Ltd. * * Portions of this code were written with the assisance of funding from * Vovida Networks, Inc. http://www.vovida.com. * * Portions are Copyright (C) 1993 Free Software Foundation, Inc. * All Rights Reserved. * * Contributor(s): ______________________________________. * * $Log: main.h,v $ * Revision 1.11 2000/03/21 21:23:24 robertj * Added option to rename imported module names, allows include filename matching. * * Revision 1.10 1999/09/18 04:17:40 robertj * Added generation of C++ inlines for some functions. * Optimised CreateObject() switch statements, collapsing common cases. * * Revision 1.9 1999/08/09 13:02:36 robertj * Added ASN compiler #defines for backward support of pre GCC 2.9 compilers. * Added ASN compiler #defines to reduce its memory footprint. * Added ASN compiler code generation of assignment operators for string classes. * * Revision 1.8 1999/07/22 06:48:56 robertj * Added comparison operation to base ASN classes and compiled ASN code. * Added support for ANY type in ASN parser. * * Revision 1.7 1999/06/30 08:57:20 robertj * Fixed bug in encodeing sequence of constrained primitive type. Constraint not set. * Fixed bug in not emitting namespace use clause. * Added "normalisation" of separate sequence of <base type> to be single class. * * Revision 1.6 1999/06/09 06:58:09 robertj * Adjusted heading comments. * * Revision 1.5 1999/06/07 01:56:26 robertj * Added header comment on license. * */#ifndef _MAIN_H#define _MAIN_Hextern unsigned lineNumber;extern PString fileName;extern FILE * yyin;extern int yyparse();void yyerror(char * str);///////////////////////////////////////////// standard error output from parser//enum StdErrorType { Warning, Fatal };class StdError { public: StdError(StdErrorType ne) : e(ne) { } //StdError(StdErrorType ne, unsigned ln) : e(ne), l(ln) { } friend ostream & operator<<(ostream & out, const StdError & e); protected: StdErrorType e; //unsigned l;};///////////////////////////////////////////// intermediate structures from parser//class NamedNumber : public PObject{ PCLASSINFO(NamedNumber, PObject); public: NamedNumber(PString * nam); NamedNumber(PString * nam, int num); NamedNumber(PString * nam, const PString & ref); void PrintOn(ostream &) const; void SetAutoNumber(const NamedNumber & prev); const PString & GetName() const { return name; } int GetNumber() const { return number; } protected: PString name; PString reference; int number; BOOL autonumber;};PLIST(NamedNumberList, NamedNumber);// Typesclass TypeBase;PLIST(TypesList, TypeBase);PSORTED_LIST(SortedTypesList, TypeBase);class Tag : public PObject{ PCLASSINFO(Tag, PObject); public: enum Type { Universal, Application, ContextSpecific, Private }; enum UniversalTags { IllegalUniversalTag, UniversalBoolean, UniversalInteger, UniversalBitString, UniversalOctetString, UniversalNull, UniversalObjectId, UniversalObjectDescriptor, UniversalExternalType, UniversalReal, UniversalEnumeration, UniversalEmbeddedPDV, UniversalSequence = 16, UniversalSet, UniversalNumericString, UniversalPrintableString, UniversalTeletexString, UniversalVideotexString, UniversalIA5String, UniversalUTCTime, UniversalGeneralisedTime, UniversalGraphicString, UniversalVisibleString, UniversalGeneralString, UniversalUniversalString, UniversalBMPString = 30 }; enum Mode { Implicit, Explicit, Automatic }; Tag(unsigned tagNum); void PrintOn(ostream &) const; Type type; unsigned number; Mode mode; static const char * classNames[]; static const char * modeNames[];};class ConstraintElementBase;PLIST(ConstraintElementList, ConstraintElementBase);class Constraint : public PObject{ PCLASSINFO(Constraint, PObject); public: Constraint(ConstraintElementBase * elmt); Constraint(ConstraintElementList * std, BOOL extend, ConstraintElementList * ext); void PrintOn(ostream &) const; BOOL IsExtendable() const { return extendable; } void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); BOOL ReferencesType(const TypeBase & type); protected: ConstraintElementList standard; BOOL extendable; ConstraintElementList extensions;};PLIST(ConstraintList, Constraint);class ConstraintElementBase : public PObject{ PCLASSINFO(ConstraintElementBase, PObject); public: ConstraintElementBase(); void SetExclusions(ConstraintElementBase * excl) { exclusions = excl; } virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); virtual BOOL ReferencesType(const TypeBase & type); protected: ConstraintElementBase * exclusions;};class ConstrainAllConstraintElement : public ConstraintElementBase{ PCLASSINFO(ConstrainAllConstraintElement, ConstraintElementBase); public: ConstrainAllConstraintElement(ConstraintElementBase * excl);};class ElementListConstraintElement : public ConstraintElementBase{ PCLASSINFO(ElementListConstraintElement, ConstraintElementBase); public: ElementListConstraintElement(ConstraintElementList * list); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); virtual BOOL ReferencesType(const TypeBase & type); protected: ConstraintElementList elements;};class ValueBase;class SingleValueConstraintElement : public ConstraintElementBase{ PCLASSINFO(SingleValueConstraintElement, ConstraintElementBase); public: SingleValueConstraintElement(ValueBase * val); ~SingleValueConstraintElement(); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); protected: ValueBase * value;};class ValueRangeConstraintElement : public ConstraintElementBase{ PCLASSINFO(ValueRangeConstraintElement, ConstraintElementBase); public: ValueRangeConstraintElement(ValueBase * lowerBound, ValueBase * upperBound); ~ValueRangeConstraintElement(); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); protected: ValueBase * lower; ValueBase * upper;};class TypeBase;class SubTypeConstraintElement : public ConstraintElementBase{ PCLASSINFO(SubTypeConstraintElement, ConstraintElementBase); public: SubTypeConstraintElement(TypeBase * typ); ~SubTypeConstraintElement(); void PrintOn(ostream &) const; void GenerateCplusplus(const PString &, ostream &, ostream &); virtual BOOL ReferencesType(const TypeBase & type); protected: TypeBase * subtype;};class NestedConstraintConstraintElement : public ConstraintElementBase{ PCLASSINFO(NestedConstraintConstraintElement, ConstraintElementBase); public: NestedConstraintConstraintElement(Constraint * con); ~NestedConstraintConstraintElement(); virtual BOOL ReferencesType(const TypeBase & type); protected: Constraint * constraint;};class SizeConstraintElement : public NestedConstraintConstraintElement{ PCLASSINFO(SizeConstraintElement, NestedConstraintConstraintElement); public: SizeConstraintElement(Constraint * constraint); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);};class FromConstraintElement : public NestedConstraintConstraintElement{ PCLASSINFO(FromConstraintElement, NestedConstraintConstraintElement); public: FromConstraintElement(Constraint * constraint); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);};class WithComponentConstraintElement : public NestedConstraintConstraintElement{ PCLASSINFO(WithComponentConstraintElement, NestedConstraintConstraintElement); public: WithComponentConstraintElement(PString * name, Constraint * constraint, int presence); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); enum { Present, Absent, Optional, Default }; protected: PString name; int presence;};class InnerTypeConstraintElement : public ElementListConstraintElement{ PCLASSINFO(InnerTypeConstraintElement, ElementListConstraintElement); public: InnerTypeConstraintElement(ConstraintElementList * list, BOOL partial); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); protected: BOOL partial;};class UserDefinedConstraintElement : public ConstraintElementBase{ PCLASSINFO(UserDefinedConstraintElement, ConstraintElementBase); public: UserDefinedConstraintElement(TypesList * types); void PrintOn(ostream &) const; virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx); protected: TypesList types;};class TypeBase : public PObject{ PCLASSINFO(TypeBase, PObject); public: Comparison Compare(const PObject & obj) const; void PrintOn(ostream &) const; virtual int GetIdentifierTokenContext() const; virtual int GetBraceTokenContext() const; const PString & GetName() const { return name; } void SetName(PString * name); PString GetIdentifier() const { return identifier; } void SetTag(Tag::Type cls, unsigned num, Tag::Mode mode); const Tag & GetTag() const { return tag; } BOOL HasNonStandardTag() const { return tag != defaultTag; } void SetParameters(PStringList * list); void AddConstraint(Constraint * constraint) { constraints.Append(constraint); } BOOL HasConstraints() const { return constraints.GetSize() > 0; } void MoveConstraints(TypeBase * from); BOOL HasParameters() const { return !parameters.IsEmpty(); } BOOL IsOptional() const { return isOptional; } void SetOptional() { isOptional = TRUE; } void SetDefaultValue(ValueBase * value) { defaultValue = value; } const PString & GetTemplatePrefix() const { return templatePrefix; } const PString & GetClassNameString() const { return classNameString; } virtual void AdjustIdentifier(); virtual void FlattenUsedTypes();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -