Added posix library to make files
[pwlib.git] / tools / asnparser / main.h
blobf0a218da871b2b74955509e6616f0615ccc7ebad
1 /*
2 * main.h
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
18 * under the License.
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): ______________________________________.
32 * $Log$
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.
78 #ifndef _MAIN_H
79 #define _MAIN_H
81 extern unsigned lineNumber;
82 extern PString fileName;
83 extern FILE * yyin;
84 extern int yyparse();
86 void yyerror(char * str);
89 /////////////////////////////////////////
91 // standard error output from parser
94 enum StdErrorType { Warning, Fatal };
96 class StdError {
97 public:
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);
102 protected:
103 StdErrorType e;
104 //unsigned l;
108 /////////////////////////////////////////
110 // intermediate structures from parser
114 class NamedNumber : public PObject
116 PCLASSINFO(NamedNumber, PObject);
117 public:
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; }
127 protected:
128 PString name;
129 PString reference;
130 int number;
131 BOOL autonumber;
134 PLIST(NamedNumberList, NamedNumber);
137 // Types
139 class TypeBase;
141 PLIST(TypesList, TypeBase);
142 PSORTED_LIST(SortedTypesList, TypeBase);
144 class Tag : public PObject
146 PCLASSINFO(Tag, PObject);
147 public:
148 enum Type {
149 Universal,
150 Application,
151 ContextSpecific,
152 Private
154 enum UniversalTags {
155 IllegalUniversalTag,
156 UniversalBoolean,
157 UniversalInteger,
158 UniversalBitString,
159 UniversalOctetString,
160 UniversalNull,
161 UniversalObjectId,
162 UniversalObjectDescriptor,
163 UniversalExternalType,
164 UniversalReal,
165 UniversalEnumeration,
166 UniversalEmbeddedPDV,
167 UniversalSequence = 16,
168 UniversalSet,
169 UniversalNumericString,
170 UniversalPrintableString,
171 UniversalTeletexString,
172 UniversalVideotexString,
173 UniversalIA5String,
174 UniversalUTCTime,
175 UniversalGeneralisedTime,
176 UniversalGraphicString,
177 UniversalVisibleString,
178 UniversalGeneralString,
179 UniversalUniversalString,
180 UniversalBMPString = 30
182 enum Mode {
183 Implicit,
184 Explicit,
185 Automatic
187 Tag(unsigned tagNum);
189 void PrintOn(ostream &) const;
191 Type type;
192 unsigned number;
193 Mode mode;
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);
208 public:
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);
218 protected:
219 ConstraintElementList standard;
220 BOOL extendable;
221 ConstraintElementList extensions;
224 PLIST(ConstraintList, Constraint);
227 class ConstraintElementBase : public PObject
229 PCLASSINFO(ConstraintElementBase, PObject);
230 public:
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);
237 protected:
238 ConstraintElementBase * exclusions;
242 class ConstrainAllConstraintElement : public ConstraintElementBase
244 PCLASSINFO(ConstrainAllConstraintElement, ConstraintElementBase);
245 public:
246 ConstrainAllConstraintElement(ConstraintElementBase * excl);
251 class ElementListConstraintElement : public ConstraintElementBase
253 PCLASSINFO(ElementListConstraintElement, ConstraintElementBase);
254 public:
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);
261 protected:
262 ConstraintElementList elements;
266 class ValueBase;
268 class SingleValueConstraintElement : public ConstraintElementBase
270 PCLASSINFO(SingleValueConstraintElement, ConstraintElementBase);
271 public:
272 SingleValueConstraintElement(ValueBase * val);
273 ~SingleValueConstraintElement();
274 void PrintOn(ostream &) const;
276 virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);
278 protected:
279 ValueBase * value;
283 class ValueRangeConstraintElement : public ConstraintElementBase
285 PCLASSINFO(ValueRangeConstraintElement, ConstraintElementBase);
286 public:
287 ValueRangeConstraintElement(ValueBase * lowerBound, ValueBase * upperBound);
288 ~ValueRangeConstraintElement();
289 void PrintOn(ostream &) const;
291 virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);
293 protected:
294 ValueBase * lower;
295 ValueBase * upper;
299 class TypeBase;
301 class SubTypeConstraintElement : public ConstraintElementBase
303 PCLASSINFO(SubTypeConstraintElement, ConstraintElementBase);
304 public:
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);
310 protected:
311 TypeBase * subtype;
315 class NestedConstraintConstraintElement : public ConstraintElementBase
317 PCLASSINFO(NestedConstraintConstraintElement, ConstraintElementBase);
318 public:
319 NestedConstraintConstraintElement(Constraint * con);
320 ~NestedConstraintConstraintElement();
322 virtual BOOL ReferencesType(const TypeBase & type);
324 protected:
325 Constraint * constraint;
329 class SizeConstraintElement : public NestedConstraintConstraintElement
331 PCLASSINFO(SizeConstraintElement, NestedConstraintConstraintElement);
332 public:
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);
342 public:
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);
352 public:
353 WithComponentConstraintElement(PString * name, Constraint * constraint, int presence);
354 void PrintOn(ostream &) const;
355 virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);
357 enum {
358 Present,
359 Absent,
360 Optional,
361 Default
364 protected:
365 PString name;
366 int presence;
370 class InnerTypeConstraintElement : public ElementListConstraintElement
372 PCLASSINFO(InnerTypeConstraintElement, ElementListConstraintElement);
373 public:
374 InnerTypeConstraintElement(ConstraintElementList * list, BOOL partial);
376 void PrintOn(ostream &) const;
377 virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);
379 protected:
380 BOOL partial;
384 class UserDefinedConstraintElement : public ConstraintElementBase
386 PCLASSINFO(UserDefinedConstraintElement, ConstraintElementBase);
387 public:
388 UserDefinedConstraintElement(TypesList * types);
389 void PrintOn(ostream &) const;
390 virtual void GenerateCplusplus(const PString & fn, ostream & hdr, ostream & cxx);
391 protected:
392 TypesList types;
397 class TypeBase : public PObject
399 PCLASSINFO(TypeBase, PObject);
400 public:
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);
446 protected:
447 TypeBase(unsigned tagNum);
448 TypeBase(TypeBase * copy);
450 void PrintStart(ostream &) const;
451 void PrintFinish(ostream &) const;
453 PString name;
454 PString identifier;
455 Tag tag;
456 Tag defaultTag;
457 ConstraintList constraints;
458 BOOL isOptional;
459 ValueBase * defaultValue;
460 BOOL isGenerated;
461 PStringList parameters;
462 PString templatePrefix;
463 PString classNameString;
467 class DefinedType : public TypeBase
469 PCLASSINFO(DefinedType, TypeBase);
470 public:
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);
486 protected:
487 void ConstructFromType(TypeBase * refType, const PString & name);
489 PString referenceName;
490 TypeBase * baseType;
491 BOOL unresolved;
495 class ParameterizedType : public DefinedType
497 PCLASSINFO(ParameterizedType, DefinedType);
498 public:
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);
507 protected:
508 TypesList arguments;
512 class SelectionType : public TypeBase
514 PCLASSINFO(SelectionType, TypeBase);
515 public:
516 SelectionType(PString * name, TypeBase * base);
517 ~SelectionType();
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);
528 protected:
529 PString selection;
530 TypeBase * baseType;
534 class BooleanType : public TypeBase
536 PCLASSINFO(BooleanType, TypeBase);
537 public:
538 BooleanType();
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);
547 public:
548 IntegerType();
549 IntegerType(NamedNumberList *);
550 virtual void GenerateOperators(ostream & hdr, ostream & cxx, const TypeBase & actualType);
551 virtual const char * GetAncestorClass() const;
552 protected:
553 NamedNumberList allowedValues;
557 class EnumeratedType : public TypeBase
559 PCLASSINFO(EnumeratedType, TypeBase);
560 public:
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;
567 protected:
568 NamedNumberList enumerations;
569 PINDEX numEnums;
570 BOOL extendable;
574 class RealType : public TypeBase
576 PCLASSINFO(RealType, TypeBase);
577 public:
578 RealType();
579 virtual const char * GetAncestorClass() const;
583 class BitStringType : public TypeBase
585 PCLASSINFO(BitStringType, TypeBase);
586 public:
587 BitStringType();
588 BitStringType(NamedNumberList *);
589 virtual int GetIdentifierTokenContext() const;
590 virtual int GetBraceTokenContext() const;
591 virtual const char * GetAncestorClass() const;
592 protected:
593 NamedNumberList allowedBits;
597 class OctetStringType : public TypeBase
599 PCLASSINFO(OctetStringType, TypeBase);
600 public:
601 OctetStringType();
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);
610 public:
611 NullType();
612 virtual const char * GetAncestorClass() const;
616 class SequenceType : public TypeBase
618 PCLASSINFO(SequenceType, TypeBase);
619 void PrintOn(ostream &) const;
620 public:
621 SequenceType(TypesList * std,
622 BOOL extendable,
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);
632 protected:
633 TypesList fields;
634 PINDEX numFields;
635 BOOL extendable;
639 class SequenceOfType : public TypeBase
641 PCLASSINFO(SequenceOfType, TypeBase);
642 public:
643 SequenceOfType(TypeBase * base, Constraint * constraint, unsigned tag = Tag::UniversalSequence);
644 ~SequenceOfType();
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);
654 protected:
655 TypeBase * baseType;
659 class SetType : public SequenceType
661 PCLASSINFO(SetType, SequenceType);
662 public:
663 SetType();
664 SetType(SequenceType * seq);
665 virtual const char * GetAncestorClass() const;
669 class SetOfType : public SequenceOfType
671 PCLASSINFO(SetOfType, SequenceOfType);
672 public:
673 SetOfType(TypeBase * base, Constraint * constraint);
677 class ChoiceType : public SequenceType
679 PCLASSINFO(ChoiceType, SequenceType);
680 public:
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);
696 public:
697 EmbeddedPDVType();
698 virtual const char * GetAncestorClass() const;
702 class ExternalType : public TypeBase
704 PCLASSINFO(ExternalType, TypeBase);
705 public:
706 ExternalType();
707 virtual const char * GetAncestorClass() const;
711 class AnyType : public TypeBase
713 PCLASSINFO(AnyType, TypeBase);
714 public:
715 AnyType(PString * ident);
716 void PrintOn(ostream & strm) const;
717 virtual const char * GetAncestorClass() const;
718 protected:
719 PString identifier;
723 class StringTypeBase : public TypeBase
725 PCLASSINFO(StringTypeBase, TypeBase);
726 public:
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);
736 public:
737 BMPStringType();
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);
746 public:
747 GeneralStringType();
748 virtual const char * GetAncestorClass() const;
752 class GraphicStringType : public StringTypeBase
754 PCLASSINFO(GraphicStringType, StringTypeBase);
755 public:
756 GraphicStringType();
757 virtual const char * GetAncestorClass() const;
761 class IA5StringType : public StringTypeBase
763 PCLASSINFO(IA5StringType, StringTypeBase);
764 public:
765 IA5StringType();
766 virtual const char * GetAncestorClass() const;
770 class ISO646StringType : public StringTypeBase
772 PCLASSINFO(ISO646StringType, StringTypeBase);
773 public:
774 ISO646StringType();
775 virtual const char * GetAncestorClass() const;
779 class NumericStringType : public StringTypeBase
781 PCLASSINFO(NumericStringType, StringTypeBase);
782 public:
783 NumericStringType();
784 virtual const char * GetAncestorClass() const;
788 class PrintableStringType : public StringTypeBase
790 PCLASSINFO(PrintableStringType, StringTypeBase);
791 public:
792 PrintableStringType();
793 virtual const char * GetAncestorClass() const;
797 class TeletexStringType : public StringTypeBase
799 PCLASSINFO(TeletexStringType, StringTypeBase);
800 public:
801 TeletexStringType();
802 virtual const char * GetAncestorClass() const;
806 class T61StringType : public StringTypeBase
808 PCLASSINFO(T61StringType, StringTypeBase);
809 public:
810 T61StringType();
811 virtual const char * GetAncestorClass() const;
815 class UniversalStringType : public StringTypeBase
817 PCLASSINFO(UniversalStringType, StringTypeBase);
818 public:
819 UniversalStringType();
820 virtual const char * GetAncestorClass() const;
824 class VideotexStringType : public StringTypeBase
826 PCLASSINFO(VideotexStringType, StringTypeBase);
827 public:
828 VideotexStringType();
829 virtual const char * GetAncestorClass() const;
833 class VisibleStringType : public StringTypeBase
835 PCLASSINFO(VisibleStringType, StringTypeBase);
836 public:
837 VisibleStringType();
838 virtual const char * GetAncestorClass() const;
842 class UnrestrictedCharacterStringType : public StringTypeBase
844 PCLASSINFO(UnrestrictedCharacterStringType, StringTypeBase);
845 public:
846 UnrestrictedCharacterStringType();
847 virtual const char * GetAncestorClass() const;
851 class GeneralizedTimeType : public TypeBase
853 PCLASSINFO(GeneralizedTimeType, TypeBase);
854 public:
855 GeneralizedTimeType();
856 virtual const char * GetAncestorClass() const;
860 class UTCTimeType : public TypeBase
862 PCLASSINFO(UTCTimeType, TypeBase);
863 public:
864 UTCTimeType();
865 virtual const char * GetAncestorClass() const;
869 class ObjectDescriptorType : public TypeBase
871 PCLASSINFO(ObjectDescriptorType, TypeBase);
872 public:
873 ObjectDescriptorType();
874 virtual const char * GetAncestorClass() const;
878 class ObjectIdentifierType : public TypeBase
880 PCLASSINFO(ObjectIdentifierType, TypeBase);
881 public:
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);
892 public:
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);
901 protected:
902 PString asnObjectClassName;
903 PString asnObjectClassField;
907 class ImportedType : public TypeBase
909 PCLASSINFO(ImportedType, TypeBase);
910 public:
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;
917 protected:
918 PString modulePrefix;
919 BOOL parameterised;
923 class SearchType : public TypeBase
925 PCLASSINFO(SearchType, TypeBase);
926 public:
927 SearchType(const PString & name);
928 virtual const char * GetAncestorClass() const;
932 // Values
934 class ValueBase : public PObject
936 PCLASSINFO(ValueBase, PObject);
937 public:
938 void SetValueName(PString * name);
939 const PString & GetName() const { return valueName; }
941 virtual void GenerateCplusplus(ostream & hdr, ostream & cxx);
943 protected:
944 void PrintBase(ostream &) const;
945 PString valueName;
948 PLIST(ValuesList, ValueBase);
951 class DefinedValue : public ValueBase
953 PCLASSINFO(DefinedValue, ValueBase);
954 public:
955 DefinedValue(PString * name);
956 void PrintOn(ostream &) const;
957 const PString & GetReference() const { return referenceName; }
958 virtual void GenerateCplusplus(ostream & hdr, ostream & cxx);
959 protected:
960 PString referenceName;
961 ValueBase * actualValue;
962 BOOL unresolved;
966 class BooleanValue : public ValueBase
968 PCLASSINFO(BooleanValue, ValueBase);
969 public:
970 BooleanValue(BOOL newVal);
971 void PrintOn(ostream &) const;
972 virtual void GenerateCplusplus(ostream & hdr, ostream & cxx);
973 protected:
974 BOOL value;
978 class IntegerValue : public ValueBase
980 PCLASSINFO(IntegerValue, ValueBase);
981 public:
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; }
989 protected:
990 PInt64 value;
994 class RealValue : public ValueBase
996 PCLASSINFO(RealValue, ValueBase);
997 public:
998 RealValue(double newVal);
999 protected:
1000 double value;
1004 class OctetStringValue : public ValueBase
1006 PCLASSINFO(OctetStringValue, ValueBase);
1007 public:
1008 OctetStringValue() { }
1009 OctetStringValue(PString * newVal);
1010 protected:
1011 PBYTEArray value;
1015 class BitStringValue : public ValueBase
1017 PCLASSINFO(BitStringValue, ValueBase);
1018 public:
1019 BitStringValue() { }
1020 BitStringValue(PString * newVal);
1021 BitStringValue(PStringList * newVal);
1022 protected:
1023 PBYTEArray value;
1027 class NullValue : public ValueBase
1029 PCLASSINFO(NullValue, ValueBase);
1033 class CharacterValue : public ValueBase
1035 PCLASSINFO(CharacterValue, ValueBase);
1036 public:
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);
1042 protected:
1043 unsigned value;
1047 class CharacterStringValue : public ValueBase
1049 PCLASSINFO(CharacterStringValue, ValueBase);
1050 public:
1051 CharacterStringValue() { }
1052 CharacterStringValue(PString * newVal);
1053 CharacterStringValue(PStringList * newVal);
1054 void PrintOn(ostream &) const;
1055 virtual void GenerateCplusplus(ostream & hdr, ostream & cxx);
1056 protected:
1057 PString value;
1061 class ObjectIdentifierValue : public ValueBase
1063 PCLASSINFO(ObjectIdentifierValue, ValueBase);
1064 public:
1065 ObjectIdentifierValue(PString * newVal);
1066 ObjectIdentifierValue(PStringList * newVal);
1067 void PrintOn(ostream &) const;
1068 protected:
1069 PStringList value;
1073 class MinValue : public ValueBase
1075 PCLASSINFO(MinValue, ValueBase);
1076 public:
1077 void PrintOn(ostream &) const;
1078 virtual void GenerateCplusplus(ostream & hdr, ostream & cxx);
1082 class MaxValue : public ValueBase
1084 PCLASSINFO(MaxValue, ValueBase);
1085 public:
1086 void PrintOn(ostream &) const;
1087 virtual void GenerateCplusplus(ostream & hdr, ostream & cxx);
1091 class SequenceValue : public ValueBase
1093 PCLASSINFO(SequenceValue, ValueBase);
1094 public:
1095 SequenceValue(ValuesList * list = NULL);
1096 void PrintOn(ostream &) const;
1097 protected:
1098 ValuesList values;
1102 class MibBase : public PObject
1104 PCLASSINFO(MibBase, PObject);
1105 public:
1106 MibBase(PString * name, PString * descr, PString * refer, ValueBase * val);
1107 virtual ~MibBase();
1108 protected:
1109 PString name;
1110 PString description;
1111 PString reference;
1112 ValueBase * value;
1115 PLIST(MibList, MibBase);
1118 class MibObject : public MibBase
1120 PCLASSINFO(MibObject, MibBase);
1121 public:
1122 enum Access {
1123 read_only,
1124 read_write,
1125 write_only,
1126 not_accessible,
1128 enum Status {
1129 mandatory,
1130 optional,
1131 obsolete,
1132 deprecated
1134 MibObject(PString * name, TypeBase * type, Access acc, Status stat,
1135 PString * descr, PString * refer, PStringList * idx,
1136 ValueBase * defVal,
1137 ValueBase * setVal);
1138 ~MibObject();
1139 void PrintOn(ostream &) const;
1140 protected:
1141 TypeBase * type;
1142 Access access;
1143 Status status;
1144 PStringList index;
1145 ValueBase * defaultValue;
1149 class MibTrap : public MibBase
1151 PCLASSINFO(MibTrap, MibBase);
1152 public:
1153 MibTrap(PString * nam, ValueBase * ent, ValuesList * var,
1154 PString * descr, PString * refer, ValueBase * val);
1155 ~MibTrap();
1156 void PrintOn(ostream &) const;
1157 protected:
1158 ValueBase * enterprise;
1159 ValuesList variables;
1163 class ImportModule : public PObject
1165 PCLASSINFO(ImportModule, PObject);
1166 public:
1167 ImportModule(PString * name, TypesList * syms);
1169 void PrintOn(ostream &) const;
1171 void GenerateCplusplus(ostream & hdr, ostream & cxx);
1173 protected:
1174 PString fullModuleName;
1175 PString shortModuleName;
1176 PString filename;
1177 PString directoryPrefix;
1178 TypesList symbols;
1181 PLIST(ImportsList, ImportModule);
1184 class ModuleDefinition : public PObject
1186 PCLASSINFO(ModuleDefinition, PObject);
1187 public:
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,
1220 unsigned numFiles,
1221 BOOL useNamespaces,
1222 BOOL useInlines,
1223 BOOL useOperators,
1224 BOOL verbose);
1227 protected:
1228 PString moduleName;
1229 PString classNamePrefix;
1230 BOOL separateClassFiles;
1231 PStringList definitiveId;
1232 Tag::Mode defaultTagMode;
1233 TypesList exports;
1234 BOOL exportAll;
1235 ImportsList imports;
1236 PStringToString importNames;
1237 TypesList types;
1238 SortedTypesList sortedTypes;
1239 ValuesList values;
1240 MibList mibs;
1241 int indentLevel;
1242 BOOL usingInlines;
1243 BOOL usingOperators;
1247 extern ModuleDefinition * Module;
1250 #endif