file block reader More...
Typedefs | |
typedef typedefCGUL_BEGIN_C struct cgul_block_reader_file * | cgul_block_reader_file_t |
Implementation of the cgul_block_reader
interface for standard C FILE
objects.
typedef typedefCGUL_BEGIN_C struct cgul_block_reader_file* cgul_block_reader_file_t |
Opaque pointer to a cgul_block_reader_file
instance.
CGUL_EXPORT cgul_block_reader_t cgul_block_reader_file__as_block_reader | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile | ||
) |
Safely upcast brfile
to the cgul_block_reader
interface.
[in] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
Referenced by cgul_block_reader_file_cxx::as_block_reader().
CGUL_EXPORT cgul_block_reader_file_t cgul_block_reader_file__new | ( | cgul_exception_t * | cex | ) |
Create a new cgul_block_reader_file
instance. After this method returns, cgul_block_reader_file__open_fname()
or cgul_block_reader_file__open_file()
should be called before calling cgul_block_reader_file__read_next_block()
. The client is responsible for calling cgul_block_reader_file__delete()
on the object returned. If an error occurs, NULL
is returned, and an exception is thrown.
cgul_block_reader
(i.e., to the base type). [in,out] | cex | c-style exception |
cgul_block_reader_file
instance Referenced by cgul_block_reader_file_cxx::cgul_block_reader_file_cxx().
CGUL_EXPORT cgul_block_reader_file_t cgul_block_reader_file__new_from_fname | ( | cgul_exception_t * | cex, |
const char * | fname | ||
) |
This method creates a new cgul_block_reader_file
instance and calls cgul_block_reader_file__open_fname()
passing it fname
. The file will be closed when this instance is deleted. The client is responsible for calling cgul_block_reader_file__delete()
on the object returned. If an error occurs, NULL
is returned, and an exception is thrown.
[in,out] | cex | c-style exception |
[in] | fname | file name |
cgul_block_reader_file
instance Referenced by cgul_block_reader_file_cxx::cgul_block_reader_file_cxx().
CGUL_EXPORT cgul_block_reader_file_t cgul_block_reader_file__new_from_file | ( | cgul_exception_t * | cex, |
FILE * | f | ||
) |
This method creates a new cgul_block_reader_file
instance and calls cgul_block_reader_file__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 calling cgul_block_reader_file__delete()
on the object returned. If an error occurs, NULL
is returned, and an exception is thrown.
[in,out] | cex | c-style exception |
[in] | f | file |
cgul_block_reader_file
instance Referenced by cgul_block_reader_file_cxx::cgul_block_reader_file_cxx().
CGUL_EXPORT void cgul_block_reader_file__delete | ( | cgul_block_reader_file_t | brfile | ) |
This virtual method deletes the brfile
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 cgul_block_reader_file__new_from_file()
or cgul_block_reader_file__open_file()
. The client must not use brfile
after calling this method.
[in] | brfile | cgul_block_reader_file instance |
Referenced by cgul_block_reader_file_cxx::set_obj(), and cgul_block_reader_file_cxx::~cgul_block_reader_file_cxx().
CGUL_EXPORT void cgul_block_reader_file__open_fname | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile, | ||
const char * | fname | ||
) |
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,out] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
[in] | fname | file name |
Referenced by cgul_block_reader_file_cxx::open_fname().
CGUL_EXPORT void cgul_block_reader_file__open_file | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile, | ||
FILE * | f | ||
) |
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] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
[in] | f | file |
Referenced by cgul_block_reader_file_cxx::open_file().
CGUL_EXPORT void cgul_block_reader_file__close | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile | ||
) |
Close the file. After this method returns, cgul_block_reader_file__open_fname()
or cgul_block_reader_file__open_file()
should be called before calling any other method.
[in,out] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
Referenced by cgul_block_reader_file_cxx::close().
CGUL_EXPORT size_t cgul_block_reader_file__read_next_block | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile, | ||
void * | block, | ||
size_t | block_size | ||
) |
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,out] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
[in] | block | block |
[in] | block_size | block size in bytes |
Referenced by cgul_block_reader_file_cxx::read_next_block().
CGUL_EXPORT const char* cgul_block_reader_file__get_fname | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile | ||
) |
Return the name of underlying file. If cgul_block_reader_file__new_from_file()
or cgul_block_reader_file__open_file()
was used to initialize the object, NULL
is returned instead. This method throws an exception if no file is currently open.
[in,out] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
NULL
Referenced by cgul_block_reader_file_cxx::get_fname().
CGUL_EXPORT const char* cgul_block_reader_file__get_presentation_name | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile | ||
) |
Virtual method that returns the presentation name.
[in,out] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
Referenced by cgul_block_reader_file_cxx::get_presentation_name().
CGUL_EXPORT void cgul_block_reader_file__set_presentation_name | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile, | ||
const char * | presentation_name | ||
) |
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,out] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
[in] | presentation_name | presentation name |
Referenced by cgul_block_reader_file_cxx::set_presentation_name().
CGUL_EXPORT FILE* cgul_block_reader_file__get_file | ( | cgul_exception_t * | cex, |
cgul_block_reader_file_t | brfile | ||
) |
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.
[in] | cex | c-style exception |
[in] | brfile | cgul_block_reader_file instance |
Referenced by cgul_block_reader_file_cxx::get_file().