// File:       poscmd06.c++
// Version:    1.00
// Author:     (c) Miles Sabin, 1997
// Purpose:    flush command

// Change log:
//  29/03/97   v. 1.00

#include "poscmds.h"

#include "ostream.h"
#include "streambuf.h"


// Implementation of FlushCommand

FlushCommand::FlushCommand(basic_ostream_char& os)
  { execute_template(os); }

FlushCommand::~FlushCommand()
  {}

ios::iostate FlushCommand::execute(basic_ostream_char& os)
  {
    basic_streambuf_char* sb = os.rdbuf();
    return (sb != 0 && sb->pubsync() == -1 ? ios::badbit : ios::goodbit);
  }


// Implementation of basic_ostream_char

basic_ostream_char& basic_ostream_char::flush()
  {
    FlushCommand cmd(*this);
    return *this;
  }


// Implementation of basic_ostream_char free fns

basic_ostream_char& endl(basic_ostream_char& os)
{
  os.put('\n').flush();
  return os;
}

basic_ostream_char& flush(basic_ostream_char& os)
{
  os.flush();
  return os;
}


