Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

Os_base Class Reference

base class for generalized output, used by class Os. More...

#include <IsOs.h>

Inheritance diagram for Os_base::

HandleId Os_ostream Os_String Os_xdr Os_MFCLog Os_ofstream List of all members.

Public Methods

 Os_base (Format_type format=ASCII)
virtual ~Os_base ()
virtual bool ok () const
void setFormat (Format_type format=ASCII)
void resetFormat ()
Format_type getFormat ()
void setRealFormat (const String &f)
void resetRealFormat ()
String getRealFormat ()
void setIntFormat (const String &f)
void resetIntFormat ()
String getIntFormat ()
void setLongFormat (const String &f)
void resetLongFormat ()
String getLongFormat ()
void setCharFormat (const String &f)
void resetCharFormat ()
String getCharFormat ()
void setStringFormat (const String &f)
void resetStringFormat ()
String getStringFormat ()
int getFormatWidth (const String &f)
int getFormatWidth (float)
int getFormatWidth (double)
int getFormatWidth (Complex &)
int getFormatWidth (char)
int getFormatWidth (int)
int getFormatWidth (long int)
int getFormatWidth (char *)
int getNoDecimals (const String &f)
virtual bool put (const char *word)
virtual bool put (const String &word)
virtual bool put (float a)
virtual bool put (double a)
virtual bool put (int i)
virtual bool put (long i)
virtual bool put (char c)
virtual bool put (char *data, int item_size, int nitems)
virtual void flush ()
virtual long getPosition ()
virtual void setPosition (long filepos)
virtual void close ()

Static Public Attributes

int protection

Protected Attributes

bool closed
Format_type format
Format_type last_format
String real_format
String int_format
String long_format
String char_format
String string_format
int width
String last_real_format
String last_int_format
String last_long_format
String last_char_format
String last_string_format

Detailed Description

base class for generalized output, used by class Os.

NAME: Os_base - base class for generalized output, used by class Os

DESCRIPTION:

The class is handled by class "Os" (see class "Os" for the purpose of generalized output). Class "Os_base" serves as base class for various output sources such as ostream, ofstream, strings and xdr binary files. The comments in the description of class "Is_base" also apply to class "Os_base".


Constructor & Destructor Documentation

Os_base::Os_base ( Format_type format = ASCII )
 

The constructor takes a format argument, indicating whether the input source has binary or ascii format. The default value is "ASCII". No further initialization is necessary. The comments in the description of class "Is_base" also apply to class "Os_base".

Os_base::~Os_base ( ) [virtual]
 


Member Function Documentation

void Os_base::close ( ) [virtual]
 

closes output files (used when the file must be flushed and closed before the "Os" object has gone out of scope or has been deleted).

In contrast to the standard output class "ostream" in C++, the "Os" class can set a fixed format for all real (or integer) numbers and reset the format to the original one when desired. Together with the "oform" and "aform" functions, this gives very flexible output formatting tools.

Reimplemented in Os_ostream, Os_ofstream, Os_MFCLog, Os_String, and Os_xdr.

void Os_base::flush ( ) [virtual]
 

flushes the output buffer, that is, forces the output to be written immediately.

Reimplemented in Os_ostream, Os_ofstream, Os_MFCLog, Os_String, and Os_xdr.

String Os_base::getCharFormat ( ) [inline]
 

as "getRealFormat" but aimed at characters.

Format_type Os_base::getFormat ( ) [inline]
 

returns the format type. The return value is an "enum" "Format_type".

