C++ bindings for cgul_block_reader_file
More...
#include <cgul_block_reader_file_cxx.h>
Public Member Functions | |
cgul_block_reader_file_cxx () | |
cgul_block_reader_file_cxx (const char *fname) | |
cgul_block_reader_file_cxx (FILE *f) | |
virtual | ~cgul_block_reader_file_cxx () |
virtual void | open_fname (const char *fname) |
virtual void | open_file (FILE *f) |
virtual void | close () |
virtual size_t | read_next_block (void *block, size_t block_size) |
virtual const char * | get_fname () const |
virtual const char * | get_presentation_name () const |
virtual void | set_presentation_name (const char *presentation_name) |
virtual FILE * | get_file () const |
virtual cgul_block_reader_t | as_block_reader () const |
virtual cgul_block_reader_file_t | get_obj () const |
virtual cgul_block_reader_file_t | take_obj () |
virtual void | set_obj (cgul_block_reader_file_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_file
objects. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_block_reader_file
into C++-style function calls and exception handling.
|
inline |
Create a new cgul_block_reader_file
instance. After this method returns, open_fname()
or open_file()
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_file__new().
Referenced by set_obj().
|
inline |
This method creates a new cgul_block_reader_file
instance and calls open_fname()
passing it fname
. The file will be closed when this instance is deleted. The client is responsible for deleting the object returned. If an error occurs, an exception is thrown.
[in] | fname | file name |
References cgul_block_reader_file__new_from_fname().
|
inline |
This method creates a new cgul_block_reader_file
instance and calls open_file()
passing it f
. The class does not take ownership of f
. Thus, the client is still responsible for calling fclose()
on it. The client is also responsible for deleting the object returned. If an error occurs, an exception is thrown.
[in] | f | file |
References cgul_block_reader_file__new_from_file().
|
inlinevirtual |
This virtual method deletes the instance freeing all internally allocated resources. This does not include closing the underlying file if it was obtained from the client by a call to open_file()
.
References cgul_block_reader_file__delete().
|
inlinevirtual |
Open the file with name fname
and use it when reading blocks of data. If a data source is already open, it will be closed before this method attempts to open the new data source. The new file will be closed when this instance is deleted. If an error occurs, an exception is thrown.
[in] | fname | file name |
References cgul_block_reader_file__open_fname().
|
inlinevirtual |
Use the file f
when reading blocks of data. If a data source is already open, it is closed before attempting to open the new data source. This class does not take ownership of f
. Thus, the client is still responsible for calling fclose()
on f
. If an error occurs, an exception is thrown.
[in] | f | file |
References cgul_block_reader_file__open_file().
|
inlinevirtual |
Close the file. After this method returns, open_fname()
or open_file()
should be called before calling any other method.
References cgul_block_reader_file__close().
|
inlinevirtual |
Virtual method used to read one block of data block
of size block_size
bytes from the underlying file. The user is responsible for making sure block
points to at least block_size
contiguous bytes of memory. 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_file__read_next_block().
|
inlinevirtual |
Return the name of underlying file. If open_file()
was used to initialize the object, NULL
is returned instead. This method throws an exception if no file is currently open.
NULL
References cgul_block_reader_file__get_fname().
|
inlinevirtual |
Virtual method that returns the presentation name.
Implements cgul_block_reader_cxx.
References cgul_block_reader_file__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, "FILE"
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_file__set_presentation_name().
|
inlinevirtual |
Return the currently opened file. The client must not do anything that would invalidate the pointer or corrupt the associated data stream. This method throws an exception if no file is currently open.
References cgul_block_reader_file__get_file().
|
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_file__as_block_reader().
|
inlinevirtual |
Get the underlying cgul_block_reader_file
object.
|
inlinevirtual |
Take the underlying cgul_block_reader_file
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_file__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_file__delete(), and cgul_block_reader_file_cxx().