omw  0.2.1-beta
Public Types | Public Member Functions | Static Public Attributes | List of all members
omw::io::FileInterface_Base Class Reference
Inheritance diagram for omw::io::FileInterface_Base:
omw::io::BinFileInterface

Public Types

using fstream = std::fstream
 
using iostate = fstream::iostate
 
using openmode = fstream::openmode
 

Public Member Functions

 FileInterface_Base (const std::string &filename)
 
const omw::stringfilename () const
 
void setFileName (const std::string &filename)
 
void open (openmode mode) const
 
void openRead () const
 
void openWrite ()
 
void close () const
 
size_t size () const
 
void read (char *buffer, size_t count) const
 
void write (const char *data)
 
void write (const char *data, size_t count)
 
iostate getState () const
 

Static Public Attributes

static constexpr iostate good = fstream::goodbit
 
static constexpr iostate badbit = fstream::badbit
 
static constexpr iostate failbit = fstream::failbit
 
static constexpr iostate eofbit = fstream::eofbit
 
static constexpr openmode rd = fstream::in
 
static constexpr openmode wr = fstream::out
 

Detailed Description

#include <omw/io/file.h>

Wrapper class for std::fstream.

Alldought this method of reading and writing a file is not very efficient, it's convenient, easy to use and fine for small files.

The constness of the member functions is to let the file (because of this interface class) act like a C++ object.

Member Typedef Documentation

◆ iostate

using omw::io::FileInterface_Base::iostate = fstream::iostate

Stream state type

◆ openmode

using omw::io::FileInterface_Base::openmode = fstream::openmode

Open mode type

Member Function Documentation

◆ close()

void omw::io::FileInterface_Base::close ( ) const

Exceptions

  • fstream::failure if an error occures

◆ getState()

omw::io::FileInterface_Base::iostate omw::io::FileInterface_Base::getState ( ) const

Returns the state flags of the file stream.

See also std::ios::rdstate() and std::ios::iostate.

◆ open()

void omw::io::FileInterface_Base::open ( openmode  mode) const
Parameters
modeEither FileInterface_Base::rd or FileInterface_Base::wr

Exceptions

  • fstream::failure if an error occures

◆ openRead()

omw::io::FileInterface_Base::openRead ( ) const
inline

Opens the file in read mode.

Exceptions

  • fstream::failure if an error occures

◆ openWrite()

omw::io::FileInterface_Base::openWrite ( )
inline

Opens the file in write mode.

Exceptions

  • fstream::failure if an error occures

◆ read()

void omw::io::FileInterface_Base::read ( char *  buffer,
size_t  count 
) const

Allways starts reading at stream position 0.

Exceptions

◆ size()

size_t omw::io::FileInterface_Base::size ( ) const

Exceptions

◆ write() [1/2]

void omw::io::FileInterface_Base::write ( const char *  str)
Parameters
strNull terminated string

Examines the string length and then passes both to omw::io::FileInterface_Base::write(const char* data, size_t count).

◆ write() [2/2]

void omw::io::FileInterface_Base::write ( const char *  data,
size_t  count 
)

Allways starts writing at stream position 0.

Exceptions

Member Data Documentation

◆ rd

constexpr openmode omw::io::FileInterface_Base::rd = fstream::in
staticconstexpr

Open file in read mode

◆ wr

constexpr openmode omw::io::FileInterface_Base::wr = fstream::out
staticconstexpr

Open file in write mode


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