cgul_block_reader_memory_cxx Class Reference

C++ bindings for cgul_block_reader_memory More...

#include <cgul_block_reader_memory_cxx.h>

Inheritance diagram for cgul_block_reader_memory_cxx:
Inheritance graph
Collaboration diagram for cgul_block_reader_memory_cxx:
Collaboration graph

Public Member Functions

 cgul_block_reader_memory_cxx ()
 
 cgul_block_reader_memory_cxx (void *buffer, size_t buffer_size)
 
virtual ~cgul_block_reader_memory_cxx ()
 
virtual void open (void *buffer, size_t buffer_size)
 
virtual void close ()
 
virtual size_t read_next_block (void *block, size_t block_size)
 
virtual const char * get_presentation_name () const
 
virtual void set_presentation_name (const char *presentation_name)
 
virtual void * get_buffer () const
 
virtual cgul_block_reader_t as_block_reader () const
 
virtual cgul_block_reader_memory_t get_obj () const
 
virtual cgul_block_reader_memory_t take_obj ()
 
virtual void set_obj (cgul_block_reader_memory_t rhs)
 
- Public Member Functions inherited from cgul_block_reader_cxx
virtual ~cgul_block_reader_cxx ()
 

Detailed Description

This class provides the C++ bindings for C cgul_block_reader_memory objects. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_block_reader_memory into C++-style function calls and exception handling.

Constructor & Destructor Documentation

§ cgul_block_reader_memory_cxx() [1/2]

cgul_block_reader_memory_cxx::cgul_block_reader_memory_cxx ( )
inline

Create a new cgul_block_reader_memory instance. After this method returns, open() should be called before calling read_next_block(). The client is responsible for deleting the object returned. If an error occurs, an exception is thrown.

References cgul_block_reader_memory__new().

Referenced by set_obj().

§ cgul_block_reader_memory_cxx() [2/2]

cgul_block_reader_memory_cxx::cgul_block_reader_memory_cxx ( void *  buffer,
size_t  buffer_size 
)
inline

This method creates a new instance and calls open() passing it buffer and buffer_size. This class does not take ownership of buffer so the client is still responsible for freeing buffer if necessary. The client is also responsible for deleting the object returned. If an error occurs, an exception is thrown.

Parameters
[in]buffermemory buffer
[in]buffer_sizesize of buffer in bytes

References cgul_block_reader_memory__new_from_memory().

§ ~cgul_block_reader_memory_cxx()

virtual cgul_block_reader_memory_cxx::~cgul_block_reader_memory_cxx ( )
inlinevirtual

This virtual method deletes the instance freeing all internally allocated resources.

References cgul_block_reader_memory__delete().

Member Function Documentation

§ open()

virtual void cgul_block_reader_memory_cxx::open ( void *  buffer,
size_t  buffer_size 
)
inlinevirtual

Set the input buffer buffer to use when reading blocks of data from memory. If a memory buffer is already open, it will be closed before this method attempts to open the new memory buffer. This class does not take ownership of buffer. Thus, the client is still responsible for freeing buffer if necessary. If an error occurs, an exception is thrown.

Parameters
[in]bufferinput memory buffer
[in]buffer_sizesize of buffer in bytes

References cgul_block_reader_memory__open().

§ close()

virtual void cgul_block_reader_memory_cxx::close ( )
inlinevirtual

Close the memory. After this method returns, open() should be called before calling any other method.

References cgul_block_reader_memory__close().

§ read_next_block()

virtual size_t cgul_block_reader_memory_cxx::read_next_block ( void *  block,
size_t  block_size 
)
inlinevirtual

Virtual method that reads one block of data block of size block_size bytes from the underlying buffer. The user is responsible for making sure block points to at least block_size contiguous bytes of memory. The user is also responsible for making sure block does not overlap with the open buffer from which blocks are read (as required by memcpy()). This method returns the number of bytes read or 0 if EOF is reached without error. If an error occurs, 0 is returned, and an exception is thrown.

Parameters
[in]blockblock
[in]block_sizeblock size in bytes
Returns
number of bytes read

Implements cgul_block_reader_cxx.

References cgul_block_reader_memory__read_next_block().

§ get_presentation_name()

virtual const char* cgul_block_reader_memory_cxx::get_presentation_name ( ) const
inlinevirtual

Virtual method that returns the presentation name.

Returns
presentation name

Implements cgul_block_reader_cxx.

References cgul_block_reader_memory__get_presentation_name().

§ set_presentation_name()

virtual void cgul_block_reader_memory_cxx::set_presentation_name ( const char *  presentation_name)
inlinevirtual

Virtual method that sets the presentation name. The presentation name is primarily used for error reporting and can be set to anything, but it does need to be set again if the input file changes. If the presentation name is not set, "MEMORY" is returned. An exception is thrown if an attempt is made to set the presentation name without first setting the input file.

Parameters
[in]presentation_namepresentation name

Implements cgul_block_reader_cxx.

References cgul_block_reader_memory__set_presentation_name().

§ get_buffer()

virtual void* cgul_block_reader_memory_cxx::get_buffer ( ) const
inlinevirtual

Return the currently opened buffer from which blocks are read. The client must not do anything that would invalidate the pointer or corrupt the associated data stream. This method throws an exception only if a file is not currently open.

Because the client is responsible for freeing the buffer if necessary, it can be convenient to call this method just before deleting the object in order to free the pointer returned.

Returns
currently opened file or memory

References cgul_block_reader_memory__get_buffer().

§ as_block_reader()

virtual cgul_block_reader_t cgul_block_reader_memory_cxx::as_block_reader ( ) const
inlinevirtual

Return the underlying cgul_block_reader object.

Note
get_obj() is similar to this method except it returns a pointer to the most derived class; whereas, this method returns the same pointer but cast to the base class.
Returns
underlying cgul_block_reader object

Implements cgul_block_reader_cxx.

References cgul_block_reader_memory__as_block_reader().

§ get_obj()

virtual cgul_block_reader_memory_t cgul_block_reader_memory_cxx::get_obj ( ) const
inlinevirtual

Get the underlying cgul_block_reader_memory object.

Returns
underlying object

§ take_obj()

virtual cgul_block_reader_memory_t cgul_block_reader_memory_cxx::take_obj ( )
inlinevirtual

Take the underlying cgul_block_reader_memory object. This means the underlying object will not be deleted when the wrapper goes out of scope. Also, because you have taken the underlying object, no other methods should be called on this wrapper's instance. Lastly, after taking the underlying object, it is the caller's responsibility to delete the underlying object by calling cgul_block_reader_memory__delete().

Returns
underlying object

§ set_obj()

virtual void cgul_block_reader_memory_cxx::set_obj ( cgul_block_reader_memory_t  rhs)
inlinevirtual

Set the new underlying object to rhs. This causes the old underlying object to be deleted which invalidates any outstanding pointers to or iterators for the old underlying object.

This instance takes ownership of rhs which means rhs will be automatically deleted when the C++ wrapper is deleted. To prevent automatic deletion of rhs, call take_obj() when the C++ wrapper is no longer needed.

Parameters
[in]rhsright-hand side

References cgul_block_reader_memory__delete(), and cgul_block_reader_memory_cxx().


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