gatb.core-API-0.0.0
CommonFile Class Reference

Default implementation of IFile interface. More...

#include <FileSystemCommon.hpp>

Inheritance diagram for CommonFile:
Inheritance graph

Public Member Functions

 CommonFile (const char *path, const char *mode)
 
virtual ~CommonFile ()
 
bool isOpen ()
 
bool isEOF ()
 
int get ()
 
int unget (int c)
 
int gets (char *s, int size)
 
void print (const char *format,...)
 
size_t fread (void *ptr, size_t size, size_t nmemb)
 
size_t fwrite (const void *ptr, size_t size, size_t nmemb)
 
void flush ()
 
u_int64_t getSize ()
 
const std::string & getPath () const
 
- Public Member Functions inherited from IFile
virtual int seeko (u_int64_t offset, int whence)=0
 
virtual u_int64_t tell ()=0
 
virtual ~IFile ()
 

Detailed Description

Default implementation of IFile interface.

This implementation uses standard C functions (stdio.h).

Constructor & Destructor Documentation

CommonFile ( const char *  path,
const char *  mode 
)
inline

Constructor.

Parameters
[in]path: full path of the file
[in]mode: read/write mode (same as fopen function)
virtual ~CommonFile ( )
inlinevirtual

Destructor.

Member Function Documentation

void flush ( )
inlinevirtual

Flush the file.

Implements IFile.

size_t fread ( void *  ptr,
size_t  size,
size_t  nmemb 
)
inlinevirtual

Reads a buffer from the file.

Parameters
[in]ptr: the buffer to be read
[in]size: size of the buffer
[in]nmemb: number of elements to be written
Returns
number of items successfully written

Implements IFile.

size_t fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb 
)
inlinevirtual

Writes a buffer into the file.

Parameters
[in]ptr: the buffer to be written
[in]size: size of the buffer
[in]nmemb: number of elements to be written
Returns
number of items successfully written

Implements IFile.

int get ( )
inlinevirtual

Get the currently pointed character in the file.

Returns
the current character.

Implements IFile.

const std::string& getPath ( ) const
inlinevirtual

Get the file URI

Returns
the URI of the file

Implements IFile.

int gets ( char *  s,
int  size 
)
inlinevirtual

Reads a line in the file.

Parameters
[in]s: buffer where to put the read line.
[in]size: maximum number of characters to be read
Returns
the actual size of the read buffer (0 if nothing read)

Implements IFile.

u_int64_t getSize ( )
inlinevirtual

Get the size of a file.

Returns
the size of the file.

Implements IFile.

bool isEOF ( )
inlinevirtual

Tells whether or not we are at the end of a file.

Returns
true if we are at the end of the file, false otherwise.

Implements IFile.

bool isOpen ( )
inlinevirtual

Tells whether the file is opened or not.

Returns
open status.

Implements IFile.

void print ( const char *  format,
  ... 
)
inlinevirtual

Writes a buffer (0 terminated) into the file with a new line.

Parameters
[in]format: format of the data to be dumped into the file.
[in]...: arguments (as an ellipsis) to b dumped

Implements IFile.

int unget ( int  c)
inlinevirtual

Unget the currently pointed character in the file.

Parameters
[in]c: the current character.
Returns
c on success, EOF on error

Implements IFile.


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