Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdIO Class Reference

A class for performing input and output. More...

#include <rdIO.h>

List of all members.

Static Public Member Functions

void SetScientific (bool aTrueFalse)
 Set whether or not output of numbers should be in scientific or float format.

bool GetScientific ()
 Set whether or not output of numbers should be in scientific or float format.

void SetDigitsPad (int aPad)
 Set the number of digits with which to pad output of numbers.

int GetDigitsPad ()
 Get the number of digits with which output of numbers is padded.

void SetPrecision (int aPlaces)
 Set the precision with which numbers are output.

int GetPrecision ()
 Get the precision with which numbers are output.

const char * GetDoubleOutputFormat ()
 Get the current output format for numbers of type double.

char * ReadToTokenLine (FILE *aFP, const char *aToken)
 Read lines from the file until a line consisting entirely of a token is read or until the end of the file.

char * ReadLine (FILE *aFP)
 Read a line of text from file.

int ComputeLineLength (FILE *aFP)
 Compute the length of a line.

int ComputeNumberOfSteps (double aTI, double aTF, double aDT)
 Compute the number of steps of a given size to get from some initial time to some final time.

char * ReadCharacters (FILE *aFP, int aNChar)
 Read a specified number of characters from file.

FILE * OpenFile (const char *aFileName, const char *aMode)
 Open a file.


Static Public Attributes

const int STRLEN = rdIO_STRLEN
 Default size of a statically or locally allocated character array.

const int STRING_INCREMENT = rdIO_STRING_INCREMENT
 Increment by which the size of character strings are incremented.


Static Private Member Functions

void ConstructDoubleOutputFormat ()
 Construct a valid output format for numbers of type double.


Static Private Attributes

bool _Scientific = false
 Specifies whether number output is in scientific or float format.

int _Pad = 8
 Specifies number of digits of padding in number output.

int _Precision = 8
 Specifies the precision of number output.

char _DoubleFormat [256] = "%16.8lf"
 The output format string.


Detailed Description

A class for performing input and output.

Version:
1.0
Author:
Frank C. Anderson


Member Function Documentation

int rdIO::ComputeLineLength FILE *  aFP  )  [static]
 

Compute the length of a line.

A carriage return defines the end of a line.

Parameters:
aFP File pointer.
Returns:
Length of a line.

int rdIO::ComputeNumberOfSteps double  aTI,
double  aTF,
double  aDT
[static]
 

Compute the number of steps of a given size to get from some initial time to some final time.

If (aTF-aTI)/aDT has a remainder that is greater than 1% of the step size, an additional step is assumed to be needed to step completely to the end of the interval.

Parameters:
aTI Initial time.
aTF Final time.
aDT Step size. Should be greater than 0.0.

void rdIO::ConstructDoubleOutputFormat  )  [static, private]
 

Construct a valid output format for numbers of type double.

This method is called each time a change is made to any of the output format parameters.

See also:
SetScientific(), SetDigitsPad, SetPrecision.

int rdIO::GetDigitsPad  )  [static]
 

Get the number of digits with which output of numbers is padded.

The pad number is used to set the minimum field width by the following formula: width = pad + precision

The formated output string, for example, would have the form width.precisionlf.

Returns:
aPad Number of digits with which output of number is padded.

const char * rdIO::GetDoubleOutputFormat  )  [static]
 

Get the current output format for numbers of type double.

The format is maintained as a static variable in class rdIO, so any changes made to the output parameters in class rdIO will be seen globally by all classes using this method.

The returned output format will be of the form

"% width.precision lf" (if not scientific) or "% width.precision le" (if scientific),

where the spaces have been removed and width = pad + precision.

Returns:
Format string for output of doubles.
See also:
SetScientific(), SetDigitsPad, SetPrecision.

int rdIO::GetPrecision  )  [static]
 

Get the precision with which numbers are output.

The precision is usually simply the number of decimal places.

Returns:
Precision (often number of decimal places).

bool rdIO::GetScientific  )  [static]
 

Set whether or not output of numbers should be in scientific or float format.

Returns:
True if scientific notation, false if float.

char * rdIO::ReadCharacters FILE *  aFP,
int  aNChar
[static]
 

Read a specified number of characters from file.

Memory is allocated for the returned string, so the caller is responsible for deleting this memory.

Parameters:
aFP File pointer that points to the file.
aNChar Number of characters in the description.
Returns:
Pointer to the string of characters.

char * rdIO::ReadLine FILE *  aFP  )  [static]
 

Read a line of text from file.

The terminating carriage return is not included in the returned string.

This routine allocates memory to store the line, so the caller is responsible for deleting this memory.

Parameters:
aFP Pointer to the file.
Returns:
Line of text not including the terminating carriage return.

char * rdIO::ReadToTokenLine FILE *  aFP,
const char *  aToken
[static]
 

Read lines from the file until a line consisting entirely of a token is read or until the end of the file.

The file pointer is advanced to the first character after the token.

Memory is allocated for the description, so the caller is responsible for deleting the returned description.

Parameters:
aFilePointer File pointer that points to the file.
aToken Token to which to read. The token should not contain a carriage return.
Returns:
Null terminated String up to a token line. The ending carriage return is included in the returned string.

void rdIO::SetDigitsPad int  aPad  )  [static]
 

Set the number of digits with which to pad output of numbers.

The pad number is used to set the minimum field width by the following formula: width = pad + precision

The formated output string, for example, would have the form width.precisionlf.

Parameters:
aPad Number of digits with which output of numbers is padded.

void rdIO::SetPrecision int  aPlaces  )  [static]
 

Set the precision with which numbers are output.

The precision is usually simply the number of decimal places.

Parameters:
aPrecision Precision.

void rdIO::SetScientific bool  aTrueFalse  )  [static]
 

Set whether or not output of numbers should be in scientific or float format.

Parameters:
aTrueFalse Scientific notation if true, and float if false.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:11 2003 for Simulation Software by doxygen1.3