cgul_block_reader_file_cxx Class Reference

C++ bindings for cgul_block_reader_file More...

#include <cgul_block_reader_file_cxx.h>

Inheritance diagram for cgul_block_reader_file_cxx:
Inheritance graph
Collaboration diagram for cgul_block_reader_file_cxx:
Collaboration graph

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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

§ cgul_block_reader_file_cxx() [1/3]

cgul_block_reader_file_cxx::cgul_block_reader_file_cxx ( )
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().

§ cgul_block_reader_file_cxx() [2/3]

cgul_block_reader_file_cxx::cgul_block_reader_file_cxx ( const char *  fname)
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.

Parameters
[in]fnamefile name

References cgul_block_reader_file__new_from_fname().

§ cgul_block_reader_file_cxx() [3/3]

cgul_block_reader_file_cxx::cgul_block_reader_file_cxx ( FILE *  f)
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.

Parameters
[in]ffile

References cgul_block_reader_file__new_from_file().

§ ~cgul_block_reader_file_cxx()

virtual cgul_block_reader_file_cxx::~cgul_block_reader_file_cxx ( )
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().

Member Function Documentation

§ open_fname()

virtual void cgul_block_reader_file_cxx::open_fname ( const char *  fname)
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.

Parameters
[in]fnamefile name

References cgul_block_reader_file__open_fname().

§ open_file()

virtual void cgul_block_reader_file_cxx::open_file ( FILE *  f)
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.

Parameters
[in]ffile

References cgul_block_reader_file__open_file().

§ close()

virtual void cgul_block_reader_file_cxx::close ( )
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().

§ read_next_block()

virtual size_t cgul_block_reader_file_cxx::read_next_block ( void *  block,
size_t  block_size 
)
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.

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

Implements cgul_block_reader_cxx.

References cgul_block_reader_file__read_next_block().

§ get_fname()

virtual const char* cgul_block_reader_file_cxx::get_fname ( ) const
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.

Returns
name of underlying file or NULL

References cgul_block_reader_file__get_fname().

§ get_presentation_name()

virtual const char* cgul_block_reader_file_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_file__get_presentation_name().

§ set_presentation_name()

virtual void cgul_block_reader_file_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, "FILE" 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_file__set_presentation_name().

§ get_file()

virtual FILE* cgul_block_reader_file_cxx::get_file ( ) const
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.

Returns
currently opened file or memory

References cgul_block_reader_file__get_file().

§ as_block_reader()

virtual cgul_block_reader_t cgul_block_reader_file_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_file__as_block_reader().

§ get_obj()

virtual cgul_block_reader_file_t cgul_block_reader_file_cxx::get_obj ( ) const
inlinevirtual

Get the underlying cgul_block_reader_file object.

Returns
underlying object

§ take_obj()

virtual cgul_block_reader_file_t cgul_block_reader_file_cxx::take_obj ( )
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().

Returns
underlying object

§ set_obj()

virtual void cgul_block_reader_file_cxx::set_obj ( cgul_block_reader_file_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_file__delete(), and cgul_block_reader_file_cxx().


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