ASN1C C/C++ Common Runtime  ASN1C v7.7.x
Public Member Functions | List of all members
OSRTInputStream Class Reference

#include <OSRTInputStream.h>

Inheritance diagram for OSRTInputStream:
OSRTStream OSRTFileInputStream OSRTHexTextInputStream OSRTMemoryInputStream OSRTSocketInputStream

Public Member Functions

EXTRTMETHOD OSRTInputStream ()
 
EXTRTMETHOD OSRTInputStream (OSRTContext *mpContext, OSBOOL attachStream=FALSE)
 
virtual EXTRTMETHOD ~OSRTInputStream ()
 
virtual EXTRTMETHOD int close ()
 
virtual EXTRTMETHOD size_t currentPos ()
 
virtual EXTRTMETHOD int flush ()
 
virtual OSBOOL isA (StreamID id) const
 
virtual OSRTCtxtPtr getContext ()
 
virtual OSCTXTgetCtxtPtr ()
 
virtual char * getErrorInfo ()
 
virtual char * getErrorInfo (char *pBuf, size_t &bufSize)
 
virtual int getPosition (size_t *ppos)
 
virtual int getStatus () const
 
virtual EXTRTMETHOD OSBOOL isOpened ()
 
virtual EXTRTMETHOD OSBOOL markSupported ()
 
virtual EXTRTMETHOD int mark (size_t readAheadLimit)
 
void printErrorInfo ()
 
void resetErrorInfo ()
 
virtual EXTRTMETHOD long read (OSOCTET *pDestBuf, size_t maxToRead)
 
virtual EXTRTMETHOD long readBlocking (OSOCTET *pDestBuf, size_t toReadBytes)
 
virtual EXTRTMETHOD int reset ()
 
virtual int setPosition (size_t pos)
 
virtual EXTRTMETHOD int skip (size_t n)
 
- Public Member Functions inherited from OSRTStream
virtual EXTRTMETHOD ~OSRTStream ()
 
int getStatus () const
 
OSBOOL isInitialized ()
 
void printErrorInfo ()
 
void resetErrorInfo ()
 

Additional Inherited Members

- Protected Member Functions inherited from OSRTStream
EXTRTMETHOD OSRTStream (OSRTContext *pContext, OSBOOL attachStream=FALSE)
 
EXTRTMETHOD OSRTStream (OSRTStream &original)
 
EXTRTMETHOD OSRTStream ()
 
EXTRTMETHOD char * getErrorInfo (size_t *pBufSize)
 
- Protected Attributes inherited from OSRTStream
OSRTCtxtHolder mCtxtHolder
 
OSBOOL mbAttached
 
int mStatus
 
int mInitStatus
 

Detailed Description

This is the base class for input streams. These streams are buffered (I/O is stored in memory prior to being written) to provide higher performance.

Constructor & Destructor Documentation

◆ OSRTInputStream()

EXTRTMETHOD OSRTInputStream::OSRTInputStream ( )

The default constructor. It initializes a buffered stream. A buffered stream maintains data in memory before reading or writing to the device. This generally provides better performance than an unbuffered stream.

Exceptions
OSRTStreamExceptionStream create or initialize failed.

◆ ~OSRTInputStream()

virtual EXTRTMETHOD OSRTInputStream::~OSRTInputStream ( )
virtual

Virtual destructor. Closes the stream if it was opened.

Member Function Documentation

◆ close()

virtual EXTRTMETHOD int OSRTInputStream::close ( )
virtual

Closes the input or output stream and releases any system resources associated with the stream. For output streams this function also flushes all internal buffers to the stream.

Returns
Completion status of operation:
  • 0 = success,
  • negative return value is error.
See also
rtxStreamClose

Reimplemented from OSRTStream.

◆ currentPos()

virtual EXTRTMETHOD size_t OSRTInputStream::currentPos ( )
virtual

This method returns the current position in the stream (in octets).

Returns
The number of octets already read from the stream.

◆ flush()

virtual EXTRTMETHOD int OSRTInputStream::flush ( )
virtual

Flushes the buffered data to the stream.

Returns
Completion status of operation:
  • 0 = success,
  • negative return value is error.
See also
rtxStreamFlush

Reimplemented from OSRTStream.

◆ getContext()

virtual OSRTCtxtPtr OSRTInputStream::getContext ( )
inlinevirtual

This method returns a pointer to the underlying OSRTContext object.

Returns
A reference-counted pointer to an OSRTContext object. The OSRTContext object will not be released until all referenced-counted pointer variables go out of scope. This allows safe sharing of the context between different run-time classes.

Reimplemented from OSRTStream.

References OSRTStream::getContext().

◆ getCtxtPtr()

virtual OSCTXT* OSRTInputStream::getCtxtPtr ( )
inlinevirtual

This method returns a pointer to the underlying OSCTXT object. This is the structure used in calls to low-level C encode/decode functions.

Returns
Pointer to a context (OSCTXT) structure.

Reimplemented from OSRTStream.

References OSRTStream::getCtxtPtr().

◆ getErrorInfo() [1/2]

virtual char* OSRTInputStream::getErrorInfo ( )
inlinevirtual

Returns error text in a dynamic memory buffer. Buffer will be allocated by 'operator new []'. The calling routine is responsible to free the memory by using 'operator delete []'.

Returns
A pointer to a newly allocated buffer with error text.

Reimplemented from OSRTStream.

References OSRTStream::getErrorInfo().

◆ getErrorInfo() [2/2]

virtual char* OSRTInputStream::getErrorInfo ( char *  pBuf,
size_t &  bufSize 
)
inlinevirtual

Returns error text in a memory buffer. If buffer pointer is specified in parameters (not NULL) then error text will be copied in the passed buffer. Otherwise, this method allocates memory using the 'operator new []' function. The calling routine is responsible to free the memory by using 'operator delete []'.

Parameters
pBufA pointer to a destination buffer to obtain the error text. If NULL, dynamic buffer will be allocated.
bufSizeA reference to buffer size. If pBuf is NULL it will receive the size of allocated dynamic buffer.
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.

Reimplemented from OSRTStream.

References OSRTStream::getErrorInfo().

◆ getPosition()

virtual int OSRTInputStream::getPosition ( size_t *  ppos)
virtual

Returns the current stream position. This may be used with the setPosition method to reset back to an arbitrary point in the input stream.

Parameters
pposPointer to a variable to receive position.
Returns
Completion status of operation: 0 = success, negative return value is error.

◆ getStatus()

virtual int OSRTInputStream::getStatus ( ) const
inlinevirtual

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.

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

References OSRTStream::getStatus(), and OSRTStream::isOpened().

◆ isA()

virtual OSBOOL OSRTInputStream::isA ( StreamID  id) const
inlinevirtual

This method is used to query a stream object in order to determine its actual type.

Parameters
idEnumerated stream identifier
Returns
True if the stream matches the identifier

Reimplemented in OSRTSocketInputStream, OSRTFileInputStream, OSRTHexTextInputStream, and OSRTMemoryInputStream.

Referenced by OSRTHexTextInputStream::isA().

◆ isOpened()

virtual EXTRTMETHOD OSBOOL OSRTInputStream::isOpened ( )
virtual

Checks, is the stream opened or not.

Returns
s TRUE, if the stream is opened, FALSE otherwise.
See also
rtxStreamIsOpened

Reimplemented from OSRTStream.

◆ mark()

virtual EXTRTMETHOD int OSRTInputStream::mark ( size_t  readAheadLimit)
virtual

This method marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes. The readAheadLimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

Parameters
readAheadLimitthe maximum limit of bytes that can be read before the mark position becomes invalid.
Returns
Completion status of operation:
  • 0 = success,
  • negative return value is error.
See also
rtxStreamMark, rtxStreamReset

◆ markSupported()

virtual EXTRTMETHOD OSBOOL OSRTInputStream::markSupported ( )
virtual

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance. By default, it returns FALSE.

Returns
TRUE if this stream instance supports the mark and reset methods; FALSE otherwise.
See also
rtxStreamMarkSupported

◆ printErrorInfo()

void OSRTInputStream::printErrorInfo ( )
inline

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

References OSRTStream::printErrorInfo().

◆ read()

virtual EXTRTMETHOD long OSRTInputStream::read ( OSOCTET *  pDestBuf,
size_t  maxToRead 
)
virtual

Read data from the stream. This method reads up to maxToRead bytes from the stream. It may return a value less then this if the mamimum number of bytes is not available.

Parameters
pDestBufPointer to a buffer to receive a data.
maxToReadSize of the buffer.
See also
rtxStreamRead

◆ readBlocking()

virtual EXTRTMETHOD long OSRTInputStream::readBlocking ( OSOCTET *  pDestBuf,
size_t  toReadBytes 
)
virtual

Read data from the stream. This method reads up to maxToRead bytes from the stream. It may return a value less then this if the mamimum number of bytes is not available.

Parameters
pDestBufPointer to a buffer to receive a data.
toReadBytesNumber of bytes to be read.
See also
rtxStreamRead

◆ reset()

virtual EXTRTMETHOD int OSRTInputStream::reset ( )
virtual

Repositions this stream to the position at the time the mark method was last called on this input stream.

Returns
Completion status of operation:
  • 0 = success,
  • negative return value is error.
See also
rtxStreamMark, rtxStreamReset

◆ resetErrorInfo()

void OSRTInputStream::resetErrorInfo ( )
inline

The resetErrorInfo method resets information on errors contained within the context.

References OSRTStream::resetErrorInfo().

◆ setPosition()

virtual int OSRTInputStream::setPosition ( size_t  pos)
virtual

Sets the current stream position to the given offset.

Parameters
posPosition stream is to be reset to. This is normally obtained via a call to getPosition, although in most cases it is a zero-based offset.
Returns
Completion status of operation: 0 = success, negative return value is error.

◆ skip()

virtual EXTRTMETHOD int OSRTInputStream::skip ( size_t  n)
virtual

Skips over and discards the specified amount of data octets from this input stream.

Parameters
nThe number of octets to be skipped.
Returns
Completion status of operation:
  • 0 = success,
  • negative return value is error.
See also
rtxStreamSkip

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