📄 main.h
字号:
class SizeConstraintElement : public NestedConstraintConstraintElement{ public: SizeConstraintElement(ConstraintPtr constraint); virtual void GetConstraint(std::string& str) const; void PrintOn(std::ostream &) const; virtual void GenerateCplusplus(const std::string & fn, std::ostream & hdr, std::ostream & cxx, std::ostream & inl) const; virtual const SizeConstraintElement* GetSizeConstraint() const;};class FromConstraintElement : public NestedConstraintConstraintElement{ public: FromConstraintElement(ConstraintPtr constraint); virtual void GetConstraint(std::string& str) const; void PrintOn(std::ostream &) const; virtual void GenerateCplusplus(const std::string & fn, std::ostream & hdr, std::ostream & cxx, std::ostream & inl) const; virtual const FromConstraintElement* GetFromConstraint() const; std::string GetCharacterSet(const char* canonicalSet, int canonicalSetSize) const; int GetRange(std::ostream& cxx) const;};class WithComponentConstraintElement : public NestedConstraintConstraintElement{ public: WithComponentConstraintElement(std::string name, ConstraintPtr constraint, int presence); void PrintOn(std::ostream &) const; virtual void GenerateCplusplus(const std::string & fn, std::ostream & hdr, std::ostream & cxx, std::ostream & inl) const; virtual bool HasPERInvisibleConstraint(const Parameter&) const { return false; } enum { Present, Absent, Optional, Default }; protected: std::string name; int presence;};class InnerTypeConstraintElement : public ElementListConstraintElement{ public: InnerTypeConstraintElement(std::auto_ptr<ConstraintElementVector> list, bool partial); void PrintOn(std::ostream &) const; virtual void GenerateCplusplus(const std::string & fn, std::ostream & hdr, std::ostream & cxx, std::ostream & inl) const; protected: bool partial;};class ActualParameter;typedef boost::shared_ptr<ActualParameter> ActualParameterPtr;typedef std::vector<ActualParameterPtr> ActualParameterList;typedef boost::shared_ptr<ActualParameterList> ActualParameterListPtr;class UserDefinedConstraintElement : public ConstraintElementBase{ public: UserDefinedConstraintElement(ActualParameterListPtr list); void PrintOn(std::ostream &) const; virtual void GenerateCplusplus(const std::string & fn, std::ostream & hdr, std::ostream & cxx, std::ostream & inl) const; virtual bool HasPERInvisibleConstraint(const Parameter&) const { return true; } protected: ActualParameterListPtr parameters;};class DefinedObjectSet;typedef boost::shared_ptr<DefinedObjectSet> DefinedObjectSetPtr;class TableConstraint { public: TableConstraint(boost::shared_ptr<DefinedObjectSet> objSet, std::auto_ptr<StringList> atNotations = std::auto_ptr<StringList>()); ~TableConstraint(); bool ReferenceType(const TypeBase& type); std::string GetObjectSetIdentifier() const; const StringList* GetAtNotations() const { return atNotations.get();} private: boost::shared_ptr<DefinedObjectSet> objSet; std::auto_ptr<StringList> atNotations;};/////////////////////////////////////////////class Parameter : public Printable{ public: Parameter(const std::string& name); Parameter(const std::string& name, int type); Parameter(const Parameter& other); int GetIdentifierType(); const std::string& GetName() const; void PrintOn(std::ostream& strm) const; virtual bool IsTypeParameter() const { return true;} virtual bool ReferencedBy(const TypeBase&) const ; virtual ActualParameterPtr MakeActualParameter() const; protected: std::string name; int identifierType;};class ValueParameter : public Parameter{ public: ValueParameter(TypePtr governor, const std::string& nam ); ValueParameter(const ValueParameter& other); ~ValueParameter(); TypeBase* GetGovernor() { return governor.get();} void PrintOn(std::ostream& strm) const; virtual bool IsTypeParameter() const { return false;} virtual bool ReferencedBy(const TypeBase&) const { return false;} virtual ActualParameterPtr MakeActualParameter() const; protected: TypePtr governor;};class DefinedObjectClass;typedef boost::shared_ptr<DefinedObjectClass> DefinedObjectClassPtr;class ObjectParameter : public Parameter{ public: ObjectParameter(DefinedObjectClassPtr governor, const std::string& name); ~ObjectParameter(); DefinedObjectClass* GetGovernor() { return governor.get();} void PrintOn(std::ostream& strm) const; virtual bool IsTypeParameter() const { return false;} virtual bool ReferencedBy(const TypeBase&) const ; virtual ActualParameterPtr MakeActualParameter() const; protected: DefinedObjectClassPtr governor;};typedef boost::shared_ptr<Parameter> ParameterPtr;typedef std::vector<ParameterPtr> ParameterListRep;class ParameterList : public Printable{ public: void Append(ParameterPtr param); bool IsEmpty() const { return rep.empty();} int GetIdentifierType(const char* identifier); Parameter* GetParameter(const char* identifier); void GenerateCplusplus(std::string& templatePrefix, std::string& classNameString); void PrintOn(std::ostream& strm) const; boost::shared_ptr<ParameterList> GetReferencedParameters(const TypeBase& type) const; ActualParameterListPtr MakeActualParameters() const; void swap(ParameterList& other) { rep.swap(other.rep); } ParameterListRep rep;};typedef boost::shared_ptr<ParameterList> ParameterListPtr;////////////////////////////////////////////class ModuleDefinition;class TypeBase : public Printable{ public: void PrintOn(std::ostream &) const; void BeginParseValue() const; void EndParseValue() const; void BeginParseValueSet() const; void EndParseValueSet() const; const std::string & GetName() const { return name; } void SetName(const std::string& name); void SetAsValueSetType() { isValueSetType = true;} std::string 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(ParameterList& list); void AddConstraint(ConstraintPtr constraint) { constraints.push_back(constraint); } bool HasConstraints() const ; void MoveConstraints(TypeBase& from); void CopyConstraints(const TypeBase& from); virtual bool HasParameters() const { return !parameters.IsEmpty(); } bool IsOptional() const { return isOptional; } void SetOptional() { isOptional = true; } void SetDefaultValue(ValuePtr value); const std::string & GetTemplatePrefix() const { return templatePrefix; } const std::string & GetClassNameString() const { return classNameString; } void SetOuterClassName(const std::string& name) { outerClassName = name; } void SetTemplatePrefix(const std::string& name) { templatePrefix = name; } bool IsValueSetType() const { return isValueSetType;} virtual void AdjustIdentifier(bool); virtual void FlattenUsedTypes(); virtual TypePtr FlattenThisType(TypePtr& self, const TypeBase & parent); virtual bool IsChoice() const; virtual bool IsParameterizedType() const; virtual bool IsPrimitiveType() const; virtual bool IsSequenceOfType() const { return false;} virtual void GenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual void GenerateForwardDecls(std::ostream & hdr); virtual void GenerateOperators(std::ostream & hdr, std::ostream & cxx, const TypeBase & actualType); virtual const char * GetAncestorClass() const = 0; virtual std::string GetTypeName() const; virtual bool CanReferenceType() const; virtual bool ReferencesType(const TypeBase & type) const; virtual const std::string& GetCModuleName() const; virtual bool IsParameterisedImport() const; virtual bool CanBeFwdDeclared(bool isComponent = false) const; virtual bool FwdDeclareMe(std::ostream & hdr); virtual void GenerateInfo(const TypeBase* type, std::ostream & hdr, std::ostream& cxx); bool IsGenerated() const { return isGenerated; } virtual void BeginGenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); void EndGenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); void GenerateTags(std::ostream & strm) const; void GenerateCplusplusConstraints(const std::string & prefix, std::ostream & hdr, std::ostream & cxx, std::ostream & inl) const; const ConstraintList& GetConstraints() const { return constraints;} virtual void BeginParseThisTypeValue() const {} virtual void EndParseThisTypeValue() const {} virtual void ResolveReference() const {} virtual std::string GetPrimitiveType() const; virtual void RemovePERInvisibleConstraint(const ParameterPtr&); void RemovePERInvisibleConstraints(); virtual bool UseType(const TypeBase& ) const { return false; } virtual void GenerateConstructors(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual bool NeedGenInfo() const ; TypePtr SeqOfFlattenThisType(const TypeBase & parent, TypePtr thisPtr); const ParameterList& GetParameters() const { return parameters; } virtual void GenerateDecoder(std::ostream&){} enum RemoveReuslt { OK, MAY_NOT, FORBIDDEN }; virtual RemoveReuslt CanRemoveType(const TypeBase&) { return OK; } virtual bool RemoveThisType(const TypeBase& type) { return GetName() == type.GetName();} virtual bool IsRemovedType() const { return false;} ModuleDefinition* GetModule() const { return module;} protected: TypeBase(unsigned tagNum, ModuleDefinition* md); TypeBase(TypeBase& copy); void PrintStart(std::ostream &) const; void PrintFinish(std::ostream &) const; const char* GetClass() const; Tag tag; Tag defaultTag; std::string name; // The ASN.1 Type name std::string identifier; // The converted C Type name ConstraintList constraints; bool isOptional; ValuePtr defaultValue; bool isGenerated; ParameterList parameters; std::string templatePrefix; std::string classNameString; std::string shortClassNameString; std::string outerClassName; bool isValueSetType; ModuleDefinition* module;};class DefinedType : public TypeBase{ public: DefinedType(const std::string& name); DefinedType(TypePtr refType); DefinedType(TypePtr refType, TypePtr& bType); DefinedType(TypePtr refType, const std::string & name); DefinedType(TypePtr refType, const TypeBase & parent); void PrintOn(std::ostream &) const; virtual bool IsChoice() const; virtual bool IsParameterizedType() const; virtual void GenerateOperators(std::ostream & hdr, std::ostream & cxx, const TypeBase & actualType); virtual const char * GetAncestorClass() const; virtual std::string GetTypeName() const; virtual bool CanReferenceType() const; virtual bool ReferencesType(const TypeBase & type) const; virtual void GenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual bool CanBeFwdDeclared(bool isComponent = false) const ; virtual void BeginParseThisTypeValue() const; virtual void EndParseThisTypeValue() const; virtual void ResolveReference() const; virtual const std::string& GetCModuleName() const; virtual bool UseType(const TypeBase& type) const ; virtual bool NeedGenInfo() const; virtual RemoveReuslt CanRemoveType(const TypeBase&) ; virtual bool RemoveThisType(const TypeBase&); virtual std::string GetPrimitiveType() const; virtual void GenerateInfo(const TypeBase* type, std::ostream& hdr, std::ostream& cxx); virtual TypePtr FlattenThisType(TypePtr& self, const TypeBase & parent); protected: void ConstructFromType(TypePtr& refType, const std::string & name); std::string referenceName; mutable TypePtr baseType; mutable bool unresolved;};class ParameterizedType : public DefinedType{ public: ParameterizedType(const std::string& name, ActualParameterList& args); ParameterizedType(TypePtr& refType, const TypeBase& parent, ActualParameterList& args); void PrintOn(std::ostream &) const; virtual bool IsParameterizedType() const; virtual std::string GetTypeName() const; virtual bool ReferencesType(const TypeBase & type) const; virtual bool UseType(const TypeBase& type) const ; virtual RemoveReuslt CanRemoveType(const TypeBase&); protected: ActualParameterList arguments;};class SelectionType : public TypeBase{ public: SelectionType(const std::string& name, TypePtr base); ~SelectionType(); void PrintOn(std::ostream &) const; virtual void FlattenUsedTypes(); virtual TypePtr FlattenThisType(TypePtr& self, const TypeBase & parent); virtual void GenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual const char * GetAncestorClass() const; virtual bool CanReferenceType() const; virtual bool ReferencesType(const TypeBase & type) const; virtual bool UseType(const TypeBase& type) const ; protected: std::string selection; TypePtr baseType;};class BooleanType : public TypeBase{ public: BooleanType(); virtual void GenerateOperators(std::ostream & hdr, std::ostream & cxx, const TypeBase & actualType); virtual const char * GetAncestorClass() const; virtual std::string GetPrimitiveType() const { return "bool";} virtual void GenerateConstructors(std::ostream & hdr, std::ostream & cxx, std::ostream & inl);};class IntegerType : public TypeBase{ public: IntegerType(); IntegerType(NamedNumberList&); virtual const char * GetAncestorClass() const; virtual void GenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); std::string GetTypeName() const; virtual std::string GetPrimitiveType() const { return GetIdentifier() + "::value_type::int_type"; } virtual bool CanReferenceType() const; virtual bool ReferencesType(const TypeBase & type) const; virtual void GenerateConstructors(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual bool NeedGenInfo() const; virtual void GenerateInfo(const TypeBase* type, std::ostream& , std::ostream&); virtual TypePtr FlattenThisType(TypePtr& self, const TypeBase & parent); protected: NamedNumberList allowedValues;};class EnumeratedType : public TypeBase{ public: EnumeratedType(NamedNumberList& enums, bool extend, NamedNumberList* ext); void PrintOn(std::ostream &) const; virtual TypePtr FlattenThisType(TypePtr& self, const TypeBase & parent); virtual void GenerateCplusplus(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual void GenerateOperators(std::ostream & hdr, std::ostream & cxx, const TypeBase & actualType); virtual const char * GetAncestorClass() const; virtual std::string GetPrimitiveType() const { return GetIdentifier() + "::value_type::NamedNumber";} virtual void GenerateConstructors(std::ostream & hdr, std::ostream & cxx, std::ostream & inl); virtual bool NeedGenInfo() const { return true;} bool IsPrimitiveType() const; virtual void GenerateInfo(const TypeBase* type, std::ostream& hdr, std::ostream& cxx); protected: NamedNumberList enumerations; size_t numEnums; bool extendable;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -