STK++ 1.0

STKernel::Base I/O stream declarations

Nearly all of the I/O classes are parameterized on the type of characters they read and write (The major exception is ios_base at the top of the hierarchy). More...

Collaboration diagram for STKernel::Base I/O stream declarations:

Typedefs

typedef std::basic_ios< Char > STK::ios
 ios for Char
typedef std::basic_streambuf
< Char > 
STK::streambuf
 streambuf for Char
typedef std::basic_istream< Char > STK::istream
 istream for Char
typedef std::basic_ostream< Char > STK::ostream
 ostream for Char
typedef std::basic_iostream< Char > STK::iostream
 iostream for Char
typedef std::basic_stringbuf
< Char > 
STK::stringbuf
 stringbuf for Char
typedef
std::basic_istringstream< Char > 
STK::istringstream
 istringstream (istringstream) for Char
typedef
std::basic_ostringstream< Char > 
STK::ostringstream
 ostringstream (ostringstream) for Char
typedef
std::basic_stringstream< Char > 
STK::stringstream
 stringstream (stringstream) for Char
typedef std::basic_filebuf< Char > STK::filebuf
 filebuf for Char
typedef std::basic_ifstream< Char > STK::ifstream
 ifstream for Char
typedef std::basic_ofstream< Char > STK::ofstream
 ofstream for Char
typedef std::basic_fstream< Char > STK::fstream
 fstream for Char

Functions

ostream & STK::operator<< (ostream &os, const Binary &output)
 Overloading of the ostream << for the type Binary.
istream & STK::operator>> (istream &is, Proxy< Binary > &input)
 Overloading of the istream >> for the type Binary.
ostream & STK::operator<< (ostream &os, const NotAvailable &output)
 Overloading of the ostream << for the type NotAvailable.
istream & STK::operator>> (istream &is, Proxy< NotAvailable > &input)
 Overloading of the istream >> for the type NotAvailable.
ostream & STK::operator<< (ostream &os, const Sign &output)
 Overloading of the ostream << for the type Sign.
istream & STK::operator>> (istream &is, Proxy< Sign > &input)
 Overloading of the istream >> for the type Sign.

Detailed Description

Nearly all of the I/O classes are parameterized on the type of characters they read and write (The major exception is ios_base at the top of the hierarchy).

For ease of use, all of the basic_* I/O-related classes are given typedef names in the namespace STK. For example:

     typedef basic_ifstream<Char>  ifstream;

These declarations in the STK namespace would be very useful if you modifiy the built-in type representation of Char (say wchar_t).


Typedef Documentation

typedef std::basic_ios<Char> STK::ios

ios for Char

Definition at line 70 of file STK_Stream.h.

typedef std::basic_streambuf<Char> STK::streambuf

streambuf for Char

Definition at line 75 of file STK_Stream.h.

typedef std::basic_istream<Char> STK::istream

istream for Char

Definition at line 80 of file STK_Stream.h.

typedef std::basic_ostream<Char> STK::ostream

ostream for Char

Definition at line 85 of file STK_Stream.h.

typedef std::basic_iostream<Char> STK::iostream

iostream for Char

Definition at line 90 of file STK_Stream.h.

typedef std::basic_stringbuf<Char> STK::stringbuf

stringbuf for Char

Definition at line 95 of file STK_Stream.h.

typedef std::basic_istringstream<Char> STK::istringstream

istringstream (istringstream) for Char

Definition at line 100 of file STK_Stream.h.

typedef std::basic_ostringstream<Char> STK::ostringstream

ostringstream (ostringstream) for Char

Definition at line 105 of file STK_Stream.h.

typedef std::basic_stringstream<Char> STK::stringstream

stringstream (stringstream) for Char

Definition at line 110 of file STK_Stream.h.

typedef std::basic_filebuf<Char> STK::filebuf

filebuf for Char

Definition at line 115 of file STK_Stream.h.

typedef std::basic_ifstream<Char> STK::ifstream

ifstream for Char

Definition at line 120 of file STK_Stream.h.

typedef std::basic_ofstream<Char> STK::ofstream

ofstream for Char

Definition at line 125 of file STK_Stream.h.

typedef std::basic_fstream<Char> STK::fstream

fstream for Char

Definition at line 130 of file STK_Stream.h.


Function Documentation

ostream & STK::operator<< ( ostream &  os,
const Binary &  output 
)

Overloading of the ostream << for the type Binary.

Parameters:
osthe output stream
outputthe value to send to the stream

Definition at line 44 of file STK_Binary.cpp.

