4 * PWLib application header file for asnparser
6 * ASN.1 compiler to produce C++ classes.
8 * Copyright (c) 1997-1999 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is ASN Parser.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions of this code were written with the assisance of funding from
25 * Vovida Networks, Inc. http://www.vovida.com.
27 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
28 * All Rights Reserved.
30 * Contributor(s): ______________________________________.
33 * Revision 1.15 2003/10/03 00:13:04 rjongbloed
34 * Added ability to specify CHOICE field selection by function rather than operator as the operator technique does not work with some dumb compilers.
35 * Added ability to specify that the header file name be different from the module name and module prefix string.
37 * Revision 1.14 2003/02/27 04:04:14 robertj
38 * Added ability to have alternate directories for header file
39 * includes in generated C++ code.
41 * Revision 1.13 2001/08/03 09:01:02 robertj
42 * Added assignement operator with RHS of PWORDArray to classes
43 * descended from PASN_BMPString.
45 * Revision 1.12 2001/06/14 02:09:20 robertj
46 * Corrected support for ASN object class type reference constructs
47 * ie TYPE-IDENTIFIER.&Type encoded as octet string.
49 * Revision 1.11 2000/03/21 21:23:24 robertj
50 * Added option to rename imported module names, allows include filename matching.
52 * Revision 1.10 1999/09/18 04:17:40 robertj
53 * Added generation of C++ inlines for some functions.
54 * Optimised CreateObject() switch statements, collapsing common cases.
56 * Revision 1.9 1999/08/09 13:02:36 robertj
57 * Added ASN compiler #defines for backward support of pre GCC 2.9 compilers.
58 * Added ASN compiler #defines to reduce its memory footprint.
59 * Added ASN compiler code generation of assignment operators for string classes.
61 * Revision 1.8 1999/07/22 06:48:56 robertj
62 * Added comparison operation to base ASN classes and compiled ASN code.
63 * Added support for ANY type in ASN parser.
65 * Revision 1.7 1999/06/30 08:57:20 robertj
66 * Fixed bug in encodeing sequence of constrained primitive type. Constraint not set.
67 * Fixed bug in not emitting namespace use clause.
68 * Added "normalisation" of separate sequence of <base type> to be single class.
70 * Revision 1.6 1999/06/09 06:58:09 robertj
71 * Adjusted heading comments.
73 * Revision 1.5 1999/06/07 01:56:26 robertj
74 * Added header comment on license.
81 extern unsigned lineNumber
;
82 extern PString fileName
;
86 void yyerror(char * str
);
89 /////////////////////////////////////////
91 // standard error output from parser
94 enum StdErrorType
{ Warning
, Fatal
};
98 StdError(StdErrorType ne
) : e(ne
) { }
99 //StdError(StdErrorType ne, unsigned ln) : e(ne), l(ln) { }
100 friend ostream
& operator<<(ostream
& out
, const StdError
& e
);
108 /////////////////////////////////////////
110 // intermediate structures from parser
114 class NamedNumber
: public PObject
116 PCLASSINFO(NamedNumber
, PObject
);
118 NamedNumber(PString
* nam
);
119 NamedNumber(PString
* nam
, int num
);
120 NamedNumber(PString
* nam
, const PString
& ref
);
121 void PrintOn(ostream
&) const;
123 void SetAutoNumber(const NamedNumber
& prev
);
124 const PString
& GetName() const { return name
; }
125 int GetNumber() const { return number
; }
134 PLIST(NamedNumberList
, NamedNumber
);
141 PLIST(TypesList
, TypeBase
);
142 PSORTED_LIST(SortedTypesList
, TypeBase
);
144 class Tag
: public PObject
146 PCLASSINFO(Tag
, PObject
);
159 UniversalOctetString
,
162 UniversalObjectDescriptor
,
163 UniversalExternalType
,
165 UniversalEnumeration
,
166 UniversalEmbeddedPDV
,
167 UniversalSequence
= 16,
169 UniversalNumericString
,
170 UniversalPrintableString
,
171 UniversalTeletexString
,
172 UniversalVideotexString
,
175 UniversalGeneralisedTime
,
176 UniversalGraphicString
,
177 UniversalVisibleString
,
178 UniversalGeneralString
,
179 UniversalUniversalString
,
180 UniversalBMPString
= 30
187 Tag(unsigned tagNum
);
189 void PrintOn(ostream
&) const;
195 static const char * classNames
[];
196 static const char * modeNames
[];
200 class ConstraintElementBase
;
202 PLIST(ConstraintElementList
, ConstraintElementBase
);
205 class Constraint
: public PObject
207 PCLASSINFO(Constraint
, PObject
);
209 Constraint(ConstraintElementBase
* elmt
);
210 Constraint(ConstraintElementList
* std
, BOOL extend
, ConstraintElementList
* ext
);
212 void PrintOn(ostream
&) const;
214 BOOL
IsExtendable() const { return extendable
; }
215 void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
216 BOOL
ReferencesType(const TypeBase
& type
);
219 ConstraintElementList standard
;
221 ConstraintElementList extensions
;
224 PLIST(ConstraintList
, Constraint
);
227 class ConstraintElementBase
: public PObject
229 PCLASSINFO(ConstraintElementBase
, PObject
);
231 ConstraintElementBase();
232 void SetExclusions(ConstraintElementBase
* excl
) { exclusions
= excl
; }
234 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
235 virtual BOOL
ReferencesType(const TypeBase
& type
);
238 ConstraintElementBase
* exclusions
;
242 class ConstrainAllConstraintElement
: public ConstraintElementBase
244 PCLASSINFO(ConstrainAllConstraintElement
, ConstraintElementBase
);
246 ConstrainAllConstraintElement(ConstraintElementBase
* excl
);
251 class ElementListConstraintElement
: public ConstraintElementBase
253 PCLASSINFO(ElementListConstraintElement
, ConstraintElementBase
);
255 ElementListConstraintElement(ConstraintElementList
* list
);
256 void PrintOn(ostream
&) const;
258 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
259 virtual BOOL
ReferencesType(const TypeBase
& type
);
262 ConstraintElementList elements
;
268 class SingleValueConstraintElement
: public ConstraintElementBase
270 PCLASSINFO(SingleValueConstraintElement
, ConstraintElementBase
);
272 SingleValueConstraintElement(ValueBase
* val
);
273 ~SingleValueConstraintElement();
274 void PrintOn(ostream
&) const;
276 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
283 class ValueRangeConstraintElement
: public ConstraintElementBase
285 PCLASSINFO(ValueRangeConstraintElement
, ConstraintElementBase
);
287 ValueRangeConstraintElement(ValueBase
* lowerBound
, ValueBase
* upperBound
);
288 ~ValueRangeConstraintElement();
289 void PrintOn(ostream
&) const;
291 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
301 class SubTypeConstraintElement
: public ConstraintElementBase
303 PCLASSINFO(SubTypeConstraintElement
, ConstraintElementBase
);
305 SubTypeConstraintElement(TypeBase
* typ
);
306 ~SubTypeConstraintElement();
307 void PrintOn(ostream
&) const;
308 void GenerateCplusplus(const PString
&, ostream
&, ostream
&);
309 virtual BOOL
ReferencesType(const TypeBase
& type
);
315 class NestedConstraintConstraintElement
: public ConstraintElementBase
317 PCLASSINFO(NestedConstraintConstraintElement
, ConstraintElementBase
);
319 NestedConstraintConstraintElement(Constraint
* con
);
320 ~NestedConstraintConstraintElement();
322 virtual BOOL
ReferencesType(const TypeBase
& type
);
325 Constraint
* constraint
;
329 class SizeConstraintElement
: public NestedConstraintConstraintElement
331 PCLASSINFO(SizeConstraintElement
, NestedConstraintConstraintElement
);
333 SizeConstraintElement(Constraint
* constraint
);
334 void PrintOn(ostream
&) const;
335 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
339 class FromConstraintElement
: public NestedConstraintConstraintElement
341 PCLASSINFO(FromConstraintElement
, NestedConstraintConstraintElement
);
343 FromConstraintElement(Constraint
* constraint
);
344 void PrintOn(ostream
&) const;
345 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
349 class WithComponentConstraintElement
: public NestedConstraintConstraintElement
351 PCLASSINFO(WithComponentConstraintElement
, NestedConstraintConstraintElement
);
353 WithComponentConstraintElement(PString
* name
, Constraint
* constraint
, int presence
);
354 void PrintOn(ostream
&) const;
355 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
370 class InnerTypeConstraintElement
: public ElementListConstraintElement
372 PCLASSINFO(InnerTypeConstraintElement
, ElementListConstraintElement
);
374 InnerTypeConstraintElement(ConstraintElementList
* list
, BOOL partial
);
376 void PrintOn(ostream
&) const;
377 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
384 class UserDefinedConstraintElement
: public ConstraintElementBase
386 PCLASSINFO(UserDefinedConstraintElement
, ConstraintElementBase
);
388 UserDefinedConstraintElement(TypesList
* types
);
389 void PrintOn(ostream
&) const;
390 virtual void GenerateCplusplus(const PString
& fn
, ostream
& hdr
, ostream
& cxx
);
397 class TypeBase
: public PObject
399 PCLASSINFO(TypeBase
, PObject
);
401 Comparison
Compare(const PObject
& obj
) const;
402 void PrintOn(ostream
&) const;
404 virtual int GetIdentifierTokenContext() const;
405 virtual int GetBraceTokenContext() const;
407 const PString
& GetName() const { return name
; }
408 void SetName(PString
* name
);
409 PString
GetIdentifier() const { return identifier
; }
410 void SetTag(Tag::Type cls
, unsigned num
, Tag::Mode mode
);
411 const Tag
& GetTag() const { return tag
; }
412 BOOL
HasNonStandardTag() const { return tag
!= defaultTag
; }
413 void SetParameters(PStringList
* list
);
414 void AddConstraint(Constraint
* constraint
) { constraints
.Append(constraint
); }
415 BOOL
HasConstraints() const { return constraints
.GetSize() > 0; }
416 void MoveConstraints(TypeBase
* from
);
417 BOOL
HasParameters() const { return !parameters
.IsEmpty(); }
418 BOOL
IsOptional() const { return isOptional
; }
419 void SetOptional() { isOptional
= TRUE
; }
420 void SetDefaultValue(ValueBase
* value
) { defaultValue
= value
; }
421 const PString
& GetTemplatePrefix() const { return templatePrefix
; }
422 const PString
& GetClassNameString() const { return classNameString
; }
424 virtual void AdjustIdentifier();
425 virtual void FlattenUsedTypes();
426 virtual TypeBase
* FlattenThisType(const TypeBase
& parent
);
427 virtual BOOL
IsChoice() const;
428 virtual BOOL
IsParameterizedType() const;
429 virtual BOOL
IsPrimitiveType() const;
430 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
431 virtual void GenerateForwardDecls(ostream
& hdr
);
432 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
433 virtual const char * GetAncestorClass() const = 0;
434 virtual PString
GetTypeName() const;
435 virtual BOOL
CanReferenceType() const;
436 virtual BOOL
ReferencesType(const TypeBase
& type
);
437 virtual void SetImportPrefix(const PString
&);
438 virtual BOOL
IsParameterisedImport() const;
440 BOOL
IsGenerated() const { return isGenerated
; }
441 void BeginGenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
442 void EndGenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
443 void GenerateCplusplusConstructor(ostream
& hdr
, ostream
& cxx
);
444 void GenerateCplusplusConstraints(const PString
& prefix
, ostream
& hdr
, ostream
& cxx
);
447 TypeBase(unsigned tagNum
);
448 TypeBase(TypeBase
* copy
);
450 void PrintStart(ostream
&) const;
451 void PrintFinish(ostream
&) const;
457 ConstraintList constraints
;
459 ValueBase
* defaultValue
;
461 PStringList parameters
;
462 PString templatePrefix
;
463 PString classNameString
;
467 class DefinedType
: public TypeBase
469 PCLASSINFO(DefinedType
, TypeBase
);
471 DefinedType(PString
* name
, BOOL parameter
);
472 DefinedType(TypeBase
* refType
, TypeBase
* bType
);
473 DefinedType(TypeBase
* refType
, const PString
& name
);
474 DefinedType(TypeBase
* refType
, const TypeBase
& parent
);
476 void PrintOn(ostream
&) const;
478 virtual BOOL
IsChoice() const;
479 virtual BOOL
IsParameterizedType() const;
480 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
481 virtual const char * GetAncestorClass() const;
482 virtual PString
GetTypeName() const;
483 virtual BOOL
CanReferenceType() const;
484 virtual BOOL
ReferencesType(const TypeBase
& type
);
487 void ConstructFromType(TypeBase
* refType
, const PString
& name
);
489 PString referenceName
;
495 class ParameterizedType
: public DefinedType
497 PCLASSINFO(ParameterizedType
, DefinedType
);
499 ParameterizedType(PString
* name
, TypesList
* args
);
501 void PrintOn(ostream
&) const;
503 virtual BOOL
IsParameterizedType() const;
504 virtual PString
GetTypeName() const;
505 virtual BOOL
ReferencesType(const TypeBase
& type
);
512 class SelectionType
: public TypeBase
514 PCLASSINFO(SelectionType
, TypeBase
);
516 SelectionType(PString
* name
, TypeBase
* base
);
519 void PrintOn(ostream
&) const;
521 virtual void FlattenUsedTypes();
522 virtual TypeBase
* FlattenThisType(const TypeBase
& parent
);
523 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
524 virtual const char * GetAncestorClass() const;
525 virtual BOOL
CanReferenceType() const;
526 virtual BOOL
ReferencesType(const TypeBase
& type
);
534 class BooleanType
: public TypeBase
536 PCLASSINFO(BooleanType
, TypeBase
);
539 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
540 virtual const char * GetAncestorClass() const;
544 class IntegerType
: public TypeBase
546 PCLASSINFO(IntegerType
, TypeBase
);
549 IntegerType(NamedNumberList
*);
550 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
551 virtual const char * GetAncestorClass() const;
553 NamedNumberList allowedValues
;
557 class EnumeratedType
: public TypeBase
559 PCLASSINFO(EnumeratedType
, TypeBase
);
561 EnumeratedType(NamedNumberList
* enums
, BOOL extend
, NamedNumberList
* ext
);
562 void PrintOn(ostream
&) const;
563 virtual TypeBase
* FlattenThisType(const TypeBase
& parent
);
564 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
565 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
566 virtual const char * GetAncestorClass() const;
568 NamedNumberList enumerations
;
574 class RealType
: public TypeBase
576 PCLASSINFO(RealType
, TypeBase
);
579 virtual const char * GetAncestorClass() const;
583 class BitStringType
: public TypeBase
585 PCLASSINFO(BitStringType
, TypeBase
);
588 BitStringType(NamedNumberList
*);
589 virtual int GetIdentifierTokenContext() const;
590 virtual int GetBraceTokenContext() const;
591 virtual const char * GetAncestorClass() const;
593 NamedNumberList allowedBits
;
597 class OctetStringType
: public TypeBase
599 PCLASSINFO(OctetStringType
, TypeBase
);
602 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
603 virtual const char * GetAncestorClass() const;
607 class NullType
: public TypeBase
609 PCLASSINFO(NullType
, TypeBase
);
612 virtual const char * GetAncestorClass() const;
616 class SequenceType
: public TypeBase
618 PCLASSINFO(SequenceType
, TypeBase
);
619 void PrintOn(ostream
&) const;
621 SequenceType(TypesList
* std
,
623 TypesList
* extensions
,
624 unsigned tagNum
= Tag::UniversalSequence
);
625 virtual void FlattenUsedTypes();
626 virtual TypeBase
* FlattenThisType(const TypeBase
& parent
);
627 virtual BOOL
IsPrimitiveType() const;
628 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
629 virtual const char * GetAncestorClass() const;
630 virtual BOOL
CanReferenceType() const;
631 virtual BOOL
ReferencesType(const TypeBase
& type
);
639 class SequenceOfType
: public TypeBase
641 PCLASSINFO(SequenceOfType
, TypeBase
);
643 SequenceOfType(TypeBase
* base
, Constraint
* constraint
, unsigned tag
= Tag::UniversalSequence
);
645 void PrintOn(ostream
&) const;
646 virtual void FlattenUsedTypes();
647 virtual TypeBase
* FlattenThisType(const TypeBase
& parent
);
648 virtual BOOL
IsPrimitiveType() const;
649 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
650 virtual void GenerateForwardDecls(ostream
& hdr
);
651 virtual const char * GetAncestorClass() const;
652 virtual BOOL
CanReferenceType() const;
653 virtual BOOL
ReferencesType(const TypeBase
& type
);
659 class SetType
: public SequenceType
661 PCLASSINFO(SetType
, SequenceType
);
664 SetType(SequenceType
* seq
);
665 virtual const char * GetAncestorClass() const;
669 class SetOfType
: public SequenceOfType
671 PCLASSINFO(SetOfType
, SequenceOfType
);
673 SetOfType(TypeBase
* base
, Constraint
* constraint
);
677 class ChoiceType
: public SequenceType
679 PCLASSINFO(ChoiceType
, SequenceType
);
681 ChoiceType(TypesList
* std
= NULL
,
682 BOOL extendable
= FALSE
,
683 TypesList
* extensions
= NULL
);
684 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
685 virtual void GenerateForwardDecls(ostream
& hdr
);
686 virtual BOOL
IsPrimitiveType() const;
687 virtual BOOL
IsChoice() const;
688 virtual const char * GetAncestorClass() const;
689 virtual BOOL
ReferencesType(const TypeBase
& type
);
693 class EmbeddedPDVType
: public TypeBase
695 PCLASSINFO(EmbeddedPDVType
, TypeBase
);
698 virtual const char * GetAncestorClass() const;
702 class ExternalType
: public TypeBase
704 PCLASSINFO(ExternalType
, TypeBase
);
707 virtual const char * GetAncestorClass() const;
711 class AnyType
: public TypeBase
713 PCLASSINFO(AnyType
, TypeBase
);
715 AnyType(PString
* ident
);
716 void PrintOn(ostream
& strm
) const;
717 virtual const char * GetAncestorClass() const;
723 class StringTypeBase
: public TypeBase
725 PCLASSINFO(StringTypeBase
, TypeBase
);
727 StringTypeBase(int tag
);
728 virtual int GetBraceTokenContext() const;
729 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
733 class BMPStringType
: public StringTypeBase
735 PCLASSINFO(BMPStringType
, StringTypeBase
);
738 virtual const char * GetAncestorClass() const;
739 virtual void GenerateOperators(ostream
& hdr
, ostream
& cxx
, const TypeBase
& actualType
);
743 class GeneralStringType
: public StringTypeBase
745 PCLASSINFO(GeneralStringType
, StringTypeBase
);
748 virtual const char * GetAncestorClass() const;
752 class GraphicStringType
: public StringTypeBase
754 PCLASSINFO(GraphicStringType
, StringTypeBase
);
757 virtual const char * GetAncestorClass() const;
761 class IA5StringType
: public StringTypeBase
763 PCLASSINFO(IA5StringType
, StringTypeBase
);
766 virtual const char * GetAncestorClass() const;
770 class ISO646StringType
: public StringTypeBase
772 PCLASSINFO(ISO646StringType
, StringTypeBase
);
775 virtual const char * GetAncestorClass() const;
779 class NumericStringType
: public StringTypeBase
781 PCLASSINFO(NumericStringType
, StringTypeBase
);
784 virtual const char * GetAncestorClass() const;
788 class PrintableStringType
: public StringTypeBase
790 PCLASSINFO(PrintableStringType
, StringTypeBase
);
792 PrintableStringType();
793 virtual const char * GetAncestorClass() const;
797 class TeletexStringType
: public StringTypeBase
799 PCLASSINFO(TeletexStringType
, StringTypeBase
);
802 virtual const char * GetAncestorClass() const;
806 class T61StringType
: public StringTypeBase
808 PCLASSINFO(T61StringType
, StringTypeBase
);
811 virtual const char * GetAncestorClass() const;
815 class UniversalStringType
: public StringTypeBase
817 PCLASSINFO(UniversalStringType
, StringTypeBase
);
819 UniversalStringType();
820 virtual const char * GetAncestorClass() const;
824 class VideotexStringType
: public StringTypeBase
826 PCLASSINFO(VideotexStringType
, StringTypeBase
);
828 VideotexStringType();
829 virtual const char * GetAncestorClass() const;
833 class VisibleStringType
: public StringTypeBase
835 PCLASSINFO(VisibleStringType
, StringTypeBase
);
838 virtual const char * GetAncestorClass() const;
842 class UnrestrictedCharacterStringType
: public StringTypeBase
844 PCLASSINFO(UnrestrictedCharacterStringType
, StringTypeBase
);
846 UnrestrictedCharacterStringType();
847 virtual const char * GetAncestorClass() const;
851 class GeneralizedTimeType
: public TypeBase
853 PCLASSINFO(GeneralizedTimeType
, TypeBase
);
855 GeneralizedTimeType();
856 virtual const char * GetAncestorClass() const;
860 class UTCTimeType
: public TypeBase
862 PCLASSINFO(UTCTimeType
, TypeBase
);
865 virtual const char * GetAncestorClass() const;
869 class ObjectDescriptorType
: public TypeBase
871 PCLASSINFO(ObjectDescriptorType
, TypeBase
);
873 ObjectDescriptorType();
874 virtual const char * GetAncestorClass() const;
878 class ObjectIdentifierType
: public TypeBase
880 PCLASSINFO(ObjectIdentifierType
, TypeBase
);
882 ObjectIdentifierType();
883 virtual int GetIdentifierTokenContext() const;
884 virtual int GetBraceTokenContext() const;
885 virtual const char * GetAncestorClass() const;
889 class ObjectClassFieldType
: public TypeBase
891 PCLASSINFO(ObjectClassFieldType
, TypeBase
);
893 ObjectClassFieldType(PString
* objclass
, PString
* field
);
894 virtual const char * GetAncestorClass() const;
895 void PrintOn(ostream
&) const;
896 virtual TypeBase
* FlattenThisType(const TypeBase
& parent
);
897 virtual BOOL
IsPrimitiveType() const;
898 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
899 virtual BOOL
CanReferenceType() const;
900 virtual BOOL
ReferencesType(const TypeBase
& type
);
902 PString asnObjectClassName
;
903 PString asnObjectClassField
;
907 class ImportedType
: public TypeBase
909 PCLASSINFO(ImportedType
, TypeBase
);
911 ImportedType(PString
* name
, BOOL parameterised
);
912 virtual const char * GetAncestorClass() const;
913 virtual void AdjustIdentifier();
914 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
915 virtual void SetImportPrefix(const PString
&);
916 virtual BOOL
IsParameterisedImport() const;
918 PString modulePrefix
;
923 class SearchType
: public TypeBase
925 PCLASSINFO(SearchType
, TypeBase
);
927 SearchType(const PString
& name
);
928 virtual const char * GetAncestorClass() const;
934 class ValueBase
: public PObject
936 PCLASSINFO(ValueBase
, PObject
);
938 void SetValueName(PString
* name
);
939 const PString
& GetName() const { return valueName
; }
941 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
944 void PrintBase(ostream
&) const;
948 PLIST(ValuesList
, ValueBase
);
951 class DefinedValue
: public ValueBase
953 PCLASSINFO(DefinedValue
, ValueBase
);
955 DefinedValue(PString
* name
);
956 void PrintOn(ostream
&) const;
957 const PString
& GetReference() const { return referenceName
; }
958 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
960 PString referenceName
;
961 ValueBase
* actualValue
;
966 class BooleanValue
: public ValueBase
968 PCLASSINFO(BooleanValue
, ValueBase
);
970 BooleanValue(BOOL newVal
);
971 void PrintOn(ostream
&) const;
972 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
978 class IntegerValue
: public ValueBase
980 PCLASSINFO(IntegerValue
, ValueBase
);
982 IntegerValue(PInt64 newVal
);
983 void PrintOn(ostream
&) const;
984 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
986 operator PInt64() const { return value
; }
987 operator long() const { return (long)value
; }
994 class RealValue
: public ValueBase
996 PCLASSINFO(RealValue
, ValueBase
);
998 RealValue(double newVal
);
1004 class OctetStringValue
: public ValueBase
1006 PCLASSINFO(OctetStringValue
, ValueBase
);
1008 OctetStringValue() { }
1009 OctetStringValue(PString
* newVal
);
1015 class BitStringValue
: public ValueBase
1017 PCLASSINFO(BitStringValue
, ValueBase
);
1019 BitStringValue() { }
1020 BitStringValue(PString
* newVal
);
1021 BitStringValue(PStringList
* newVal
);
1027 class NullValue
: public ValueBase
1029 PCLASSINFO(NullValue
, ValueBase
);
1033 class CharacterValue
: public ValueBase
1035 PCLASSINFO(CharacterValue
, ValueBase
);
1037 CharacterValue(BYTE c
);
1038 CharacterValue(BYTE t1
, BYTE t2
);
1039 CharacterValue(BYTE q1
, BYTE q2
, BYTE q3
, BYTE q4
);
1040 void PrintOn(ostream
&) const;
1041 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
1047 class CharacterStringValue
: public ValueBase
1049 PCLASSINFO(CharacterStringValue
, ValueBase
);
1051 CharacterStringValue() { }
1052 CharacterStringValue(PString
* newVal
);
1053 CharacterStringValue(PStringList
* newVal
);
1054 void PrintOn(ostream
&) const;
1055 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
1061 class ObjectIdentifierValue
: public ValueBase
1063 PCLASSINFO(ObjectIdentifierValue
, ValueBase
);
1065 ObjectIdentifierValue(PString
* newVal
);
1066 ObjectIdentifierValue(PStringList
* newVal
);
1067 void PrintOn(ostream
&) const;
1073 class MinValue
: public ValueBase
1075 PCLASSINFO(MinValue
, ValueBase
);
1077 void PrintOn(ostream
&) const;
1078 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
1082 class MaxValue
: public ValueBase
1084 PCLASSINFO(MaxValue
, ValueBase
);
1086 void PrintOn(ostream
&) const;
1087 virtual void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
1091 class SequenceValue
: public ValueBase
1093 PCLASSINFO(SequenceValue
, ValueBase
);
1095 SequenceValue(ValuesList
* list
= NULL
);
1096 void PrintOn(ostream
&) const;
1102 class MibBase
: public PObject
1104 PCLASSINFO(MibBase
, PObject
);
1106 MibBase(PString
* name
, PString
* descr
, PString
* refer
, ValueBase
* val
);
1110 PString description
;
1115 PLIST(MibList
, MibBase
);
1118 class MibObject
: public MibBase
1120 PCLASSINFO(MibObject
, MibBase
);
1134 MibObject(PString
* name
, TypeBase
* type
, Access acc
, Status stat
,
1135 PString
* descr
, PString
* refer
, PStringList
* idx
,
1137 ValueBase
* setVal
);
1139 void PrintOn(ostream
&) const;
1145 ValueBase
* defaultValue
;
1149 class MibTrap
: public MibBase
1151 PCLASSINFO(MibTrap
, MibBase
);
1153 MibTrap(PString
* nam
, ValueBase
* ent
, ValuesList
* var
,
1154 PString
* descr
, PString
* refer
, ValueBase
* val
);
1156 void PrintOn(ostream
&) const;
1158 ValueBase
* enterprise
;
1159 ValuesList variables
;
1163 class ImportModule
: public PObject
1165 PCLASSINFO(ImportModule
, PObject
);
1167 ImportModule(PString
* name
, TypesList
* syms
);
1169 void PrintOn(ostream
&) const;
1171 void GenerateCplusplus(ostream
& hdr
, ostream
& cxx
);
1174 PString fullModuleName
;
1175 PString shortModuleName
;
1177 PString directoryPrefix
;
1181 PLIST(ImportsList
, ImportModule
);
1184 class ModuleDefinition
: public PObject
1186 PCLASSINFO(ModuleDefinition
, PObject
);
1188 ModuleDefinition(PString
* name
, PStringList
* id
, Tag::Mode defTagMode
);
1190 void PrintOn(ostream
&) const;
1192 Tag::Mode
GetDefaultTagMode() const { return defaultTagMode
; }
1194 void SetExportAll();
1195 void SetExports(TypesList
* syms
);
1197 void AddImport(ImportModule
* mod
) { imports
.Append(mod
); }
1198 void AddType(TypeBase
* type
) { types
.Append(type
); }
1199 void AddValue(ValueBase
* val
) { values
.Append(val
); }
1200 void AddMIB(MibBase
* mib
) { mibs
.Append(mib
); }
1202 void AppendType(TypeBase
* type
);
1203 TypeBase
* FindType(const PString
& name
);
1204 const ValuesList
& GetValues() const { return values
; }
1206 const PString
& GetModuleName() const { return moduleName
; }
1207 const PString
& GetPrefix() const { return classNamePrefix
; }
1209 PString
GetImportModuleName(const PString
& moduleName
);
1211 int GetIndentLevel() const { return indentLevel
; }
1212 void SetIndentLevel(int delta
) { indentLevel
+= delta
; }
1214 BOOL
UsingInlines() const { return usingInlines
; }
1215 BOOL
UsingOperators() const { return usingOperators
; }
1217 void GenerateCplusplus(const PFilePath
& path
,
1218 const PString
& modName
,
1219 const PString
& headerDir
,
1229 PString classNamePrefix
;
1230 BOOL separateClassFiles
;
1231 PStringList definitiveId
;
1232 Tag::Mode defaultTagMode
;
1235 ImportsList imports
;
1236 PStringToString importNames
;
1238 SortedTypesList sortedTypes
;
1243 BOOL usingOperators
;
1247 extern ModuleDefinition
* Module
;