#ifndef cathlibcpp_fstream_H
#define cathlibcpp_fstream_H

// File:       fstream.h
// Author:     (c) Miles Sabin, 1997
// Purpose:    approximation to ANSI C++ fstream header


#ifndef cathlibcpp_config_H
#include "config.h"
#endif

#ifndef cathlibcpp_istream_H
#include "istream.h"
#endif

#ifndef cathlibcpp_ostream_H
#include "ostream.h"
#endif

#ifndef cathlibcpp_stdiobuf_H
#include "stdiobuf.h"
#endif

#ifndef cathlibcpp_stream_H
#include "stream.h"
#endif

#ifndef cathlibcpp_string_H
#include "string.h"                 // for char_traits_char
#endif


class basic_filebuf_char;
typedef basic_filebuf_char filebuf;

class basic_ifstream_char;
typedef basic_ifstream_char ifstream;

class basic_ofstream_char;
typedef basic_ofstream_char ofstream;

class basic_fstream_char;
typedef basic_fstream_char fstream;


class basic_filebuf_char : public stdiobuf
{
  public:

    // types
    typedef char_traits_char traits;

    // constructors
    basic_filebuf_char();
    virtual ~basic_filebuf_char();
};


class basic_ifstream_char : public basic_istream_char
{
  public:

    // types
    typedef char_traits_char traits;

    // constructors
    basic_ifstream_char();
    basic_ifstream_char(char const* s, ios_base::openmode mode = ios_base::in);
    ~basic_ifstream_char();

    // accessors
    basic_filebuf_char* rdbuf() const;

    // mutators
    bool is_open();
    void open(char const* s, ios_base::openmode mode = ios_base::in);
    void close();

  private:

    basic_filebuf_char sb_;
};


class basic_ofstream_char : public basic_ostream_char
{
  public:

    // types
    typedef char_traits_char traits;

    // constructors
    basic_ofstream_char();
    basic_ofstream_char(char const* s, ios_base::openmode mode = ios_base::out|ios_base::trunc);
    ~basic_ofstream_char();

    // accessors
    basic_filebuf_char* rdbuf() const;

    // mutators
    bool is_open();
    void open(char const* s, ios_base::openmode mode = ios_base::out|ios_base::trunc);
    void close();

  private:

    basic_filebuf_char sb_;
};


class basic_fstream_char : public basic_iostream_char
{
  public:

    // types
    typedef char_traits_char traits;

    // constructors
    basic_fstream_char();
    basic_fstream_char(char const* s, ios_base::openmode mode = ios_base::in|ios_base::out);
    ~basic_fstream_char();

    // accessors
    basic_filebuf_char* rdbuf() const;

    // mutators
    bool is_open();
    void open(char const* s, ios_base::openmode mode = ios_base::in|ios_base::out);
    void close();

  private:

    basic_filebuf_char sb_;
};

#endif
