ASN1C C/C++ Common Runtime  ASN1C v7.7.x
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

#include <asn1CppTypes.h>

Inheritance diagram for ASN1CType:
ASN1CBitStr ASN1CSeqOfList ASN1CTime ASN1CGeneralizedTime ASN1CUTCTime

Public Member Functions

EXTRTMETHOD ASN1CType (OSRTMessageBufferIF &msgBuf)
 
EXTRTMETHOD ASN1CType (const ASN1CType &orig)
 
virtual ~ASN1CType ()
 
void append (OSRTDList &llist, void *pdata)
 
OSRTCtxtPtr getContext ()
 
OSCTXTgetCtxtPtr ()
 
char * getErrorText (char *textbuf=(char *) 0, OSSIZE bufsize=0)
 
int getStatus () const
 
void * memAlloc (OSSIZE numocts)
 
void * memAllocZ (OSSIZE numocts)
 
void memFreeAll ()
 
void * memRealloc (void *ptr, OSSIZE numocts)
 
void memReset ()
 
void memFreePtr (void *ptr)
 
void printErrorInfo ()
 
void resetError ()
 
OSBOOL setDiag (OSBOOL value)
 
virtual EXTRTMETHOD int Encode ()
 
virtual EXTRTMETHOD int Decode (OSBOOL free=FALSE)
 
virtual int EncodeTo (OSRTMessageBufferIF &)
 
virtual int DecodeFrom (OSRTMessageBufferIF &, OSBOOL free=TRUE)
 
virtual void MemFree ()
 

Protected Member Functions

EXTRTMETHOD ASN1CType ()
 
EXTRTMETHOD ASN1CType (OSRTContext &ctxt)
 
EXTRTMETHOD int setMsgBuf (OSRTMessageBufferIF &msgBuf, OSBOOL initBuf=FALSE)
 
EXTRTMETHOD int setRunTimeKey (const OSOCTET *key, OSSIZE keylen)
 

Protected Attributes

OSRTCtxtPtr mpContext
 
OSRTMessageBufferIF * mpMsgBuf
 

Detailed Description

ASN1C control class base class. This is the main base class for all generated ASN1C_<name> control classes. It holds a variable of a generated data type as well as the associated message buffer or stream class to which a message will be encoded or from which a message will be decoded.

Constructor & Destructor Documentation

◆ ASN1CType() [1/4]

EXTRTMETHOD ASN1CType::ASN1CType ( )
protected

The default constructor sets the message pointer member variable to NULL and creates a new context object.

◆ ASN1CType() [2/4]

EXTRTMETHOD ASN1CType::ASN1CType ( OSRTContext ctxt)
protected

This constructor sets the message pointer member variable to NULL and initializes the context object to point at the given context value.

Parameters
ctxt- Reference to a context object.

◆ ASN1CType() [3/4]

EXTRTMETHOD ASN1CType::ASN1CType ( OSRTMessageBufferIF &  msgBuf)

This constructor sets the internal message buffer pointer to point at the given message buffer or stream object. The context is set to point at the context contained within the message buffer object. Thus, the message buffer and control class object share the context. It will not be released until both objects are destroyed.

Parameters
msgBuf- Reference to a message buffer or stream object.

◆ ASN1CType() [4/4]

EXTRTMETHOD ASN1CType::ASN1CType ( const ASN1CType orig)

The copy constructor sets the internal message buffer pointer and context to point at the message buffer and context from the original ASN1CType object.

Parameters
orig- Reference to a message buffer or stream object.

◆ ~ASN1CType()

virtual ASN1CType::~ASN1CType ( )
inlinevirtual

The virtual destructor does nothing. It is overridden by derived versions of this class.

Member Function Documentation

◆ append()

void ASN1CType::append ( OSRTDList llist,
void *  pdata 
)
inline

The append method can be used to append an element to any linked list structure contained within the generated type.

Parameters
llistLinked list structure.
pdataData record to be appended. Note that the pointer value is appended. The data is not copied.

References LOG_RTERR, RTERR_NOMEM, and rtxDListAppend().

◆ Decode()

virtual EXTRTMETHOD int ASN1CType::Decode ( OSBOOL  free = FALSE)
virtual

The Decode method decodes the ASN.1 message described by the encapsulated message buffer object by invoking DecodeFrom.

Parameters
freeIndicates whether memory for existing objects should be freed prior to decoding as part of object (re)initialization.
Returns
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

◆ DecodeFrom()

virtual int ASN1CType::DecodeFrom ( OSRTMessageBufferIF &  ,
OSBOOL  free = TRUE 
)
inlinevirtual

The DecodeFrom method decodes an ASN.1 message from the given message buffer or stream argument.

Parameters
msgBufMessage buffer or stream containing message to decode.
freeIndicates whether memory for existing objects should be freed prior to decoding as part of object (re)initialization.
Returns
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

References ASN_E_NOTPDU, and OS_UNUSED_ARG.

◆ Encode()

virtual EXTRTMETHOD int ASN1CType::Encode ( )
virtual

The Encode method encodes an ASN.1 message using the encoding rules specified by the derived message buffer object.

Returns
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

◆ EncodeTo()

virtual int ASN1CType::EncodeTo ( OSRTMessageBufferIF &  )
inlinevirtual

The EncodeTo method encodes an ASN.1 message into the given message buffer or stream argument.

Parameters
msgBufMessage buffer or stream to which the message is to be encoded.
Returns
Length of encoded message. A negative return value indicates an error.

References ASN_E_NOTPDU.

◆ getContext()

OSRTCtxtPtr ASN1CType::getContext ( )
inline

The getContext method returns the underlying context smart-pointer object.

Returns
Context smart pointer object.

◆ getCtxtPtr()

OSCTXT* ASN1CType::getCtxtPtr ( )
inline

