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

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

#include "piscmds.h"

#include "istream.h"
#include "streambuf.h"


// Implementation of PeekCommand

PeekCommand::PeekCommand(basic_istream_char& is)
  { execute_template(is, true); }

PeekCommand::~PeekCommand()
  {}

ios::iostate PeekCommand::execute(basic_istream_char& is)
  {
    c_ = is.rdbuf()->sgetc();
    return ios::goodbit;
  }


// Implementation of basic_istream_char

int basic_istream_char::peek()
  {
    gcount_ = 0;

    PeekCommand cmd(*this);
    return (good() ? cmd.as_int() : traits::eof());
  }
