libdballe  6.8
Public Member Functions | Static Public Member Functions | Protected Attributes
dballe::File Class Referenceabstract
Inheritance diagram for dballe::File:
dballe::AofFile dballe::ArrayFile

Public Member Functions

 File (const std::string &name, FILE *fd, bool close_on_exit=true)
 
FILE * stream () const throw ()
 Get the file stream.
 
const std::string & name () const throw ()
 Get the type of the dba_file. More...
 
virtual Encoding type () const =0 throw ()
 Get the name of the dba_file. More...
 
virtual bool read (Rawmsg &msg)=0
 Read a message from the file. More...
 
virtual void write (const Rawmsg &msg)
 Write the encoded message data to the file. More...
 

Static Public Member Functions

static std::auto_ptr< Filecreate (Encoding type, const std::string &name, const char *mode)
 Create a dba_file structure. More...
 

Protected Attributes

std::string m_name
 Name of the file.
 
FILE * fd
 FILE structure used to read or write to the file.
 
bool close_on_exit
 Set to true if fd should be closed when dba_file_delete() is called.
 
int idx
 Index of the last message read from the file or written to the file.
 

Member Function Documentation

static std::auto_ptr<File> dballe::File::create ( Encoding  type,
const std::string &  name,
const char *  mode 
)
static

Create a dba_file structure.

Parameters
typeThe type of data contained in the file. If -1 is passed, then create will attempt to autodetect the file type from its first byte.
nameThe name of the file to access. "(stdin)", "(stdout)" and "(stderr)" are special file names, that will use the corresponding stream instead of open a file.
modeThe opening mode of the file, as used by fopen.
Returns
The newly allocated File, that needs to be deleted by the caller.
const std::string& dballe::File::name ( ) const
throw (
)
inline

Get the type of the dba_file.

Returns
The file encoding.

References m_name.

virtual bool dballe::File::read ( Rawmsg msg)
pure virtual

Read a message from the file.

Parameters
msgThe Rawmsg that will hold the data.
Returns
true if a message has been found in the file, else false.

Implemented in dballe::AofFile, and dballe::ArrayFile.

virtual Encoding dballe::File::type ( ) const
throw (
)
pure virtual

Get the name of the dba_file.

Returns
The file name.

Implemented in dballe::AofFile, and dballe::ArrayFile.

virtual void dballe::File::write ( const Rawmsg msg)
virtual

Write the encoded message data to the file.

Parameters
msgThe ::dba_rawmsg with the encoded data to write

Reimplemented in dballe::AofFile, and dballe::ArrayFile.


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