Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

File Class Reference

file class that provides some nice features. More...

#include <file.h>

Inheritance diagram for File::

SimpleFile List of all members.

Public Methods

 File ()
 creates non valid file. More...

 File (std::string name, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out, bool nocreate=false, bool real=true)
 File (const File &file)
 copy constructur. More...

 ~File ()
void open (std::string name, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out, bool nocreate=false, bool real=true)
bool is_valid () const
bool operator! () const
std::string get_name () const
template<class T> File & operator<< (const T t)
template<class T> File & operator>> (T &t)
void seekg (long pos)
long tellg ()
void seekp (long pos)
long tellp ()
int eof ()
std::iostream & get_io ()
 returns the iostream of the stream. More...

void operator= (const File &file)
std::ios_base::openmode get_mode () const
int get_line () const
void set_line (int line)
void operator++ ()
 increase the line number. More...

void operator-- ()
 decrease the line number. More...

std::ostream & flush ()
std::ostream & put (char c)
std::ostream & write (std::string str)
std::ostream & write (std::string str, std::streamsize n)
std::istream & get (char &c)
std::istream & read (char *ptr, std::streamsize n)
void clear ()
void trunc ()
 truncate the file. More...

bool append (File other)
 append and other file to this file. More...

void stats (File other)
void stats (std::ostream &out)
void dump (File other)
void dump (std::ostream &out)

Static Public Methods

bool use_handler ()
 use the file handler? More...

void use_handler (bool u)
bool use_tmp_files ()
 use temporary files? More...

void use_tmp_files (bool u)
bool fh_has_file (std::string name)
 check the file handler if the file already is registerd. More...


Private Methods

void set_mode (std::ios_base::openmode mode)

Private Attributes

streams
 the stream. More...

bool valid
bool real
 true if the file is a real file. More...

std::string init_name
 if s == 0 it uses this backup name. More...

bool nocreate
 if true, no file will be created, if it does not exist. More...


Static Private Attributes

bool use_mem = true
 use the file handler (default true). More...

bool use_tmp = false
 use temporary files (default false). More...

file_handler fh
 the global file handler. More...


Detailed Description

file class that provides some nice features.

The class can access real files or virtual files that are mapped into the memory. At creation time you can specify if this file has to be exist really. The heart of the File class are the stream classes. The class is using reference counting for easy handling the Files.


Constructor & Destructor Documentation

File::File  
 

creates non valid file.

File::File std::string    name,
std::ios_base::openmode    mode = std::ios_base::in | std::ios_base::out,
bool    nc = false,
bool    real = true
 

Parameters:
nc  do not create the file if it does not exist

File::File const File &    file
 

copy constructur.

File::~File  
 


Member Function Documentation

bool File::append File    other
 

append and other file to this file.

void File::clear   [inline]
 

Reimplemented in SimpleFile.

void File::dump std::ostream &    out
 

void File::dump File    other [inline]
 

int File::eof   [inline]
 

Reimplemented in SimpleFile.

bool File::fh_has_file std::string    name [static]
 

check the file handler if the file already is registerd.

std::ostream& File::flush   [inline]
 

Reimplemented in SimpleFile.

std::istream& File::get char &    c [inline]
 

Reimplemented in SimpleFile.

std::iostream& File::get_io   [inline]
 

returns the iostream of the stream.

int File::get_line   const [inline]
 

std::ios_base::openmode File::get_mode   const [inline]
 

std::string File::get_name   const [inline]
 

if the file is not valid this is the only function, that can be called. It returns the name of the current stream, or if there is no stream, the file is not valid, it returns the name of the file opened with open() or the constructor

Reimplemented in SimpleFile.

bool File::is_valid   const [inline]
 

Reimplemented in SimpleFile.

void File::open std::string    name,
std::ios_base::openmode    mode = std::ios_base::in | std::ios_base::out,
bool    nocreate = false,
bool    real = true
[inline]
 

bool File::operator!   const [inline]
 

Reimplemented in SimpleFile.

void File::operator++   [inline]
 

increase the line number.

void File::operator--   [inline]
 

decrease the line number.

template<class T>
File& File::operator<< const T    t [inline]
 

void File::operator= const File &    file
 

the behavoir is like the std::string class the reference to the old file will be deleted and one new to the new file

template<class T>
File& File::operator>> T &    t [inline]
 

std::ostream& File::put char    c [inline]
 

Reimplemented in SimpleFile.

std::istream& File::read char *    ptr,
std::streamsize    n
[inline]
 

Reimplemented in SimpleFile.

void File::seekg long    pos [inline]
 

Reimplemented in SimpleFile.

void File::seekp long    pos [inline]
 

Reimplemented in SimpleFile.

void File::set_line int    line [inline]
 

void File::set_mode std::ios_base::openmode    mode [private]
 

void File::stats std::ostream &    out
 

void File::stats File    other [inline]
 

long File::tellg   [inline]
 

Reimplemented in SimpleFile.

long File::tellp   [inline]
 

Reimplemented in SimpleFile.

void File::trunc  
 

truncate the file.

Reimplemented in SimpleFile.

void File::use_handler bool    u [static]
 

bool File::use_handler   [static]
 

use the file handler?

void File::use_tmp_files bool    u [static]
 

bool File::use_tmp_files   [static]
 

use temporary files?

std::ostream& File::write std::string    s,
std::streamsize    n
[inline]
 

Reimplemented in SimpleFile.

std::ostream& File::write std::string    s [inline]
 

Reimplemented in SimpleFile.


Member Data Documentation

File::file_handler File::fh [static, private]
 

the global file handler.

std::string File::init_name [private]
 

if s == 0 it uses this backup name.

bool File::nocreate [private]
 

if true, no file will be created, if it does not exist.

bool File::real [private]
 

true if the file is a real file.

stream* File::s [private]
 

the stream.

bool File::use_mem = true [static, private]
 

use the file handler (default true).

bool File::use_tmp = false [static, private]
 

use temporary files (default false).

bool File::valid [private]
 


The documentation for this class was generated from the following files:
Generated on Tue Nov 20 02:19:53 2001 for Leo<HTML> by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001