int Os_base::getFormatWidth ( char * ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( long int ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( int ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( char ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( Complex & ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( double ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( float ) [inline]
 

See documentation of one of the overloaded functions.

int Os_base::getFormatWidth ( const String & f )
 

returns the width of the current format, for example, if we have called "setRealFormat" for a "12.4e" format, "getFormatWidth" returns 12.

String Os_base::getIntFormat ( ) [inline]
 

as "getRealFormat" but aimed at integers.

String Os_base::getLongFormat ( ) [inline]
 

as "getRealFormat" but aimed at "long int" variables.

int Os_base::getNoDecimals ( const String & f )
 

just that, in the example given above ("12.4e") it returns 4.

long Os_base::getPosition ( ) [virtual]
 

returns the position in a random access file.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

String Os_base::getRealFormat ( ) [inline]
 

get the output format for all real numbers. The string is on a format using well-known "printf" syntax.

String Os_base::getStringFormat ( ) [inline]
 

as "getRealFormat" but aimed at strings, or strictly speaking, "char[]" arrays.

bool Os_base::ok ( ) const [virtual]
 

Reimplemented in Os_ostream, Os_ofstream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( char * data,
int item_size,
int nitems ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_String, and Os_xdr.

bool Os_base::put ( char c ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( long int ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( int i ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( double a ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( float a ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( const String & word ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

bool Os_base::put ( const char * word ) [virtual]
 

similar to "get", but writes the number/string/character.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

void Os_base::resetCharFormat ( )
 

as "resetRealFormat" but aimed at characters.

void Os_base::resetFormat ( )
 

resets the format type to the value prior to last call to "setFormat". See similar function in class Is_base for more information.

void Os_base::resetIntFormat ( )
 

as "resetRealFormat" but aimed at integers.

void Os_base::resetLongFormat ( )
 

as "resetRealFormat" but aimed at "long int" variables.

void Os_base::resetRealFormat ( )
 

resets the real format to the value before last call to "setRealFormat". Very convenient if one wants to change the format inside a function but then reset the format to its original state. There are similar functions for the int, long, char and string formats as well.

void Os_base::resetStringFormat ( )
 

as "setRealFormat" but aimed at strings, or strictly speaking, "char[]" arrays.

void Os_base::setCharFormat ( const String & f )
 

as "setRealFormat" but aimed at characters.

void Os_base::setFormat ( Format_type format = ASCII )
 

sets the format type to "ASCII" or "BINARY".

void Os_base::setIntFormat ( const String & f )
 

as "setRealFormat" but aimed at integers.

void Os_base::setLongFormat ( const String & f )
 

as "setRealFormat" but aimed at "long int" variables.

void Os_base::setPosition ( long int ) [virtual]
 

sets the position in a random access file.

Reimplemented in Os_ostream, Os_MFCLog, Os_String, and Os_xdr.

void Os_base::setRealFormat ( const String & f )
 

sets the output format for all real numbers. The argument takes a format string using the well-known "printf" syntax. Consult a C textbook for reference. Compared to format setting in "ostream", the "setRealFormat" function is much more convenient since it is not necessary to specify the format for every number being written. If a fixed format set by "setRealFormat" is not suitable, we recommend to use the functions "oform" or "aform" for flexible indication of the output format. These two functions work as "printf" but instead of writing to the standard output they return the formatted string as a "char[]" array ("oform") or as a "String" object ("aform"). Since "oform" uses a fixed-size internal character buffer and returns just a pointer to this buffer, repeated calls to "oform" may result in strange output errors. "aform" is much safer since it allocates a "String" every time it is invoked.

void Os_base::setStringFormat ( const String & f )
 

as "setRealFormat" but aimed at strings, or strictly speaking, "char[]" arrays.


Member Data Documentation

String Os_base::char_format [protected]
 

bool Os_base::closed [protected]
 

Format_type Os_base::format [protected]
 

String Os_base::int_format [protected]
 

String Os_base::last_char_format [protected]
 

Format_type Os_base::last_format [protected]
 

String Os_base::last_int_format [protected]
 

String Os_base::last_long_format [protected]
 

String Os_base::last_real_format [protected]
 

String Os_base::last_string_format [protected]
 

String Os_base::long_format [protected]
 

int Os_base::protection [static]
 

String Os_base::real_format [protected]
 

String Os_base::string_format [protected]
 

int Os_base::width [protected]
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.