#ifndef INCLUDED_BOBCAT_OFOLDSTREAM_
#define INCLUDED_BOBCAT_OFOLDSTREAM_

#include <iosfwd>
#include <ostream>
#include <fstream>

#include <bobcat/ofoldbuf>

namespace FBB
{

    // 'virtual public OFoldBufBlanks is used to avoid 'base class not
    // accessible' warnings since OFoldBuf also inherits from
    // OFoldBufBlanks and only one struct definition is needed in the
    // final OFoldStream class.
class OFoldStream: virtual public OFoldBufEnums, 
                   private OFoldBuf, public std::ostream
{
    public:
        OFoldStream()           = default;

        explicit OFoldStream(std::string const &fname,              // 1.f
                    size_t leftIndent = 0, size_t rightMargin = 80,
                    TabsOrBlanks tob = BLANKS,
                    TrailingBlanks tb = IGNORE_TRAILING_BLANKS);

        explicit OFoldStream(std::ostream &dest,                    // 2.f
                    size_t leftIndent = 0, size_t rightMargin = 80,
                    TabsOrBlanks tob = BLANKS,
                    TrailingBlanks tb = IGNORE_TRAILING_BLANKS);

        void reset(std::string const &fname,
                  size_t leftIndent = 0, size_t rightMargin = 80,
                  TrailingBlanks tb = IGNORE_TRAILING_BLANKS);

        void reset(std::ostream &out,
                  size_t leftIndent = 0, size_t rightMargin = 80,
                  TrailingBlanks tb = IGNORE_TRAILING_BLANKS);

        void setMargins(size_t leftMargin, size_t rightMargin);     // .f
        void setTrailingBlanks(TrailingBlanks tb);                  // .f
        void useBlanks();                                           // .f
        void useTabs(size_t tabWidth = 8);                          // .f

        static size_t leftMargin(std::ostream const &os);           // .f
        static size_t rightMargin(std::ostream const &os);          // .f
};

#include "ofoldstream1.f"
#include "ofoldstream2.f"

#include "leftmargin.f"
#include "rightmargin.f"
#include "setmargins.f"    
#include "settrailingblanks.f"    
#include "useblanks.f"
#include "usetabs.f"

} // FBB

#endif




