ASN1C C/C++ Common Runtime  ASN1C v7.2.x
asn1CppEvtHndlr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1997-2018 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 
43 #ifndef _ASN1CPPEVTHNDLR_H_
44 #define _ASN1CPPEVTHNDLR_H_
45 
46 #include "rtsrc/asn1type.h"
47 
48 #ifndef OS_UNUSED_ARG
49 
55 #define OS_UNUSED_ARG(arg) (void)arg
56 #endif
57 
58 // The following pure abstract class defines the event handler interface
59 // callback functions that are invoked as a message is parsed..
67 class EXTRTCLASS Asn1NamedEventHandler {
68  public:
70  virtual ~Asn1NamedEventHandler() {}
71 
72  // Start element callback function. This is invoked upon entry into
73  // an element in a constructed type (SEQUENCE, SET, SEQUENCE OF,
74  // SET OF, or CHOICE). A single char* argument (name) is passed.
90  virtual void startElement (const char* name, int index) = 0;
91 
92  // End element callback function. This is invoked upon exit from
93  // a constructed type. A single char* argument (name) is passed.
110  virtual void endElement (const char* name, int index) = 0;
111 
112  // Data callback functions. These are invoked when data contents
113  // are parsed from a field. A separate callback is invoked for
114  // each of the ASN.1 primitive data types..
115 
123  virtual void boolValue (OSBOOL value) { OS_UNUSED_ARG(value); }
124 
132  virtual void intValue (OSINT32 value) { OS_UNUSED_ARG(value); }
133 
144  virtual void uIntValue (OSUINT32 value) { OS_UNUSED_ARG(value); }
145 
153  virtual void int64Value (OSINT64 value) {
154  intValue ((OSINT32)value);
155  }
156 
164  virtual void uInt64Value (OSUINT64 value) {
165  uIntValue ((OSUINT32)value);
166  }
167 
177  virtual void bitStrValue (OSUINT32 numbits, const OSOCTET* data) {
178  OS_UNUSED_ARG(numbits); OS_UNUSED_ARG(data);
179  }
180 
190  virtual void octStrValue (OSUINT32 numocts, const OSOCTET* data) {
191  OS_UNUSED_ARG(numocts); OS_UNUSED_ARG(data);
192  }
193 
201  virtual void charStrValue (const char* value) { OS_UNUSED_ARG(value); }
202 
211  virtual void charStrValue (OSUINT32 nchars, const OSUTF8CHAR* value) {
212  OS_UNUSED_ARG(nchars); OS_UNUSED_ARG(value);
213  }
214 
227  virtual void charStrValue (OSUINT32 nchars, OSUNICHAR* data) {
228  OS_UNUSED_ARG(nchars); OS_UNUSED_ARG(data);
229  }
230 
242  virtual void charStrValue (OSUINT32 nchars, OS32BITCHAR* data) {
243  OS_UNUSED_ARG(nchars); OS_UNUSED_ARG(data);
244  }
245 
253  virtual void nullValue () {}
254 
263  virtual void oidValue (OSUINT32 numSubIds, OSUINT32* pSubIds) {
264  OS_UNUSED_ARG(numSubIds); OS_UNUSED_ARG(pSubIds);
265  }
266 
274  virtual void realValue (double value) { OS_UNUSED_ARG(value); }
275 
284  virtual void enumValue (OSUINT32 value, const OSUTF8CHAR* text) {
285  OS_UNUSED_ARG(value); OS_UNUSED_ARG(text);
286  }
287 
297  virtual void openTypeValue (OSUINT32 numocts, const OSOCTET* data) {
298  OS_UNUSED_ARG(numocts); OS_UNUSED_ARG(data);
299  }
300 
301  // The following static function is called to add a new event handler
302  // to the context event handler list..
303 
311  EXTRTMETHOD static void addEventHandler
312  (OSCTXT* pCtxt, Asn1NamedEventHandler* pHandler);
313 
314  // The following static function is called to remove an event handler
315  // from the context event handler list. Note that it does not delete
316  // the event handler object.
317 
326  EXTRTMETHOD static void removeEventHandler
327  (OSCTXT* pCtxt, Asn1NamedEventHandler* pHandler);
328 
329  // The following static methods are invoked from within the generated
330  // code to call the various user-defined event handler methods ..
331 
341  EXTRTMETHOD static void invokeStartElement
342  (OSCTXT* pCtxt, const char* name, int index);
343 
353  EXTRTMETHOD static void invokeEndElement
354  (OSCTXT* pCtxt, const char* name, int index);
355 
363  EXTRTMETHOD static void invokeBoolValue (OSCTXT* pCtxt, OSBOOL value);
364 
372  EXTRTMETHOD static void invokeIntValue (OSCTXT* pCtxt, OSINT32 value);
373 
381  EXTRTMETHOD static void invokeUIntValue (OSCTXT* pCtxt, OSUINT32 value);
382 
390  EXTRTMETHOD static void invokeInt64Value (OSCTXT* pCtxt, OSINT64 value);
391 
399  EXTRTMETHOD static void invokeUInt64Value (OSCTXT* pCtxt, OSUINT64 value);
400 
409  EXTRTMETHOD static void invokeBitStrValue
410  (OSCTXT* pCtxt, OSUINT32 numbits, const OSOCTET* data);
411 
420  EXTRTMETHOD static void invokeOctStrValue
421  (OSCTXT* pCtxt, OSUINT32 numocts, const OSOCTET* data);
422 
430  EXTRTMETHOD static void invokeCharStrValue
431  (OSCTXT* pCtxt, const char* value);
432 
441  EXTRTMETHOD static void invokeCharStrValue
442  (OSCTXT* pCtxt, OSUINT32 nchars, OSUNICHAR* data);
443 
452  EXTRTMETHOD static void invokeCharStrValue
453  (OSCTXT* pCtxt, OSUINT32 nchars, OS32BITCHAR* data);
454 
463  EXTRTMETHOD static void invokeCharStrValue
464  (OSCTXT* pCtxt, OSUINT32 nchars, const OSUTF8CHAR* data);
465 
472  EXTRTMETHOD static void invokeNullValue (OSCTXT* pCtxt);
473 
482  EXTRTMETHOD static void invokeOidValue
483  (OSCTXT* pCtxt, OSUINT32 numSubIds, OSUINT32* pSubIds);
484 
492  EXTRTMETHOD static void invokeRealValue (OSCTXT* pCtxt, double value);
493 
502  EXTRTMETHOD static void invokeEnumValue
503  (OSCTXT* pCtxt, OSUINT32 value, const OSUTF8CHAR* text);
504 
513  EXTRTMETHOD static void invokeOpenTypeValue
514  (OSCTXT* pCtxt, OSUINT32 numocts, const OSOCTET* data);
515 
516 } ;
517 
518 // Null event handler class. This class contains an empty implementation
519 // of all user methods..
520 
525 class EXTRTCLASS Asn1NullEventHandler : public Asn1NamedEventHandler {
526  public:
528  virtual void startElement (const char* , int ) {}
530  virtual void endElement (const char* , int ) {}
531 } ;
532 
533 // The following pure abstract class defines the error handler interface
534 // callback functions that are invoked when a parsing error occurs..
535 
537 class EXTRTCLASS ASN1MessageBuffer ;
538 
547 class EXTRTCLASS Asn1ErrorHandler {
548  public:
549  Asn1ErrorHandler() {}
550  virtual ~Asn1ErrorHandler() {}
551 
563  virtual int error (OSCTXT* pCtxt, ASN1CCB* pCCB, int stat) = 0;
564 
565  // The following static method is called from within the generated
566  // code to call the virtual error callback method..
567 
568  EXTRTMETHOD static int invoke (OSCTXT* pCtxt, ASN1CCB* pCCB, int stat);
569 
570  // The following static method is called from within the generated
571  // code to call the virtual error callback method..
572 
573  EXTRTMETHOD static int invoke
574  (OSCTXT* pCtxt, OSOCTET* ptr, int len, int stat);
575 
586  EXTRTMETHOD static void setErrorHandler
587  (OSCTXT* pCtxt, Asn1ErrorHandler* pHandler);
588 
589 } ;
593 #endif
virtual void enumValue(OSUINT32 value, const OSUTF8CHAR *text)
Definition: asn1CppEvtHndlr.h:284
virtual void charStrValue(OSUINT32 nchars, OSUNICHAR *data)
Definition: asn1CppEvtHndlr.h:227
virtual void uIntValue(OSUINT32 value)
Definition: asn1CppEvtHndlr.h:144
virtual void octStrValue(OSUINT32 numocts, const OSOCTET *data)
Definition: asn1CppEvtHndlr.h:190
Definition: asn1CppTypes.h:102
virtual void openTypeValue(OSUINT32 numocts, const OSOCTET *data)
Definition: asn1CppEvtHndlr.h:297
virtual void oidValue(OSUINT32 numSubIds, OSUINT32 *pSubIds)
Definition: asn1CppEvtHndlr.h:263
Definition: asn1CppEvtHndlr.h:525
virtual void charStrValue(OSUINT32 nchars, const OSUTF8CHAR *value)
Definition: asn1CppEvtHndlr.h:211
virtual void bitStrValue(OSUINT32 numbits, const OSOCTET *data)
Definition: asn1CppEvtHndlr.h:177
virtual void uInt64Value(OSUINT64 value)
Definition: asn1CppEvtHndlr.h:164
virtual void endElement(const char *, int)
Definition: asn1CppEvtHndlr.h:530
virtual void startElement(const char *, int)
Definition: asn1CppEvtHndlr.h:528
virtual void int64Value(OSINT64 value)
Definition: asn1CppEvtHndlr.h:153
virtual void realValue(double value)
Definition: asn1CppEvtHndlr.h:274
virtual void intValue(OSINT32 value)
Definition: asn1CppEvtHndlr.h:132
#define OS_UNUSED_ARG(arg)
Definition: asn1CppEvtHndlr.h:55
virtual void nullValue()
Definition: asn1CppEvtHndlr.h:253
virtual void charStrValue(const char *value)
Definition: asn1CppEvtHndlr.h:201
virtual void charStrValue(OSUINT32 nchars, OS32BITCHAR *data)
Definition: asn1CppEvtHndlr.h:242
virtual void boolValue(OSBOOL value)
Definition: asn1CppEvtHndlr.h:123
Definition: asn1CppEvtHndlr.h:547
Definition: asn1CppEvtHndlr.h:67
Definition: rtxContext.h:185
Definition: asn1type.h:1136