References STK::STRING_NA.

{ if (Arithmetic<Binary>::isNA(output))
    return (os <<  STRING_NA);
  else
    return (os << static_cast<int> (output));
}
istream & STK::operator>> ( istream &  is,
Proxy< Binary > &  input 
)

Overloading of the istream >> for the type Binary.

Parameters:
isthe input stream
inputthe value to get from the stream

Definition at line 53 of file STK_Binary.cpp.

References STK::Arithmetic< TYPE >::NA(), STK::STRING_NA, and STK::STRING_NA_SIZE.

{
  // get current file position
  std::ios::pos_type pos = is.tellg();
  // try to read a discrete value
  int buff;
  // failed to read a discrete value
  if ((is >> buff).fail())
  {
    // clear failbit state
    is.clear(is.rdstate() & ~std::ios::failbit);
    // clear eofbit state if necessary and rewind position
    if (is.eof())
    {
      is.seekg(pos);
      is.clear(is.rdstate() & ~std::ios::eofbit);
    }
    // in all case input is a NA object
    input = Arithmetic<Binary>::NA();
    // get current position in the stream
    pos = is.tellg();

    // Create a String buffer
    Char Lbuff[STRING_NA_SIZE+1];

    // try to read a NA String
    is.getline(Lbuff, STRING_NA_SIZE+1);

    // if we don't get a NA String, rewind stream
    if (!(STRING_NA.compare(Lbuff) == 0))
    { is.seekg(pos); }
  }
  else
    input = static_cast<Binary>(buff);
  return is;
}
ostream & STK::operator<< ( ostream &  os,
const NotAvailable &  output 
)

Overloading of the ostream << for the type NotAvailable.

Parameters:
osthe output stream
outputthe value to send to the stream

Definition at line 44 of file STK_NotAvailable.cpp.

References STK::STRING_NA.

{ return (os <<  STRING_NA);}
istream & STK::operator>> ( istream &  is,
Proxy< NotAvailable > &  input 
)

Overloading of the istream >> for the type NotAvailable.

Parameters:
isthe input stream
inputthe value to get from the stream

Definition at line 49 of file STK_NotAvailable.cpp.

References STK::Arithmetic< TYPE >::NA(), STK::STRING_NA, and STK::STRING_NA_SIZE.

{
  // in all case input is a NA object
  input = Arithmetic<NotAvailable>::NA();
  // get current file position
  std::ios::pos_type pos = is.tellg();

  // Create a String buffer
  Char Lbuff[STRING_NA_SIZE+1];

  // try to read a NA String
  is.getline(Lbuff, STRING_NA_SIZE+1);

  // if we don't get a NA String, rewind stream
  if (!(STRING_NA.compare(Lbuff) == 0))
  { is.seekg(pos); }
  return is;
}
ostream & STK::operator<< ( ostream &  os,
const Sign &  output 
)

Overloading of the ostream << for the type Sign.

Parameters:
osthe output stream
outputthe value to send to the stream

Definition at line 43 of file STK_Sign.cpp.

References STK::STRING_NA.

{ if (Arithmetic<Sign>::isNA(output))
    return (os <<  STRING_NA);
  else
    return (os << static_cast<int> (output));
}
istream & STK::operator>> ( istream &  is,
Proxy< Sign > &  input 
)

Overloading of the istream >> for the type Sign.

Parameters:
isthe input stream
inputthe value to get from the stream

Definition at line 52 of file STK_Sign.cpp.

References STK::Arithmetic< TYPE >::NA(), STK::STRING_NA, and STK::STRING_NA_SIZE.

{
  // get current file position
  std::ios::pos_type pos = is.tellg();
  // try to read a discrete value
  int buff;
  // failed to read a discrete value
  if ((is >> buff).fail())
  {
    // clear failbit state
    is.clear(is.rdstate() & ~std::ios::failbit);
    // clear eofbit state if necessary and rewind position
    if (is.eof())
    {
      is.seekg(pos);
      is.clear(is.rdstate() & ~std::ios::eofbit);
    }
    // in all case input is a NA object
    input = Arithmetic<Sign>::NA();
    // get current position in the stream
    pos = is.tellg();

    // Create a String buffer
    Char Lbuff[STRING_NA_SIZE+1];

    // try to read a NA String
    is.getline(Lbuff, STRING_NA_SIZE+1);

    // if we don't get a NA String, rewind stream
    if (!(STRING_NA.compare(Lbuff) == 0))
    { is.seekg(pos); }
  }
  else
    input = static_cast<Sign>(buff);
  return is;
}