C++ bindings for cgul_block_reader_memory
More...
#include <cgul_block_reader_memory_cxx.h>
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 () |
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.
|
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().
|
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.
[in] | buffer | memory buffer |
[in] | buffer_size | size of buffer in bytes |
References cgul_block_reader_memory__new_from_memory().
|
inlinevirtual |
This virtual method deletes the instance freeing all internally allocated resources.
References cgul_block_reader_memory__delete().
|
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.
[in] | buffer | input memory buffer |
[in] | buffer_size | size of buffer in bytes |
References cgul_block_reader_memory__open().
|
inlinevirtual |
Close the memory. After this method returns, open()
should be called before calling any other method.
References cgul_block_reader_memory__close().
|
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.
[in] | block | block |
[in] | block_size | block size in bytes |
Implements cgul_block_reader_cxx.
References cgul_block_reader_memory__read_next_block().
|
inlinevirtual |
Virtual method that returns the presentation name.
Implements cgul_block_reader_cxx.
References cgul_block_reader_memory__get_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.
[in] | presentation_name | presentation name |
Implements cgul_block_reader_cxx.
References cgul_block_reader_memory__set_presentation_name().
|
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.
References cgul_block_reader_memory__get_buffer().
|
inlinevirtual |
Return the underlying cgul_block_reader
object.
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. cgul_block_reader
object Implements cgul_block_reader_cxx.
References cgul_block_reader_memory__as_block_reader().
|
inlinevirtual |
Get the underlying cgul_block_reader_memory
object.
|
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()
.
|
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.
[in] | rhs | right-hand side |
References cgul_block_reader_memory__delete(), and cgul_block_reader_memory_cxx().