ASN1C C/C++ Common Runtime  ASN1C v7.8.x
asn1CppEvtHndlr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1997-2022 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
24 
25 // rtsrc/asn1CppEvtHndlr.h - this .h file defines the object that is registered
26 // for the C++ version of the event handler feature.
27 
51 #ifndef _ASN1CPPEVTHNDLR_H_
52 #define _ASN1CPPEVTHNDLR_H_
53 
54 #include "rtsrc/asn1type.h"
55 
56 #ifndef OS_UNUSED_ARG
57 
63 #define OS_UNUSED_ARG(arg) (void)arg
64 #endif
65 
66 // The following pure abstract class defines the event handler interface
67 // callback functions that are invoked as a message is parsed..
75 class EXTRTCLASS Asn1NamedEventHandler {
76  public:
78  virtual ~Asn1NamedEventHandler() {}
79 
80  // Start element callback function. This is invoked upon entry into
81  // an element in a constructed type (SEQUENCE, SET, SEQUENCE OF,
82  // SET OF, or CHOICE). A single char* argument (name) is passed.
98  virtual void startElement (const char* name, int index) = 0;
99 
100  // End element callback function. This is invoked upon exit from
101  // a constructed type. A single char* argument (name) is passed.
118  virtual void endElement (const char* name, int index) = 0;
119 
120  // Data callback functions. These are invoked when data contents
121  // are parsed from a field. A separate callback is invoked for
122  // each of the ASN.1 primitive data types..
123 
131  virtual void boolValue (OSBOOL value) { OS_UNUSED_ARG(value); }
132 
140  virtual void intValue (OSINT32 value) { OS_UNUSED_ARG(value); }
141 
152  virtual void uIntValue (OSUINT32 value) { OS_UNUSED_ARG(value); }
153 
161  virtual void int64Value (OSINT64 value) {
162  intValue ((OSINT32)value);
163  }
164 
172  virtual void uInt64Value (OSUINT64 value) {
173  uIntValue ((OSUINT32)value);
174  }
175 
185  virtual void bitStrValue (OSUINT32 numbits, const OSOCTET* data) {
186  OS_UNUSED_ARG(numbits); OS_UNUSED_ARG(data);
187  }
188 
198  virtual void octStrValue (OSUINT32 numocts, const OSOCTET* data) {
199  OS_UNUSED_ARG(numocts); OS_UNUSED_ARG(data);
200  }
201 
209  virtual void charStrValue (const char* value) { OS_UNUSED_ARG(value); }
210 
219  virtual void charStrValue (OSUINT32 nchars, const OSUTF8CHAR* value) {
220  OS_UNUSED_ARG(nchars); OS_UNUSED_ARG(value);
221  }
222 
235  virtual void charStrValue (OSUINT32 nchars, OSUNICHAR* data) {
236  OS_UNUSED_ARG(nchars); OS_UNUSED_ARG(data);
237  }
238 
250  virtual void charStrValue (OSUINT32 nchars, OS32BITCHAR* data) {
251  OS_UNUSED_ARG(nchars); OS_UNUSED_ARG(data);
252  }
253 
261  virtual void nullValue () {}
262 
271  virtual void oidValue (OSUINT32 numSubIds, OSUINT32* pSubIds) {
272  OS_UNUSED_ARG(numSubIds); OS_UNUSED_ARG(pSubIds);
273  }
274 
282  virtual void realValue (double value) { OS_UNUSED_ARG(value); }
283 
292  virtual void enumValue (OSUINT32 value, const OSUTF8CHAR* text) {
293  OS_UNUSED_ARG(value); OS_UNUSED_ARG(text);
294  }
295 
305  virtual void openTypeValue (OSUINT32 numocts, const OSOCTET* data) {
306  OS_UNUSED_ARG(numocts); OS_UNUSED_ARG(data);
307  }
308 
309  // The following static function is called to add a new event handler
310  // to the context event handler list..
311 
319  EXTRTMETHOD static void addEventHandler
320  (OSCTXT* pCtxt, Asn1NamedEventHandler* pHandler);
321 
322  // The following static function is called to remove an event handler
323  // from the context event handler list. Note that it does not delete
324  // the event handler object.
325 
334  EXTRTMETHOD static void removeEventHandler
335  (OSCTXT* pCtxt, Asn1NamedEventHandler* pHandler);
336 
337  // The following static methods are invoked from within the generated
338  // code to call the various user-defined event handler methods ..
339 
349  EXTRTMETHOD static void invokeStartElement
350  (OSCTXT* pCtxt, const char* name, int index);
351 
361  EXTRTMETHOD static void invokeEndElement
362  (OSCTXT* pCtxt, const char* name, int index);
363 
371  EXTRTMETHOD static void invokeBoolValue (OSCTXT* pCtxt, OSBOOL value);
372 
380  EXTRTMETHOD static void invokeIntValue (OSCTXT* pCtxt, OSINT32 value);
381 
389  EXTRTMETHOD static void invokeUIntValue (OSCTXT* pCtxt, OSUINT32 value);
390 
398  EXTRTMETHOD static void invokeInt64Value (OSCTXT* pCtxt, OSINT64 value);
399 
407  EXTRTMETHOD static void invokeUInt64Value (OSCTXT* pCtxt, OSUINT64 value);
408 
417  EXTRTMETHOD static void invokeBitStrValue
418  (OSCTXT* pCtxt, OSUINT32 numbits, const OSOCTET* data);
419 
428  EXTRTMETHOD static void invokeOctStrValue
429  (OSCTXT* pCtxt, OSUINT32 numocts, const OSOCTET* data);
430 
438  EXTRTMETHOD static void invokeCharStrValue
439  (OSCTXT* pCtxt, const char* value);
440 
449  EXTRTMETHOD static void invokeCharStrValue
450  (OSCTXT* pCtxt, OSUINT32 nchars, OSUNICHAR* data);
451 
460  EXTRTMETHOD static void invokeCharStrValue
461  (OSCTXT* pCtxt, OSUINT32 nchars, OS32BITCHAR* data);
462 
471  EXTRTMETHOD static void invokeCharStrValue
472  (OSCTXT* pCtxt, OSUINT32 nchars, const OSUTF8CHAR* data);
473 
480  EXTRTMETHOD static void invokeNullValue (OSCTXT* pCtxt);
481 
490  EXTRTMETHOD static void invokeOidValue
491  (OSCTXT* pCtxt, OSUINT32 numSubIds, OSUINT32* pSubIds);
492 
500  EXTRTMETHOD static void invokeRealValue (OSCTXT* pCtxt, double value);
501 
510  EXTRTMETHOD static void invokeEnumValue
511  (OSCTXT* pCtxt, OSUINT32 value, const OSUTF8CHAR* text);
512 
521  EXTRTMETHOD static void invokeOpenTypeValue
522  (OSCTXT* pCtxt, OSUINT32 numocts, const OSOCTET* data);
523 
524 } ;
525 
526 // Null event handler class. This class contains an empty implementation
527 // of all user methods..
528 
533 class EXTRTCLASS Asn1NullEventHandler : public Asn1NamedEventHandler {
534  public:
536  virtual void startElement (const char* , int ) {}
538  virtual void endElement (const char* , int ) {}
539 } ;
540 
541 // The following pure abstract class defines the error handler interface
542 // callback functions that are invoked when a parsing error occurs..
543 
545 class EXTRTCLASS ASN1MessageBuffer ;
546 
555 class EXTRTCLASS Asn1ErrorHandler {
556  public:
557  Asn1ErrorHandler() {}
558  virtual ~Asn1ErrorHandler() {}
559 
571  virtual int error (OSCTXT* pCtxt, ASN1CCB* pCCB, int stat) = 0;
572 
573  // The following static method is called from within the generated
574  // code to call the virtual error callback method..
575 
576  EXTRTMETHOD static int invoke (OSCTXT* pCtxt, ASN1CCB* pCCB, int stat);
577 
578  // The following static method is called from within the generated
579  // code to call the virtual error callback method..
580 
581  EXTRTMETHOD static int invoke
582  (OSCTXT* pCtxt, OSOCTET* ptr, int len, int stat);
583 
594  EXTRTMETHOD static void setErrorHandler
595  (OSCTXT* pCtxt, Asn1ErrorHandler* pHandler);
596 
597 } ;
601 #endif
virtual void enumValue(OSUINT32 value, const OSUTF8CHAR *text)
Definition: asn1CppEvtHndlr.h:292
virtual void charStrValue(OSUINT32 nchars, OSUNICHAR *data)
Definition: asn1CppEvtHndlr.h:235
virtual void uIntValue(OSUINT32 value)
Definition: asn1CppEvtHndlr.h:152
virtual void octStrValue(OSUINT32 numocts, const OSOCTET *data)
Definition: asn1CppEvtHndlr.h:198
#define OS_UNUSED_ARG(arg)
Definition: asn1CppEvtHndlr.h:63
Definition: asn1CppTypes.h:103
virtual void openTypeValue(OSUINT32 numocts, const OSOCTET *data)
Definition: asn1CppEvtHndlr.h:305
virtual void oidValue(OSUINT32 numSubIds, OSUINT32 *pSubIds)
Definition: asn1CppEvtHndlr.h:271
Definition: asn1CppEvtHndlr.h:533
virtual void charStrValue(OSUINT32 nchars, const OSUTF8CHAR *value)
Definition: asn1CppEvtHndlr.h:219
virtual void bitStrValue(OSUINT32 numbits, const OSOCTET *data)
Definition: asn1CppEvtHndlr.h:185
virtual void uInt64Value(OSUINT64 value)
Definition: asn1CppEvtHndlr.h:172
virtual void endElement(const char *, int)
Definition: asn1CppEvtHndlr.h:538
virtual void startElement(const char *, int)
Definition: asn1CppEvtHndlr.h:536
virtual void int64Value(OSINT64 value)
Definition: asn1CppEvtHndlr.h:161
virtual void realValue(double value)
Definition: asn1CppEvtHndlr.h:282
virtual void intValue(OSINT32 value)
Definition: asn1CppEvtHndlr.h:140
virtual void nullValue()
Definition: asn1CppEvtHndlr.h:261
virtual void charStrValue(const char *value)
Definition: asn1CppEvtHndlr.h:209
virtual void charStrValue(OSUINT32 nchars, OS32BITCHAR *data)
Definition: asn1CppEvtHndlr.h:250
virtual void boolValue(OSBOOL value)
Definition: asn1CppEvtHndlr.h:131
Definition: asn1CppEvtHndlr.h:555
Definition: asn1CppEvtHndlr.h:75
Definition: rtxContext.h:198
Definition: asn1type.h:1502