asner.h

Go to the documentation of this file.
00001 /*
00002  * asner.h
00003  *
00004  * Abstract Syntax Notation Encoding Rules classes
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Log: asner.h,v $
00027  * Revision 1.48  2007/05/16 09:11:44  csoutheren
00028  * Fix warnings on gcc 4.2.0
00029  *
00030  * Revision 1.47  2007/04/18 23:49:50  csoutheren
00031  * Add usage of precompiled headers
00032  *
00033  * Revision 1.46  2005/11/25 01:01:13  csoutheren
00034  * Applied patch #1351168
00035  * PWlib various fixes
00036  *
00037  * Revision 1.45  2005/06/07 06:25:53  csoutheren
00038  * Applied patch 1199897 to increase speed of ASN parser debugging output
00039  * Thanks to Dmitriy <ddv@abinet.com>
00040  *
00041  * Revision 1.44  2004/11/11 07:34:50  csoutheren
00042  * Added #include <ptlib.h>
00043  *
00044  * Revision 1.43  2004/04/18 04:33:35  rjongbloed
00045  * Changed all operators that return BOOL to return standard type bool. This is primarily
00046  *   for improved compatibility with std STL usage removing many warnings.
00047  *
00048  * Revision 1.42  2003/12/14 10:21:29  rjongbloed
00049  * Fixed bug in length incorrectlty decoded from ASN and (apparently) rare circumstances. Thanks pangxg@hotmail.com.
00050  * Cleaned up return values to be BOOL rather than int for some functions.
00051  *
00052  * Revision 1.41  2003/08/18 23:32:22  rjongbloed
00053  * Micro optimisation suggested by Chih-Wei Huang
00054  *
00055  * Revision 1.40  2003/08/01 16:00:51  csoutheren
00056  * Changed #if to #ifdef to (maybe) avoid compiler problems with gcc 2.95.2
00057  *
00058  * Revision 1.39  2003/08/01 02:12:34  csoutheren
00059  * Changed to allow easy isolation of PER, BER and XER encoding/decoding routines
00060  *
00061  * Revision 1.38  2003/04/22 23:39:09  craigs
00062  * Changed some functions from protected to public for MacOSX. Thanks to Hugo Santos
00063  *
00064  * Revision 1.37  2003/04/17 14:44:44  craigs
00065  * Removed MacOS specific defines to make some attributes public
00066  * Thanks to Hugo Santos and apologies to Roger Hardiman
00067  *
00068  * Revision 1.36  2003/02/26 01:57:44  robertj
00069  * Added XML encoding rules to ASN system, thanks Federico Pinna
00070  *
00071  * Revision 1.35  2003/02/01 13:25:52  robertj
00072  * Added function to add new elements directly to ASN array.
00073  *
00074  * Revision 1.34  2003/01/24 23:43:43  robertj
00075  * Fixed subtle problems with the use of MAX keyword for unsigned numbers,
00076  *   should beUINT_MAX not INT_MAX, thanks Stevie Gray for pointing it out.
00077  *
00078  * Revision 1.33  2002/11/26 23:29:18  robertj
00079  * Added missing const to DecodeSubType() function.
00080  *
00081  * Revision 1.32  2002/11/06 22:47:23  robertj
00082  * Fixed header comment (copyright etc)
00083  *
00084  * Revision 1.31  2002/10/31 05:50:49  robertj
00085  * Changed to use new UTF-8/UCS-2 conversion functions on PString.
00086  *
00087  * Revision 1.30  2002/10/10 14:37:40  rogerh
00088  * In two of the PASN classes make the protected members public. This
00089  * makes OpenH323 compile in Mac OS X 10.2.1
00090  *
00091  * Revision 1.29  2002/09/16 01:08:59  robertj
00092  * Added #define so can select if #pragma interface/implementation is used on
00093  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00094  *
00095  * Revision 1.28  2002/05/29 01:22:35  robertj
00096  * Added ability to set object id from unsigned integer arrays.
00097  *
00098  * Revision 1.27  2002/05/21 04:23:40  robertj
00099  * Fixed problem with ASN encoding/decoding unsconstrained negative numbers,
00100  *
00101  * Revision 1.26  2002/05/14 06:59:31  robertj
00102  * Added more bullet proofing so a malformed PDU cannot cause teh decoder
00103  *   to try and allocate huge arrays and consume all CPU and memory on a
00104  *   system. A configurable limit of 100 is set for things like SEQUENCE OF.
00105  *
00106  * Revision 1.25  2001/12/13 09:13:28  robertj
00107  * Added function get get oid as a string.
00108  * Added functions to compare oid to PString.
00109  *
00110  * Revision 1.24  2001/09/14 01:59:59  robertj
00111  * Fixed problem with incorrectly initialised PASN_Choice sub-object.
00112  *
00113  * Revision 1.23  2001/08/06 01:39:02  robertj
00114  * Added assignement operator with RHS of PASN_BMPString to classes
00115  *   descended from PASN_BMPString.
00116  *
00117  * Revision 1.22  2001/06/14 02:14:12  robertj
00118  * Added functions to encode and decode another ASN type that is inside
00119  *   an octet string, useful for ANY or EXTERNAL types etc.
00120  *
00121  * Revision 1.21  2001/04/30 06:47:04  robertj
00122  * Fixed problem with en/decoding more than 16 extension fields in a sequence.
00123  *
00124  * Revision 1.20  2001/04/26 08:15:58  robertj
00125  * Fixed problem with ASN compile of single constraints on enumerations.
00126  *
00127  * Revision 1.19  2001/04/23 04:40:14  robertj
00128  * Added ASN standard types GeneralizedTime and UTCTime
00129  *
00130  * Revision 1.18  2001/04/12 03:25:22  robertj
00131  * Fixed PASN_Boolean cosntructor to be compatible with usage in ASN parser.
00132  * Changed all PASN_xxx types so constructor can take real type as only
00133  *   parameter. eg PASN_OctetString s = "fred";
00134  *
00135  * Revision 1.17  2001/03/21 03:32:35  robertj
00136  * Aded ability to get at the data bits buffer in a PASN_BitString
00137  *
00138  * Revision 1.16  2001/01/24 04:36:56  robertj
00139  * Added more bulletproofing to ASN structures to obey constraints.
00140  *
00141  * Revision 1.15  2000/10/26 11:09:07  robertj
00142  * More bullet proofing of PER decoder, changed bit type to be unsigned.
00143  *
00144  * Revision 1.14  2000/10/25 04:05:44  robertj
00145  * More bullet proofing of PER decoder.
00146  *
00147  * Revision 1.13  2000/07/11 18:23:03  robertj
00148  * Added ability to set/get BMP string data as PWORDArray.
00149  *
00150  * Revision 1.12  2000/04/10 17:30:42  robertj
00151  * Added [] operator for char access on ASN string classes.
00152  *
00153  * Revision 1.11  2000/02/29 06:32:12  robertj
00154  * Added ability to remove optional field in sequence, thanks Dave Harvey.
00155  *
00156  * Revision 1.10  1999/08/09 13:02:45  robertj
00157  * dded ASN compiler #defines for backward support of pre GCC 2.9 compilers.
00158  * Added ASN compiler #defines to reduce its memory footprint.
00159  *
00160  * Revision 1.9  1999/07/22 06:48:51  robertj
00161  * Added comparison operation to base ASN classes and compiled ASN code.
00162  * Added support for ANY type in ASN parser.
00163  *
00164  * Revision 1.8  1999/03/09 09:34:05  robertj
00165  * Fixed typo's.
00166  *
00167  * Revision 1.7  1999/03/09 08:01:46  robertj
00168  * Changed comments for doc++ support (more to come).
00169  *
00170  * Revision 1.6  1998/09/23 06:19:21  robertj
00171  * Added open source copyright license.
00172  *
00173  * Revision 1.5  1998/05/21 04:26:53  robertj
00174  * Fixed numerous PER problems.
00175  *
00176  * Revision 1.4  1998/05/07 05:19:28  robertj
00177  * Fixed problems with using copy constructor/assignment oeprator on PASN_Objects.
00178  *
00179  * Revision 1.3  1997/12/18 05:08:13  robertj
00180  * Added function to get choice discriminat`or name.
00181  *
00182  * Revision 1.2  1997/12/11 10:35:42  robertj
00183  * Support for new ASN file parser.
00184  *
00185  */
00186 
00187 #ifndef _ASNER_H
00188 #define _ASNER_H
00189 
00190 #ifdef P_USE_PRAGMA
00191 #pragma interface
00192 #endif
00193 
00194 // provide options to omit vertain encodings, if needed
00195 #define     P_INCLUDE_PER
00196 #define     P_INCLUDE_BER
00197 #define     P_INCLUDE_XER
00198 
00199 class PASN_Stream;
00200 class PBER_Stream;
00201 class PPER_Stream;
00202 
00203 #if P_EXPAT
00204 class PXER_Stream;
00205 class PXMLElement;
00206 #else
00207 #undef      P_INCLUDE_XER
00208 #endif
00209 
00210 #ifndef _PTLIB_H
00211 #include <ptlib.h>
00212 #endif
00213 
00215 
00218 class PASN_Object : public PObject
00219 {
00220     PCLASSINFO(PASN_Object, PObject);
00221   public:
00223     virtual PString GetTypeAsString() const = 0;
00224 
00225     PINDEX GetObjectLength() const;
00226     virtual PINDEX GetDataLength() const = 0;
00227     virtual BOOL IsPrimitive() const { return TRUE; }
00228 
00229     virtual BOOL Decode(PASN_Stream &) = 0;
00230     virtual void Encode(PASN_Stream &) const = 0;
00231 
00232     BOOL IsExtendable() const { return extendable; }
00233     void SetExtendable(BOOL ext = TRUE) { extendable = ext; }
00234 
00235     enum TagClass {
00236       UniversalTagClass,
00237       ApplicationTagClass,
00238       ContextSpecificTagClass,
00239       PrivateTagClass,
00240       DefaultTagClass
00241     };
00242     TagClass GetTagClass() const { return tagClass; }
00243 
00244     enum UniversalTags {
00245       InvalidUniversalTag,
00246       UniversalBoolean,
00247       UniversalInteger,
00248       UniversalBitString,
00249       UniversalOctetString,
00250       UniversalNull,
00251       UniversalObjectId,
00252       UniversalObjectDescriptor,
00253       UniversalExternalType,
00254       UniversalReal,
00255       UniversalEnumeration,
00256       UniversalEmbeddedPDV,
00257       UniversalSequence = 16,
00258       UniversalSet,
00259       UniversalNumericString,
00260       UniversalPrintableString,
00261       UniversalTeletexString,
00262       UniversalVideotexString,
00263       UniversalIA5String,
00264       UniversalUTCTime,
00265       UniversalGeneralisedTime,
00266       UniversalGeneralizedTime = UniversalGeneralisedTime,
00267       UniversalGraphicString,
00268       UniversalVisibleString,
00269       UniversalGeneralString,
00270       UniversalUniversalString,
00271       UniversalBMPString = 30
00272     };
00273 
00274     unsigned GetTag() const  { return tag; }
00275     virtual void SetTag(unsigned newTag, TagClass tagClass = DefaultTagClass);
00276 
00277     enum ConstraintType {
00278       Unconstrained,
00279       PartiallyConstrained,
00280       FixedConstraint,
00281       ExtendableConstraint
00282     };
00283 
00284     enum MinimumValueTag { MinimumValue = INT_MIN };
00285     enum MaximumValueTag { MaximumValue = INT_MAX };
00286     void SetConstraints(ConstraintType type, int value)
00287       { SetConstraintBounds(type, value, value); }
00288     void SetConstraints(ConstraintType, int lower, MaximumValueTag /*upper*/)
00289       { SetConstraintBounds(PartiallyConstrained, (int)lower, lower < 0 ? INT_MAX : UINT_MAX); }
00290     void SetConstraints(ConstraintType, MinimumValueTag lower, unsigned upper)
00291       { SetConstraintBounds(PartiallyConstrained, (int)lower, (unsigned)upper); }
00292     void SetConstraints(ConstraintType, MinimumValueTag lower, MaximumValueTag upper)
00293       { SetConstraintBounds(PartiallyConstrained, (int)lower, (unsigned)upper); }
00294     void SetConstraints(ConstraintType type, int lower, unsigned upper)
00295       { SetConstraintBounds(type, lower, upper); }
00296 
00297     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
00298     virtual void SetCharacterSet(ConstraintType ctype, const char * charSet);
00299     virtual void SetCharacterSet(ConstraintType ctype, unsigned firstChar, unsigned lastChar);
00300 
00301     static PINDEX GetMaximumArraySize();
00302     static void SetMaximumArraySize(PINDEX sz);
00303     static PINDEX GetMaximumStringSize();
00304     static void SetMaximumStringSize(PINDEX sz);
00305 
00306   protected:
00307     PASN_Object(unsigned tag, TagClass tagClass, BOOL extend = FALSE);
00308 
00310     BOOL extendable;
00312     TagClass tagClass;
00314     unsigned tag;
00315 };
00316 
00317 
00320 class PASN_ConstrainedObject : public PASN_Object
00321 {
00322     PCLASSINFO(PASN_ConstrainedObject, PASN_Object);
00323   public:
00324     BOOL IsConstrained() const { return constraint != Unconstrained; }
00325     int GetLowerLimit() const { return lowerLimit; }
00326     unsigned GetUpperLimit() const { return upperLimit; }
00327 
00328     BOOL ConstrainedLengthDecode(PPER_Stream & strm, unsigned & length);
00329     void ConstrainedLengthEncode(PPER_Stream & strm, unsigned length) const;
00330 
00331     BOOL ConstraintEncode(PPER_Stream & strm, unsigned value) const;
00332 
00333   protected:
00334     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
00335     PASN_ConstrainedObject(unsigned tag, TagClass tagClass);
00336 
00337     ConstraintType constraint;
00338     int lowerLimit;
00339     unsigned upperLimit;
00340 };
00341 
00342 
00345 class PASN_Null : public PASN_Object
00346 {
00347     PCLASSINFO(PASN_Null, PASN_Object);
00348   public:
00349     PASN_Null(unsigned tag = UniversalNull,
00350               TagClass tagClass = UniversalTagClass);
00351 
00352     virtual Comparison Compare(const PObject & obj) const;
00353     virtual PObject * Clone() const;
00354     virtual void PrintOn(ostream & strm) const;
00355 
00356     virtual PString GetTypeAsString() const;
00357     virtual PINDEX GetDataLength() const;
00358     virtual BOOL Decode(PASN_Stream &);
00359     virtual void Encode(PASN_Stream &) const;
00360 };
00361 
00362 
00365 class PASN_Boolean : public PASN_Object
00366 {
00367     PCLASSINFO(PASN_Boolean, PASN_Object);
00368   public:
00369     PASN_Boolean(BOOL val = FALSE);
00370     PASN_Boolean(unsigned tag, TagClass tagClass, BOOL val = FALSE);
00371 
00372     PASN_Boolean & operator=(BOOL v) { value = v; return *this; }
00373     operator BOOL() const { return value; }
00374     BOOL GetValue() const { return value; }
00375     void SetValue(BOOL v) { value = v; }
00376 
00377     virtual Comparison Compare(const PObject & obj) const;
00378     virtual PObject * Clone() const;
00379     virtual void PrintOn(ostream & strm) const;
00380 
00381     virtual PString GetTypeAsString() const;
00382     virtual PINDEX GetDataLength() const;
00383     virtual BOOL Decode(PASN_Stream &);
00384     virtual void Encode(PASN_Stream &) const;
00385 
00386   protected:
00387     BOOL value;
00388 };
00389 
00390 
00393 class PASN_Integer : public PASN_ConstrainedObject
00394 {
00395     PCLASSINFO(PASN_Integer, PASN_ConstrainedObject);
00396   public:
00397     PASN_Integer(unsigned val = 0);
00398     PASN_Integer(unsigned tag, TagClass tagClass, unsigned val = 0);
00399 
00400     PASN_Integer & operator=(unsigned value);
00401     operator unsigned() const { return value; }
00402     unsigned GetValue() const { return value; }
00403     void SetValue(unsigned v) { operator=(v); }
00404 
00405     virtual Comparison Compare(const PObject & obj) const;
00406     virtual PObject * Clone() const;
00407     virtual void PrintOn(ostream & strm) const;
00408 
00409     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
00410     virtual PString GetTypeAsString() const;
00411     virtual PINDEX GetDataLength() const;
00412     virtual BOOL Decode(PASN_Stream &);
00413     virtual void Encode(PASN_Stream &) const;
00414 
00415 #ifdef P_INCLUDE_PER
00416     BOOL DecodePER(PPER_Stream & strm);
00417     void EncodePER(PPER_Stream & strm) const;
00418 #endif
00419 
00420     BOOL IsUnsigned() const;
00421 
00422   protected:
00423     unsigned value;
00424 };
00425 
00426 struct PASN_Names{
00427     const char * name;
00428     PINDEX value; 
00429 };
00430 
00433 class PASN_Enumeration : public PASN_Object
00434 {
00435     PCLASSINFO(PASN_Enumeration, PASN_Object);
00436   public:
00437     PASN_Enumeration(unsigned val = 0);
00438     PASN_Enumeration(unsigned tag,
00439                      TagClass tagClass,
00440                      unsigned nEnums = P_MAX_INDEX,
00441                      BOOL extendable = FALSE,
00442                      unsigned val = 0);
00443     PASN_Enumeration(unsigned tag,
00444                      TagClass tagClass,
00445                      unsigned nEnums,
00446                      BOOL extendable,
00447                      const PASN_Names * nameSpec,
00448                      unsigned namesCnt,
00449                      unsigned val = 0);
00450 
00451     PASN_Enumeration & operator=(unsigned v) { value = v; return *this; }
00452     operator unsigned() const { return value; }
00453     unsigned GetValue() const { return value; }
00454     void SetValue(unsigned v) { value = v; }
00455 
00456     unsigned GetMaximum() const { return maxEnumValue; }
00457 
00458     virtual Comparison Compare(const PObject & obj) const;
00459     virtual PObject * Clone() const;
00460     virtual void PrintOn(ostream & strm) const;
00461 
00462     virtual PString GetTypeAsString() const;
00463     virtual PINDEX GetDataLength() const;
00464     virtual BOOL Decode(PASN_Stream &);
00465     virtual void Encode(PASN_Stream &) const;
00466 
00467 #ifdef P_INCLUDE_PER
00468     BOOL DecodePER(PPER_Stream & strm);
00469     void EncodePER(PPER_Stream & strm) const;
00470 #endif
00471 
00472 #ifdef P_INCLUDE_XER
00473     virtual BOOL DecodeXER(PXER_Stream & strm);
00474     virtual void EncodeXER(PXER_Stream & strm) const;
00475 #endif
00476 
00477     PINDEX GetValueByName(PString name) const;
00478   protected:
00479     unsigned maxEnumValue;
00480     unsigned value;
00481     const PASN_Names *names;
00482     unsigned namesCount;   
00483 };
00484 
00485 
00488 class PASN_Real : public PASN_Object
00489 {
00490     PCLASSINFO(PASN_Real, PASN_Object);
00491   public:
00492     PASN_Real(double val = 0);
00493     PASN_Real(unsigned tag, TagClass tagClass, double val = 0);
00494 
00495     PASN_Real & operator=(double val) { value = val; return *this; }
00496     operator double() const { return value; }
00497     double GetValue() const { return value; }
00498     void SetValue(double v) { value = v; }
00499 
00500     virtual Comparison Compare(const PObject & obj) const;
00501     virtual PObject * Clone() const;
00502     virtual void PrintOn(ostream & strm) const;
00503 
00504     virtual PString GetTypeAsString() const;
00505     virtual PINDEX GetDataLength() const;
00506     virtual BOOL Decode(PASN_Stream &);
00507     virtual void Encode(PASN_Stream &) const;
00508 
00509   protected:
00510     double value;
00511 };
00512 
00513 
00516 class PASN_ObjectId : public PASN_Object
00517 {
00518     PCLASSINFO(PASN_ObjectId, PASN_Object);
00519   public:
00520     PASN_ObjectId(const char * dotstr = NULL);
00521     PASN_ObjectId(unsigned tag, TagClass tagClass);
00522 
00523     PASN_ObjectId(const PASN_ObjectId & other);
00524     PASN_ObjectId & operator=(const PASN_ObjectId & other);
00525 
00526     PASN_ObjectId & operator=(const char * dotstr);
00527     PASN_ObjectId & operator=(const PString & dotstr);
00528     PASN_ObjectId & operator=(const PUnsignedArray & numbers);
00529     void SetValue(const PString & dotstr);
00530     void SetValue(const PUnsignedArray & numbers) { value = numbers; }
00531     void SetValue(const unsigned * numbers, PINDEX size);
00532 
00533     bool operator==(const char * dotstr) const;
00534     bool operator!=(const char * dotstr) const      { return !operator==(dotstr); }
00535     bool operator==(const PString & dotstr) const   { return  operator==((const char *)dotstr); }
00536     bool operator!=(const PString & dotstr) const   { return !operator==((const char *)dotstr); }
00537     bool operator==(const PASN_ObjectId & id) const { return value == id.value; }
00538 
00539     PINDEX GetSize() const { return value.GetSize(); }
00540     unsigned operator[](PINDEX idx) const { return value[idx]; }
00541     const PUnsignedArray & GetValue() const { return value; }
00542     PString AsString() const;
00543 
00544     virtual Comparison Compare(const PObject & obj) const;
00545     virtual PObject * Clone() const;
00546     virtual void PrintOn(ostream & strm) const;
00547 
00548     virtual PString GetTypeAsString() const;
00549     virtual PINDEX GetDataLength() const;
00550     virtual BOOL Decode(PASN_Stream &);
00551     virtual void Encode(PASN_Stream &) const;
00552 
00553     BOOL CommonDecode(PASN_Stream & strm, unsigned dataLen);
00554     void CommonEncode(PBYTEArray & eObjId) const;
00555 
00556   protected:
00557     PUnsignedArray value;
00558 };
00559 
00560 
00563 class PASN_BitString : public PASN_ConstrainedObject
00564 {
00565     PCLASSINFO(PASN_BitString, PASN_ConstrainedObject);
00566   public:
00567     PASN_BitString(unsigned nBits = 0, const BYTE * buf = NULL);
00568     PASN_BitString(unsigned tag, TagClass tagClass, unsigned nBits = 0);
00569 
00570     PASN_BitString(const PASN_BitString & other);
00571     PASN_BitString & operator=(const PASN_BitString & other);
00572 
00573     void SetData(unsigned nBits, const PBYTEArray & bytes);
00574     void SetData(unsigned nBits, const BYTE * buf, PINDEX size = 0);
00575 
00576     const BYTE * GetDataPointer() const { return bitData; }
00577 
00578     unsigned GetSize() const { return totalBits; }
00579     BOOL SetSize(unsigned nBits);
00580 
00581     bool operator[](PINDEX bit) const;
00582     void Set(unsigned bit);
00583     void Clear(unsigned bit);
00584     void Invert(unsigned bit);
00585 
00586     virtual Comparison Compare(const PObject & obj) const;
00587     virtual PObject * Clone() const;
00588     virtual void PrintOn(ostream & strm) const;
00589 
00590     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
00591     virtual PString GetTypeAsString() const;
00592     virtual PINDEX GetDataLength() const;
00593     virtual BOOL Decode(PASN_Stream &);
00594     virtual void Encode(PASN_Stream &) const;
00595 
00596 #ifdef P_INCLUDE_BER
00597     BOOL DecodeBER(PBER_Stream & strm, unsigned len);
00598     void EncodeBER(PBER_Stream & strm) const;
00599 #endif
00600 
00601 #ifdef P_INCLUDE_PER
00602     BOOL DecodePER(PPER_Stream & strm);
00603     void EncodePER(PPER_Stream & strm) const;
00604 #endif
00605 
00606     BOOL DecodeSequenceExtensionBitmap(PPER_Stream & strm);
00607     void EncodeSequenceExtensionBitmap(PPER_Stream & strm) const;
00608 
00609   protected:
00610     unsigned totalBits;
00611     PBYTEArray bitData;
00612 };
00613 
00614 
00617 class PASN_OctetString : public PASN_ConstrainedObject
00618 {
00619     PCLASSINFO(PASN_OctetString, PASN_ConstrainedObject);
00620   public:
00621     PASN_OctetString(const char * str = NULL, PINDEX size = 0);
00622     PASN_OctetString(unsigned tag, TagClass tagClass);
00623 
00624     PASN_OctetString(const PASN_OctetString & other);
00625     PASN_OctetString & operator=(const PASN_OctetString & other);
00626 
00627     PASN_OctetString & operator=(const char * str);
00628     PASN_OctetString & operator=(const PString & str);
00629     PASN_OctetString & operator=(const PBYTEArray & arr);
00630     void SetValue(const char * str) { operator=(str); }
00631     void SetValue(const PString & str) { operator=(str); }
00632     void SetValue(const PBYTEArray & arr) { operator=(arr); }
00633     void SetValue(const BYTE * data, PINDEX len);
00634     const PBYTEArray & GetValue() const { return value; }
00635     operator const PBYTEArray &() const { return value; }
00636     operator const BYTE *() const { return value; }
00637     PString AsString() const;
00638     BYTE operator[](PINDEX i) const { return value[i]; }
00639     BYTE & operator[](PINDEX i) { return value[i]; }
00640     BYTE * GetPointer(PINDEX sz = 0) { return value.GetPointer(sz); }
00641     PINDEX GetSize() const { return value.GetSize(); }
00642     BOOL SetSize(PINDEX newSize);
00643 
00644     virtual Comparison Compare(const PObject & obj) const;
00645     virtual PObject * Clone() const;
00646     virtual void PrintOn(ostream & strm) const;
00647 
00648     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
00649     virtual PString GetTypeAsString() const;
00650     virtual PINDEX GetDataLength() const;
00651     virtual BOOL Decode(PASN_Stream &);
00652     virtual void Encode(PASN_Stream &) const;
00653 
00654 #ifdef P_INCLUDE_PER
00655     BOOL DecodePER(PPER_Stream & strm);
00656     void EncodePER(PPER_Stream & strm) const;
00657 #endif
00658 
00659     BOOL DecodeSubType(PASN_Object &) const;
00660     void EncodeSubType(const PASN_Object &);
00661 
00662   protected:
00663     PBYTEArray value;
00664 };
00665 
00666 
00669 class PASN_ConstrainedString : public PASN_ConstrainedObject
00670 {
00671     PCLASSINFO(PASN_ConstrainedString, PASN_ConstrainedObject);
00672   public:
00673     PASN_ConstrainedString & operator=(const char * str);
00674     PASN_ConstrainedString & operator=(const PString & str) { return operator=((const char *)str); }
00675     operator const PString &() const { return value; }
00676     const PString & GetValue() const { return value; }
00677     void SetValue(const char * v) { operator=(v); }
00678     void SetValue(const PString & v) { operator=(v); }
00679     char operator[](PINDEX idx) const { return value[idx]; }
00680 
00681     void SetCharacterSet(ConstraintType ctype, const char * charSet);
00682     void SetCharacterSet(ConstraintType ctype, unsigned firstChar = 0, unsigned lastChar = 255);
00683     void SetCharacterSet(const char * charSet, PINDEX size, ConstraintType ctype);
00684 
00685     virtual Comparison Compare(const PObject & obj) const;
00686     virtual void PrintOn(ostream & strm) const;
00687 
00688     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
00689     virtual PINDEX GetDataLength() const;
00690     virtual BOOL Decode(PASN_Stream &);
00691     virtual void Encode(PASN_Stream &) const;
00692 
00693 #ifdef P_INCLUDE_BER
00694     BOOL DecodeBER(PBER_Stream & strm, unsigned len);
00695     void EncodeBER(PBER_Stream & strm) const;
00696 #endif
00697 
00698 #ifdef P_INCLUDE_PER
00699     BOOL DecodePER(PPER_Stream & strm);
00700     void EncodePER(PPER_Stream & strm) const;
00701 #endif
00702 
00703   protected:
00704     PASN_ConstrainedString(const char * canonicalSet, PINDEX setSize,
00705                            unsigned tag, TagClass tagClass);
00706 
00707     PString value;
00708     PCharArray characterSet;
00709     const char * canonicalSet;
00710     PINDEX canonicalSetSize;
00711     unsigned canonicalSetBits;
00712     unsigned charSetUnalignedBits;
00713     unsigned charSetAlignedBits;
00714 };
00715 
00716 
00717 #define DECLARE_STRING_CLASS(name) \
00718   class PASN_##name##String : public PASN_ConstrainedString { \
00719     PCLASSINFO(PASN_##name##String, PASN_ConstrainedString); \
00720     public: \
00721       PASN_##name##String(const char * str = NULL); \
00722       PASN_##name##String(unsigned tag, TagClass tagClass); \
00723       PASN_##name##String & operator=(const char * str); \
00724       PASN_##name##String & operator=(const PString & str); \
00725       virtual PObject * Clone() const; \
00726       virtual PString GetTypeAsString() const; \
00727   }
00728 
00729 DECLARE_STRING_CLASS(Numeric);
00730 DECLARE_STRING_CLASS(Printable);
00731 DECLARE_STRING_CLASS(Visible);
00732 DECLARE_STRING_CLASS(IA5);
00733 DECLARE_STRING_CLASS(General);
00734 
00735 
00738 class PASN_BMPString : public PASN_ConstrainedObject
00739 {
00740     PCLASSINFO(PASN_BMPString, PASN_ConstrainedObject);
00741   public:
00742     PASN_BMPString(const char * str = NULL);
00743     PASN_BMPString(const PWORDArray & wstr);
00744     PASN_BMPString(unsigned tag, TagClass tagClass);
00745 
00746     PASN_BMPString(const PASN_BMPString & other);
00747     PASN_BMPString & operator=(const PASN_BMPString & other);
00748 
00749     PASN_BMPString & operator=(const char * v) { return operator=(PString(v).AsUCS2()); }
00750     PASN_BMPString & operator=(const PString & v) { return operator=(v.AsUCS2()); }
00751     PASN_BMPString & operator=(const PWORDArray & v);
00752     operator PString() const { return GetValue(); }
00753     operator PWORDArray() const { return value; }
00754     PString GetValue() const { return value; }
00755     void GetValue(PWORDArray & v) const { v = value; }
00756     void SetValue(const char * v) { operator=(PString(v).AsUCS2()); }
00757     void SetValue(const PString & v) { operator=(v.AsUCS2()); }
00758     void SetValue(const PWORDArray & v) { operator=(v); }
00759     void SetValue(const PASN_BMPString & v) { operator=(v.value); }
00760 
00761     void SetCharacterSet(ConstraintType ctype, const char * charSet);
00762     void SetCharacterSet(ConstraintType ctype, const PWORDArray & charSet);
00763     void SetCharacterSet(ConstraintType ctype, unsigned firstChar, unsigned lastChar);
00764 
00765     virtual Comparison Compare(const PObject & obj) const;
00766     virtual PObject * Clone() const;
00767     virtual void PrintOn(ostream & strm) const;
00768 
00769     virtual PString GetTypeAsString() const;
00770     virtual PINDEX GetDataLength() const;
00771     virtual BOOL Decode(PASN_Stream &);
00772     virtual void Encode(PASN_Stream &) const;
00773 
00774 #ifdef P_INCLUDE_BER
00775     BOOL DecodeBER(PBER_Stream & strm, unsigned len);
00776     void EncodeBER(PBER_Stream & strm) const;
00777 #endif
00778 
00779 #ifdef P_INCLUDE_PER
00780     BOOL DecodePER(PPER_Stream & strm);
00781     void EncodePER(PPER_Stream & strm) const;
00782 #endif
00783 
00784   protected:
00785     void Construct();
00786     BOOL IsLegalCharacter(WORD ch);
00787 
00788     PWORDArray value;
00789     PWORDArray characterSet;
00790     WORD firstChar, lastChar;
00791     unsigned charSetUnalignedBits;
00792     unsigned charSetAlignedBits;
00793 };
00794 
00795 
00796 class PASN_GeneralisedTime : public PASN_VisibleString
00797 {
00798     PCLASSINFO(PASN_GeneralisedTime, PASN_VisibleString);
00799   public:
00800     PASN_GeneralisedTime()
00801       : PASN_VisibleString(UniversalGeneralisedTime, UniversalTagClass) { }
00802     PASN_GeneralisedTime(const PTime & time)
00803       : PASN_VisibleString(UniversalGeneralisedTime, UniversalTagClass) { SetValue(time); }
00804     PASN_GeneralisedTime(unsigned tag, TagClass tagClass)
00805       : PASN_VisibleString(tag, tagClass) { }
00806 
00807     PASN_GeneralisedTime & operator=(const PTime & time);
00808     void SetValue(const PTime & time) { operator=(time); }
00809     PTime GetValue() const;
00810 };
00811 
00812 
00813 class PASN_UniversalTime : public PASN_VisibleString
00814 {
00815     PCLASSINFO(PASN_UniversalTime, PASN_VisibleString);
00816   public:
00817     PASN_UniversalTime()
00818       : PASN_VisibleString(UniversalUTCTime, UniversalTagClass) { }
00819     PASN_UniversalTime(const PTime & time)
00820       : PASN_VisibleString(UniversalUTCTime, UniversalTagClass) { SetValue(time); }
00821     PASN_UniversalTime(unsigned tag, TagClass tagClass)
00822       : PASN_VisibleString(tag, tagClass) { }
00823 
00824     PASN_UniversalTime & operator=(const PTime & time);
00825     void SetValue(const PTime & time) { operator=(time); }
00826     PTime GetValue() const;
00827 };
00828 
00829 
00830 class PASN_Sequence;
00831 
00834 class PASN_Choice : public PASN_Object
00835 {
00836     PCLASSINFO(PASN_Choice, PASN_Object);
00837   public:
00838     ~PASN_Choice();
00839 
00840     virtual void SetTag(unsigned newTag, TagClass tagClass = DefaultTagClass);
00841     PString GetTagName() const;
00842     PASN_Object & GetObject() const;
00843     BOOL IsValid() const { return choice != NULL; }
00844 
00845 #if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9
00846 
00847     operator PASN_Null &() const;
00848     operator PASN_Boolean &() const;
00849     operator PASN_Integer &() const;
00850     operator PASN_Enumeration &() const;
00851     operator PASN_Real &() const;
00852     operator PASN_ObjectId &() const;
00853     operator PASN_BitString &() const;
00854     operator PASN_OctetString &() const;
00855     operator PASN_NumericString &() const;
00856     operator PASN_PrintableString &() const;
00857     operator PASN_VisibleString &() const;
00858     operator PASN_IA5String &() const;
00859     operator PASN_GeneralString &() const;
00860     operator PASN_BMPString &() const;
00861     operator PASN_Sequence &() const;
00862 
00863 #else
00864 
00865     operator PASN_Null &();
00866     operator PASN_Boolean &();
00867     operator PASN_Integer &();
00868     operator PASN_Enumeration &();
00869     operator PASN_Real &();
00870     operator PASN_ObjectId &();
00871     operator PASN_BitString &();
00872     operator PASN_OctetString &();
00873     operator PASN_NumericString &();
00874     operator PASN_PrintableString &();
00875     operator PASN_VisibleString &();
00876     operator PASN_IA5String &();
00877     operator PASN_GeneralString &();
00878     operator PASN_BMPString &();
00879     operator PASN_Sequence &();
00880 
00881     operator const PASN_Null &() const;
00882     operator const PASN_Boolean &() const;
00883     operator const PASN_Integer &() const;
00884     operator const PASN_Enumeration &() const;
00885     operator const PASN_Real &() const;
00886     operator const PASN_ObjectId &() const;
00887     operator const PASN_BitString &() const;
00888     operator const PASN_OctetString &() const;
00889     operator const PASN_NumericString &() const;
00890     operator const PASN_PrintableString &() const;
00891     operator const PASN_VisibleString &() const;
00892     operator const PASN_IA5String &() const;
00893     operator const PASN_GeneralString &() const;
00894     operator const PASN_BMPString &() const;
00895     operator const PASN_Sequence &() const;
00896 
00897 #endif
00898 
00899     virtual BOOL CreateObject() = 0;
00900 
00901     virtual Comparison Compare(const PObject & obj) const;
00902     virtual void PrintOn(ostream & strm) const;
00903 
00904     virtual PString GetTypeAsString() const;
00905     virtual PINDEX GetDataLength() const;
00906     virtual BOOL IsPrimitive() const;
00907     virtual BOOL Decode(PASN_Stream &);
00908     virtual void Encode(PASN_Stream &) const;
00909 
00910 #ifdef P_INCLUDE_PER
00911     virtual BOOL DecodePER(PPER_Stream &);
00912     virtual void EncodePER(PPER_Stream &) const;
00913 #endif
00914 
00915 #ifdef P_INCLUDE_XER
00916     BOOL DecodeXER(PXER_Stream &);
00917     void EncodeXER(PXER_Stream &) const;
00918 #endif
00919 
00920     PASN_Choice & operator=(const PASN_Choice & other);
00921 
00922     PINDEX GetValueByName(PString name) const;
00923   protected:
00924     PASN_Choice(unsigned nChoices = 0, BOOL extend = FALSE);
00925     PASN_Choice(unsigned tag, TagClass tagClass, unsigned nChoices, BOOL extend);
00926     PASN_Choice(unsigned tag, TagClass tagClass, unsigned nChoices, BOOL extend, const PASN_Names * nameSpec,unsigned namesCnt);
00927 
00928     PASN_Choice(const PASN_Choice & other);
00929 
00930     BOOL CheckCreate() const;
00931 
00932     unsigned numChoices;
00933     PASN_Object * choice;
00934     const PASN_Names *names;
00935     unsigned namesCount;
00936 };
00937 
00938 
00939 PARRAY(PASN_ObjectArray, PASN_Object);
00940 
00941 
00944 class PASN_Sequence : public PASN_Object
00945 {
00946     PCLASSINFO(PASN_Sequence, PASN_Object);
00947   public:
00948     PASN_Sequence(unsigned tag = UniversalSequence,
00949                   TagClass tagClass = UniversalTagClass,
00950                   unsigned nOpts = 0, BOOL extend = FALSE, unsigned nExtend = 0);
00951 
00952     PASN_Sequence(const PASN_Sequence & other);
00953     PASN_Sequence & operator=(const PASN_Sequence & other);
00954 
00955     PINDEX GetSize() const { return fields.GetSize(); }
00956     BOOL SetSize(PINDEX newSize);
00957     PASN_Object & operator[](PINDEX i) const { return fields[i]; }
00958 
00959     BOOL HasOptionalField(PINDEX opt) const;
00960     void IncludeOptionalField(PINDEX opt);
00961     void RemoveOptionalField(PINDEX opt);
00962 
00963     virtual Comparison Compare(const PObject & obj) const;
00964     virtual PObject * Clone() const;
00965     virtual void PrintOn(ostream & strm) const;
00966 
00967     virtual PString GetTypeAsString() const;
00968     virtual PINDEX GetDataLength() const;
00969     virtual BOOL IsPrimitive() const;
00970     virtual BOOL Decode(PASN_Stream &);
00971     virtual void Encode(PASN_Stream &) const;
00972 
00973     BOOL PreambleDecode(PASN_Stream & strm);
00974     void PreambleEncode(PASN_Stream & strm) const;
00975     BOOL KnownExtensionDecode(PASN_Stream & strm, PINDEX fld, PASN_Object & field);
00976     void KnownExtensionEncode(PASN_Stream & strm, PINDEX fld, const PASN_Object & field) const;
00977     BOOL UnknownExtensionsDecode(PASN_Stream & strm);
00978     void UnknownExtensionsEncode(PASN_Stream & strm) const;
00979 
00980 #ifdef P_INCLUDE_BER
00981     BOOL PreambleDecodeBER(PBER_Stream & strm);
00982     void PreambleEncodeBER(PBER_Stream & strm) const;
00983     BOOL KnownExtensionDecodeBER(PBER_Stream & strm, PINDEX fld, PASN_Object & field);
00984     void KnownExtensionEncodeBER(PBER_Stream & strm, PINDEX fld, const PASN_Object & field) const;
00985     BOOL UnknownExtensionsDecodeBER(PBER_Stream & strm);
00986     void UnknownExtensionsEncodeBER(PBER_Stream & strm) const;
00987 #endif
00988 
00989 #ifdef P_INCLUDE_PER
00990     BOOL PreambleDecodePER(PPER_Stream & strm);
00991     void PreambleEncodePER(PPER_Stream & strm) const;
00992     BOOL KnownExtensionDecodePER(PPER_Stream & strm, PINDEX fld, PASN_Object & field);
00993     void KnownExtensionEncodePER(PPER_Stream & strm, PINDEX fld, const PASN_Object & field) const;
00994     BOOL UnknownExtensionsDecodePER(PPER_Stream & strm);
00995     void UnknownExtensionsEncodePER(PPER_Stream & strm) const;
00996 #endif
00997 
00998 #ifdef P_INCLUDE_XER
00999     virtual BOOL PreambleDecodeXER(PXER_Stream & strm);
01000     virtual void PreambleEncodeXER(PXER_Stream & strm) const;
01001     virtual BOOL KnownExtensionDecodeXER(PXER_Stream & strm, PINDEX fld, PASN_Object & field);
01002     virtual void KnownExtensionEncodeXER(PXER_Stream & strm, PINDEX fld, const PASN_Object & field) const;
01003     virtual BOOL UnknownExtensionsDecodeXER(PXER_Stream & strm);
01004     virtual void UnknownExtensionsEncodeXER(PXER_Stream & strm) const;
01005 #endif
01006 
01007   protected:
01008     BOOL NoExtensionsToDecode(PPER_Stream & strm);
01009     BOOL NoExtensionsToEncode(PPER_Stream & strm);
01010 
01011     PASN_ObjectArray fields;
01012     PASN_BitString optionMap;
01013     int knownExtensions;
01014     int totalExtensions;
01015     PASN_BitString extensionMap;
01016     PINDEX endBasicEncoding;
01017 };
01018 
01019 
01022 class PASN_Set : public PASN_Sequence
01023 {
01024     PCLASSINFO(PASN_Set, PASN_Sequence);
01025   public:
01026     PASN_Set(unsigned tag = UniversalSet,
01027              TagClass tagClass = UniversalTagClass,
01028              unsigned nOpts = 0, BOOL extend = FALSE, unsigned nExtend = 0);
01029 
01030     virtual PObject * Clone() const;
01031     virtual PString GetTypeAsString() const;
01032 };
01033 
01034 
01037 class PASN_Array : public PASN_ConstrainedObject
01038 {
01039     PCLASSINFO(PASN_Array, PASN_ConstrainedObject);
01040   public:
01041     PINDEX GetSize() const { return array.GetSize(); }
01042     BOOL SetSize(PINDEX newSize);
01043     PASN_Object & operator[](PINDEX i) const { return array[i]; }
01044     void Append(PASN_Object * obj) { array.SetAt(array.GetSize(), obj); }
01045     void RemoveAt(PINDEX i) { array.RemoveAt(i); }
01046     void RemoveAll() { array.RemoveAll(); }
01047 
01048     virtual Comparison Compare(const PObject & obj) const;
01049     virtual void PrintOn(ostream & strm) const;
01050 
01051     virtual void SetConstraintBounds(ConstraintType type, int lower, unsigned upper);
01052     virtual PString GetTypeAsString() const;
01053     virtual PINDEX GetDataLength() const;
01054     virtual BOOL IsPrimitive() const;
01055     virtual BOOL Decode(PASN_Stream &);
01056     virtual void Encode(PASN_Stream &) const;
01057 
01058     virtual PASN_Object * CreateObject() const = 0;
01059 
01060     PASN_Array & operator=(const PASN_Array & other);
01061 
01062   protected:
01063     PASN_Array(unsigned tag = UniversalSequence,
01064                TagClass tagClass = UniversalTagClass);
01065 
01066     PASN_Array(const PASN_Array & other);
01067 
01068     PASN_ObjectArray array;
01069 };
01070 
01071 
01073 
01076 class PASN_Stream : public PBYTEArray
01077 {
01078     PCLASSINFO(PASN_Stream, PBYTEArray);
01079   public:
01080     PASN_Stream();
01081     PASN_Stream(const PBYTEArray & bytes);
01082     PASN_Stream(const BYTE * buf, PINDEX size);
01083 
01084     void PrintOn(ostream & strm) const;
01085 
01086     PINDEX GetPosition() const { return byteOffset; }
01087     void SetPosition(PINDEX newPos);
01088     BOOL IsAtEnd() { return byteOffset >= GetSize(); }
01089     void ResetDecoder();
01090     void BeginEncoding();
01091     void CompleteEncoding();
01092 
01093     virtual BOOL Read(PChannel & chan) = 0;
01094     virtual BOOL Write(PChannel & chan) = 0;
01095 
01096     virtual BOOL NullDecode(PASN_Null &) = 0;
01097     virtual void NullEncode(const PASN_Null &) = 0;
01098     virtual BOOL BooleanDecode(PASN_Boolean &) = 0;
01099     virtual void BooleanEncode(const PASN_Boolean &) = 0;
01100     virtual BOOL IntegerDecode(PASN_Integer &) = 0;
01101     virtual void IntegerEncode(const PASN_Integer &) = 0;
01102     virtual BOOL EnumerationDecode(PASN_Enumeration &) = 0;
01103     virtual void EnumerationEncode(const PASN_Enumeration &) = 0;
01104     virtual BOOL RealDecode(PASN_Real &) = 0;
01105     virtual void RealEncode(const PASN_Real &) = 0;
01106     virtual BOOL ObjectIdDecode(PASN_ObjectId &) = 0;
01107     virtual void ObjectIdEncode(const PASN_ObjectId &) = 0;
01108     virtual BOOL BitStringDecode(PASN_BitString &) = 0;
01109     virtual void BitStringEncode(const PASN_BitString &) = 0;
01110     virtual BOOL OctetStringDecode(PASN_OctetString &) = 0;
01111     virtual void OctetStringEncode(const PASN_OctetString &) = 0;
01112     virtual BOOL ConstrainedStringDecode(PASN_ConstrainedString &) = 0;
01113     virtual void ConstrainedStringEncode(const PASN_ConstrainedString &) = 0;
01114     virtual BOOL BMPStringDecode(PASN_BMPString &) = 0;
01115     virtual void BMPStringEncode(const PASN_BMPString &) = 0;
01116     virtual BOOL ChoiceDecode(PASN_Choice &) = 0;
01117     virtual void ChoiceEncode(const PASN_Choice &) = 0;
01118     virtual BOOL ArrayDecode(PASN_Array &) = 0;
01119     virtual void ArrayEncode(const PASN_Array &) = 0;
01120     virtual BOOL SequencePreambleDecode(PASN_Sequence &) = 0;
01121     virtual void SequencePreambleEncode(const PASN_Sequence &) = 0;
01122     virtual BOOL SequenceKnownDecode(PASN_Sequence &, PINDEX, PASN_Object &) = 0;
01123     virtual void SequenceKnownEncode(const PASN_Sequence &, PINDEX, const PASN_Object &) = 0;
01124     virtual BOOL SequenceUnknownDecode(PASN_Sequence &) = 0;
01125     virtual void SequenceUnknownEncode(const PASN_Sequence &) = 0;
01126 
01127     BYTE ByteDecode();
01128     void ByteEncode(unsigned value);
01129 
01130     unsigned BlockDecode(BYTE * bufptr, unsigned nBytes);
01131     void BlockEncode(const BYTE * bufptr, PINDEX nBytes);
01132 
01133     void ByteAlign();
01134 
01135   protected:
01136     PINDEX byteOffset;
01137     unsigned bitOffset;
01138 
01139   private:
01140     void Construct();
01141 };
01142 
01143 #ifdef  P_INCLUDE_PER
01144 #include "asnper.h"
01145 #endif
01146 
01147 #ifdef  P_INCLUDE_BER
01148 #include "asnber.h"
01149 #endif
01150 
01151 #ifdef  P_INCLUDE_XER
01152 #include "asnxer.h"
01153 #endif
01154 
01155 #endif // _ASNER_H

Generated on Fri Mar 7 06:25:02 2008 for PTLib by  doxygen 1.5.1