The getCtxtPtr method returns the underlying C runtime context. This context can be used in calls to C runtime functions.

References OSRTContext::getPtr(), and OSRTCtxtPtr::isNull().

◆ getErrorText()

char* ASN1CType::getErrorText ( char *  textbuf = (char *) 0,
OSSIZE  bufsize = 0 
)

This method returns the error text associated with the last run-time error. If buffer pointer and buffer size are specified in parameters (not NULL) then error text will be copied in the passed buffer. Otherwise, this function allocates memory using the 'new' operator. It is the user's responsibility to free this memory using 'delete'.

Parameters
textbufA pointer to a destination buffer to hold the error text. If NULL, a dynamic buffer will be allocated.
bufsizeThe size of the output buffer size.
Returns
A pointer to a buffer with error text. If pBuf is not NULL, the return pointer will be equal to it. Otherwise, returns newly allocated buffer with error text. NULL, if error occurred.

◆ getStatus()

int ASN1CType::getStatus ( ) const
inline

This method returns the completion status of previous operation. It can be used to check completion status of constructors or methods, which do not return completion status. If error occurs, use printErrorInfo method to print out the error's description and stack trace. Method resetError can be used to reset error to continue operations after recovering from the error.

Returns
Runtime status code:
  • 0 (0) = success,
  • negative return value is error.

References OSRTContext::getStatus(), and OSRTCtxtPtr::isNull().

◆ memAlloc()

void* ASN1CType::memAlloc ( OSSIZE  numocts)
inline

The memAlloc method allocates memory using the C runtime memory management functions. The memory is tracked in the underlying context structure. When both this ASN1CType derived control class object and the message buffer object are destroyed, this memory will be freed.

Parameters
numoctsNumber of bytes of memory to allocate
Returns
Void pointer to allocated memory or NULL if insufficient memory was available to fulfill the request.

References OSRTCtxtPtr::isNull(), and OSRTContext::memAlloc().

◆ memAllocZ()

void* ASN1CType::memAllocZ ( OSSIZE  numocts)
inline

The memAllocZ method allocates memory using the C runtime memory management functions. The memory is tracked in the underlying context structure. When both this ASN1CType derived control class object and the message buffer object are destroyed, this memory will be freed. This memory will be zeroed out upon allocation.

Parameters
numoctsNumber of bytes of memory to allocate
Returns
Void pointer to allocated memory or NULL if insufficient memory was available to fulfill the request.

References OSRTCtxtPtr::isNull(), and OSRTContext::memAllocZ().

◆ MemFree()

virtual void ASN1CType::MemFree ( )
inlinevirtual

The MemFree method invokes the asn1Free* function on the message using this object's OSCTXT. The implementation here does nothing. Subclasses must override this method to invoke the correct asn1Free function when there is one (the function is only generated when required).

◆ memFreeAll()

void ASN1CType::memFreeAll ( )
inline

The memFreeAll method will free all memory currently tracked within the context. This includes all memory allocated with the memAlloc method as well as any memory allocated using the C rtxMemAlloc function with the context returned by the getCtxtPtr method.

References OSRTCtxtPtr::isNull(), and OSRTContext::memFreeAll().

◆ memFreePtr()

void ASN1CType::memFreePtr ( void *  ptr)
inline

The memFreePtr method frees the memory at a specific location. This memory must have been allocated using the memAlloc method described earlier.

Parameters
ptr- Pointer to a block of memory allocated with memAlloc

References OSRTCtxtPtr::isNull(), and OSRTContext::memFreePtr().

◆ memRealloc()

void* ASN1CType::memRealloc ( void *  ptr,
OSSIZE  numocts 
)
inline

The memRealloc method reallocates memory using the C runtime memory management functions.

Parameters
ptrOriginal pointer containing dynamic memory to be resized.
numoctsNumber of bytes of memory to allocate
Returns
Reallocated memory pointer

References OSRTCtxtPtr::isNull(), and OSRTContext::memRealloc().

◆ memReset()

void ASN1CType::memReset ( )
inline

The memReset method resets dynamic memory using the C runtime memory management functions.

References OSRTCtxtPtr::isNull(), and OSRTContext::memReset().

◆ printErrorInfo()

void ASN1CType::printErrorInfo ( )
inline

The PrintErrorInfo method prints information on errors contained within the context.

References OSRTCtxtPtr::isNull(), and OSRTContext::printErrorInfo().

◆ resetError()

void ASN1CType::resetError ( )
inline

This method resets error status and stack trace. This method should be used to continue operations after recovering from the error.

References OSRTCtxtPtr::isNull(), and OSRTContext::resetErrorInfo().

◆ setDiag()

OSBOOL ASN1CType::setDiag ( OSBOOL  value)
inline

This method turns diagnostic tracing on or off.

Parameters
valueBoolean value; TRUE = turn tracing on.
Returns
Previous state.

◆ setRunTimeKey()

EXTRTMETHOD int ASN1CType::setRunTimeKey ( const OSOCTET *  key,
OSSIZE  keylen 
)
protected

This method sets run-time key to the context. This method does nothing for unlimited redistribution libraries.

Parameters
key- array of octets with the key
keylen- number of octets in key array.
Returns
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

Member Data Documentation

◆ mpContext

OSRTCtxtPtr ASN1CType::mpContext
protected

The mpContext member variable holds a reference-counted C runtime variable. This context is used in calls to all C run-time functions. The context pointed at by this smart-pointer object is shared with the message buffer object contained within this class.

◆ mpMsgBuf

OSRTMessageBufferIF* ASN1CType::mpMsgBuf
protected

The mpMsgBuf member variable is a pointer to a derived message buffer or stream class that will manage the ASN.1 message being encoded or decoded.


The documentation for this class was generated from the following file: