GeoTessCPP  2.2.3
Software to facilitate storage and retrieval of 3D information about the Earth.
geotess::IFStreamAscii Class Reference

Opens ascii file for read and write access. More...

#include <IFStreamAscii.h>

Public Member Functions

void getLine (string &buf)
 
void getline (string &s)
 
 IFStreamAscii ()
 
virtual ~IFStreamAscii ()
 
void openForRead (const string &fn)
 
void openForWrite (const string &fn)
 
bool isOpen ()
 
void close ()
 
void flush ()
 
void resetPos ()
 
bool read (string &token)
 
bool readLine (string &ln)
 
void tokenize (const string &str, vector< string > &tokens)
 
const string & getFileName () const
 
void setDefaultDelimiters ()
 
void resetReader ()
 
void setDelimiters (const string &wspcDelims, const string &strgDelim, const string &cmntDelim, const string &begBlk, const string &endBlk)
 
void setWhitespaceDelimiters (const string &wsDelims)
 
const string & getWhitespaceDelimiters () const
 
void setStringDelimiter (const string &strgDelim)
 
const string & getStringDelimiter () const
 
void setCommentDelimiter (const string &cmntDelim)
 
const string & getCommentDelimiter () const
 
void setBlockCommentDelimiters (const string &begBlk, const string &endBlk)
 
void setBeginBlockCommentDelimiter (const string &begBlkCmntDelim)
 
const string & getBeginBlockCommentDelimiter () const
 
void setEndBlockCommentDelimiter (const string &endBlkCmntDelim)
 
const string & getEndBlockCommentDelimiter () const
 
int getTotalLinesRead () const
 
int getDataLinesRead () const
 
int getBlankLinesRead () const
 
int getCommentLinesRead () const
 
int getBlockCommentLinesRead () const
 
int getBytesRead () const
 
bool isEOF () const
 
bool next ()
 
string readString ()
 
bool readString (string &s)
 
byte readByte ()
 
bool readType (byte &b)
 
bool readByte (byte &b)
 
short readShort ()
 
bool readType (short &s)
 
bool readShort (short &s)
 
int readInteger ()
 
bool readType (int &i)
 
bool readInteger (int &i)
 
LONG_INT readLong ()
 
bool readType (LONG_INT &l)
 
bool readLong (LONG_INT &l)
 
float readFloat ()
 
bool readType (float &f)
 
bool readFloat (float &f)
 
double readDouble ()
 
bool readType (double &d)
 
bool readDouble (double &d)
 
void writeString (const string &s)
 
void writeStringNL (const string &s)
 
void writeType (const string &s)
 
void writeTypeNL (const string &s)
 
void writeBool (bool b)
 
void writeBoolNL (bool b)
 
void writeType (bool b)
 
void writeTypeNL (bool b)
 
void writeByte (byte b)
 
void writeByteNL (byte b)
 
void writeType (byte b)
 
void writeTypeNL (byte b)
 
void writeShort (short s)
 
void writeShortNL (short s)
 
void writeType (short s)
 
void writeTypeNL (short s)
 
void writeInt (int i)
 
void writeIntNL (int i)
 
void writeType (int i)
 
void writeTypeNL (int i)
 
void writeLong (LONG_INT l)
 
void writeLongNL (LONG_INT l)
 
void writeType (LONG_INT l)
 
void writeTypeNL (LONG_INT l)
 
void writeFloat (float f)
 
void writeFloatNL (float f)
 
void writeType (float f)
 
void writeTypeNL (float f)
 
void writeDouble (double d)
 
void writeDoubleNL (double d)
 
void writeType (double d)
 
void writeTypeNL (double d)
 
void writeNL ()
 

Detailed Description

Opens ascii file for read and write access.

Opens ascii file for read and write access. The read portion is configured to parse generically formatted ascii files from an input stream.

Functionality is provided to read elemental, strings, booleans, bytes, shorts, ints, longs, floats, or doubles, as-well-as array input forms of each (except strings). Alternatively, indivdual lines can be read and parsed by the caller if desired. To perform elemental reads a tokenized scanner is provided that must be configured by the user with a White-Space (WS) definition. The WS delimiters default to a space, tab, and a comma. A single comment line delimiter and block comment start and end delimiters can also be set by the caller. These default to "//", "slash-*", and '*-slash" respectively.

Definition at line 82 of file IFStreamAscii.h.

Constructor & Destructor Documentation

◆ IFStreamAscii()

geotess::IFStreamAscii::IFStreamAscii ( )
inline

Default constructor.

Definition at line 174 of file IFStreamAscii.h.

◆ ~IFStreamAscii()

virtual geotess::IFStreamAscii::~IFStreamAscii ( )
inlinevirtual

Destructor.

Definition at line 186 of file IFStreamAscii.h.

Member Function Documentation

◆ close()

void geotess::IFStreamAscii::close ( )
inline

Close the input stream if it is open.

Definition at line 202 of file IFStreamAscii.h.

◆ flush()

void geotess::IFStreamAscii::flush ( )
inline

Close the input stream if it is open.

Definition at line 213 of file IFStreamAscii.h.

◆ getBeginBlockCommentDelimiter()

const string& geotess::IFStreamAscii::getBeginBlockCommentDelimiter ( ) const
inline

Return the begin block comment delimiter string.

Definition at line 354 of file IFStreamAscii.h.

◆ getBlankLinesRead()

int geotess::IFStreamAscii::getBlankLinesRead ( ) const
inline

Return the current number of blank lines read from the input stream.

Definition at line 394 of file IFStreamAscii.h.

◆ getBlockCommentLinesRead()

int geotess::IFStreamAscii::getBlockCommentLinesRead ( ) const
inline

Return the current number of block comment lines read from the input stream.

Definition at line 410 of file IFStreamAscii.h.

◆ getBytesRead()

int geotess::IFStreamAscii::getBytesRead ( ) const
inline

Return the current number of bytes read from the input stream.

Definition at line 418 of file IFStreamAscii.h.

◆ getCommentDelimiter()

const string& geotess::IFStreamAscii::getCommentDelimiter ( ) const
inline

Return the comment delimiter string.

Definition at line 327 of file IFStreamAscii.h.

◆ getCommentLinesRead()

int geotess::IFStreamAscii::getCommentLinesRead ( ) const
inline

Return the current number of comment lines read from the input stream.

Definition at line 402 of file IFStreamAscii.h.

◆ getDataLinesRead()

int geotess::IFStreamAscii::getDataLinesRead ( ) const
inline

Return the current number of data lines read from the input stream.

Definition at line 386 of file IFStreamAscii.h.

◆ getEndBlockCommentDelimiter()

const string& geotess::IFStreamAscii::getEndBlockCommentDelimiter ( ) const
inline

Return the end block comment delimiter string.

Definition at line 370 of file IFStreamAscii.h.

◆ getFileName()

const string& geotess::IFStreamAscii::getFileName ( ) const
inline

Return the opened file name.

Definition at line 255 of file IFStreamAscii.h.

◆ getLine()

void geotess::IFStreamAscii::getLine ( string &  buf)

Returns the next line in the input stream in the string buf.

◆ getline()

void geotess::IFStreamAscii::getline ( string &  s)
inline

Read a single line from the underlying istream. Added by sballar 2013-03-22.

Definition at line 169 of file IFStreamAscii.h.

◆ getStringDelimiter()

const string& geotess::IFStreamAscii::getStringDelimiter ( ) const
inline

Return the string delimiter string.

Definition at line 311 of file IFStreamAscii.h.

◆ getTotalLinesRead()

int geotess::IFStreamAscii::getTotalLinesRead ( ) const
inline

Return the current number of total lines read from the input stream.

Definition at line 378 of file IFStreamAscii.h.

◆ getWhitespaceDelimiters()

const string& geotess::IFStreamAscii::getWhitespaceDelimiters ( ) const
inline

Return the whitespace delimiter string.

Definition at line 295 of file IFStreamAscii.h.

◆ isEOF()

bool geotess::IFStreamAscii::isEOF ( ) const
inline

Returns true if EOF is reached.

Definition at line 609 of file IFStreamAscii.h.

◆ isOpen()

bool geotess::IFStreamAscii::isOpen ( )
inline

Returns true if the stream is open.

Definition at line 197 of file IFStreamAscii.h.

◆ next()

bool geotess::IFStreamAscii::next ( )
inline

Skips to the next token.

Read the next string. Return true if SUCCESSFUL

Definition at line 635 of file IFStreamAscii.h.

◆ openForRead()

void geotess::IFStreamAscii::openForRead ( const string &  fn)

Open stream for read or write access.

◆ openForWrite()

void geotess::IFStreamAscii::openForWrite ( const string &  fn)

◆ read()

bool geotess::IFStreamAscii::read ( string &  token)
inline

Reads the next token (string) from the input file stream. If eof() occurs false is returned. Otherwise true is returned.

Reads and returns a single token from the stream.

The new token is contained in the input string reference token. The function returns true if successful. If eof() is reached false is returned.

Definition at line 577 of file IFStreamAscii.h.

◆ readByte() [1/2]

byte geotess::IFStreamAscii::readByte ( )
inline

Read and return the next byte.

Definition at line 644 of file IFStreamAscii.h.

◆ readByte() [2/2]

bool geotess::IFStreamAscii::readByte ( byte b)
inline

Read the next byte. Return true if SUCCESSFUL

Definition at line 654 of file IFStreamAscii.h.

◆ readDouble() [1/2]

double geotess::IFStreamAscii::readDouble ( )
inline

Read and return the next double.

Definition at line 829 of file IFStreamAscii.h.

◆ readDouble() [2/2]

bool geotess::IFStreamAscii::readDouble ( double &  d)
inline

Read the next double. Return true if SUCCESSFUL

Definition at line 839 of file IFStreamAscii.h.

◆ readFloat() [1/2]

float geotess::IFStreamAscii::readFloat ( )
inline

Read and return the next float.

Definition at line 792 of file IFStreamAscii.h.

◆ readFloat() [2/2]

bool geotess::IFStreamAscii::readFloat ( float &  f)
inline

Read the next float. Return true if SUCCESSFUL

Definition at line 802 of file IFStreamAscii.h.

◆ readInteger() [1/2]

int geotess::IFStreamAscii::readInteger ( )
inline

Read and return the next int.

Definition at line 718 of file IFStreamAscii.h.

◆ readInteger() [2/2]

bool geotess::IFStreamAscii::readInteger ( int &  i)
inline

Read the next int. Return true if SUCCESSFUL

Definition at line 728 of file IFStreamAscii.h.

◆ readLine()

bool geotess::IFStreamAscii::readLine ( string &  ln)

Read a new line into ln from the stream. If eof() then return false. Otherwise return true.

◆ readLong() [1/2]

LONG_INT geotess::IFStreamAscii::readLong ( )
inline

Read and return the next long.

Definition at line 755 of file IFStreamAscii.h.

◆ readLong() [2/2]

bool geotess::IFStreamAscii::readLong ( LONG_INT l)
inline

Read the next long. Return true if SUCCESSFUL

Definition at line 765 of file IFStreamAscii.h.

◆ readShort() [1/2]

short geotess::IFStreamAscii::readShort ( )
inline

Read and return the next short.

Definition at line 681 of file IFStreamAscii.h.

◆ readShort() [2/2]

bool geotess::IFStreamAscii::readShort ( short &  s)
inline

Read the next short. Return true if SUCCESSFUL

Definition at line 691 of file IFStreamAscii.h.

◆ readString() [1/2]

string geotess::IFStreamAscii::readString ( )
inline

Read the next string. Return true if SUCCESSFUL

Definition at line 617 of file IFStreamAscii.h.

◆ readString() [2/2]

bool geotess::IFStreamAscii::readString ( string &  s)
inline

Read the next string. Return true if SUCCESSFUL

Definition at line 627 of file IFStreamAscii.h.

◆ readType() [1/6]

bool geotess::IFStreamAscii::readType ( byte b)
inline

Read the next byte. Return true if SUCCESSFUL

Definition at line 451 of file IFStreamAscii.h.

◆ readType() [2/6]

bool geotess::IFStreamAscii::readType ( double &  d)
inline

Read the next double. Return true if SUCCESSFUL

Definition at line 526 of file IFStreamAscii.h.

◆ readType() [3/6]

bool geotess::IFStreamAscii::readType ( float &  f)
inline

Read the next float. Return true if SUCCESSFUL

Definition at line 511 of file IFStreamAscii.h.

◆ readType() [4/6]

bool geotess::IFStreamAscii::readType ( int &  i)
inline

Read the next int. Return true if SUCCESSFUL

Definition at line 481 of file IFStreamAscii.h.

◆ readType() [5/6]

bool geotess::IFStreamAscii::readType ( LONG_INT l)
inline

Read the next long. Return true if SUCCESSFUL

Definition at line 496 of file IFStreamAscii.h.

◆ readType() [6/6]

bool geotess::IFStreamAscii::readType ( short &  s)
inline

Read the next short. Return true if SUCCESSFUL

Definition at line 466 of file IFStreamAscii.h.

◆ resetPos()

void geotess::IFStreamAscii::resetPos ( )
inline

Resets the read stream position to the beginning of the file. The reset only occurs if the stream is currently open. Otherwise, no action occurs. The ascii stream can only be set to the beginning for read access by closing the file and reopening again for read access.

Definition at line 225 of file IFStreamAscii.h.

◆ resetReader()

void geotess::IFStreamAscii::resetReader ( )

Resets all parameters back to their initial state (excluding delimiters).

◆ setBeginBlockCommentDelimiter()

void geotess::IFStreamAscii::setBeginBlockCommentDelimiter ( const string &  begBlkCmntDelim)
inline

Set the begin block comment delimiter string.

Definition at line 346 of file IFStreamAscii.h.

◆ setBlockCommentDelimiters()

void geotess::IFStreamAscii::setBlockCommentDelimiters ( const string &  begBlk,
const string &  endBlk 
)
inline

Sets the begin and end block comment strings for this IFStreamAscii object.

Definition at line 336 of file IFStreamAscii.h.

◆ setCommentDelimiter()

void geotess::IFStreamAscii::setCommentDelimiter ( const string &  cmntDelim)
inline

Set the comment delimiter string.

Definition at line 319 of file IFStreamAscii.h.

◆ setDefaultDelimiters()

void geotess::IFStreamAscii::setDefaultDelimiters ( )

Sets the default delimiter settings.

◆ setDelimiters()

void geotess::IFStreamAscii::setDelimiters ( const string &  wspcDelims,
const string &  strgDelim,
const string &  cmntDelim,
const string &  begBlk,
const string &  endBlk 
)
inline

Sets the whitespace, string, comment, and block comment delimiters for this IFStreamAscii object.

Definition at line 271 of file IFStreamAscii.h.

◆ setEndBlockCommentDelimiter()

void geotess::IFStreamAscii::setEndBlockCommentDelimiter ( const string &  endBlkCmntDelim)
inline

Set the end block comment delimiter string.

Definition at line 362 of file IFStreamAscii.h.

◆ setStringDelimiter()

void geotess::IFStreamAscii::setStringDelimiter ( const string &  strgDelim)
inline

Set the string delimiter string.

Definition at line 303 of file IFStreamAscii.h.

◆ setWhitespaceDelimiters()

void geotess::IFStreamAscii::setWhitespaceDelimiters ( const string &  wsDelims)
inline

Set the whitespace delimiter string.

Definition at line 287 of file IFStreamAscii.h.

◆ tokenize()

void geotess::IFStreamAscii::tokenize ( const string &  str,
vector< string > &  tokens 
)

Tokenize the input string (str) and place the tokens into the input array list.

◆ writeBool()

void geotess::IFStreamAscii::writeBool ( bool  b)
inline

Definition at line 539 of file IFStreamAscii.h.

◆ writeBoolNL()

void geotess::IFStreamAscii::writeBoolNL ( bool  b)
inline

Definition at line 540 of file IFStreamAscii.h.

◆ writeByte()

void geotess::IFStreamAscii::writeByte ( byte  b)
inline

Definition at line 543 of file IFStreamAscii.h.

◆ writeByteNL()

void geotess::IFStreamAscii::writeByteNL ( byte  b)
inline

Definition at line 544 of file IFStreamAscii.h.

◆ writeDouble()

void geotess::IFStreamAscii::writeDouble ( double  d)
inline

Definition at line 563 of file IFStreamAscii.h.

◆ writeDoubleNL()

void geotess::IFStreamAscii::writeDoubleNL ( double  d)
inline

Definition at line 564 of file IFStreamAscii.h.

◆ writeFloat()

void geotess::IFStreamAscii::writeFloat ( float  f)
inline

Definition at line 559 of file IFStreamAscii.h.

◆ writeFloatNL()

void geotess::IFStreamAscii::writeFloatNL ( float  f)
inline

Definition at line 560 of file IFStreamAscii.h.

◆ writeInt()

void geotess::IFStreamAscii::writeInt ( int  i)
inline

Definition at line 551 of file IFStreamAscii.h.

◆ writeIntNL()

void geotess::IFStreamAscii::writeIntNL ( int  i)
inline

Definition at line 552 of file IFStreamAscii.h.

◆ writeLong()

void geotess::IFStreamAscii::writeLong ( LONG_INT  l)
inline

Definition at line 555 of file IFStreamAscii.h.

◆ writeLongNL()

void geotess::IFStreamAscii::writeLongNL ( LONG_INT  l)
inline

Definition at line 556 of file IFStreamAscii.h.

◆ writeNL()

void geotess::IFStreamAscii::writeNL ( )
inline

Definition at line 567 of file IFStreamAscii.h.

◆ writeShort()

void geotess::IFStreamAscii::writeShort ( short  s)
inline

Definition at line 547 of file IFStreamAscii.h.

◆ writeShortNL()

void geotess::IFStreamAscii::writeShortNL ( short  s)
inline

Definition at line 548 of file IFStreamAscii.h.

◆ writeString()

void geotess::IFStreamAscii::writeString ( const string &  s)
inline

Definition at line 535 of file IFStreamAscii.h.

◆ writeStringNL()

void geotess::IFStreamAscii::writeStringNL ( const string &  s)
inline

Definition at line 536 of file IFStreamAscii.h.

◆ writeType() [1/8]

void geotess::IFStreamAscii::writeType ( bool  b)
inline

Definition at line 541 of file IFStreamAscii.h.

◆ writeType() [2/8]

void geotess::IFStreamAscii::writeType ( byte  b)
inline

Definition at line 545 of file IFStreamAscii.h.

◆ writeType() [3/8]

void geotess::IFStreamAscii::writeType ( const string &  s)
inline

Definition at line 537 of file IFStreamAscii.h.

◆ writeType() [4/8]

void geotess::IFStreamAscii::writeType ( double  d)
inline

Definition at line 565 of file IFStreamAscii.h.

◆ writeType() [5/8]

void geotess::IFStreamAscii::writeType ( float  f)
inline

Definition at line 561 of file IFStreamAscii.h.

◆ writeType() [6/8]

void geotess::IFStreamAscii::writeType ( int  i)
inline

Definition at line 553 of file IFStreamAscii.h.

◆ writeType() [7/8]

void geotess::IFStreamAscii::writeType ( LONG_INT  l)
inline

Definition at line 557 of file IFStreamAscii.h.

◆ writeType() [8/8]

void geotess::IFStreamAscii::writeType ( short  s)
inline

Definition at line 549 of file IFStreamAscii.h.

◆ writeTypeNL() [1/8]

void geotess::IFStreamAscii::writeTypeNL ( bool  b)
inline

Definition at line 542 of file IFStreamAscii.h.

◆ writeTypeNL() [2/8]

void geotess::IFStreamAscii::writeTypeNL ( byte  b)
inline

Definition at line 546 of file IFStreamAscii.h.

◆ writeTypeNL() [3/8]

void geotess::IFStreamAscii::writeTypeNL ( const string &  s)
inline

Definition at line 538 of file IFStreamAscii.h.

◆ writeTypeNL() [4/8]

void geotess::IFStreamAscii::writeTypeNL ( double  d)
inline

Definition at line 566 of file IFStreamAscii.h.

◆ writeTypeNL() [5/8]

void geotess::IFStreamAscii::writeTypeNL ( float  f)
inline

Definition at line 562 of file IFStreamAscii.h.

◆ writeTypeNL() [6/8]

void geotess::IFStreamAscii::writeTypeNL ( int  i)
inline

Definition at line 554 of file IFStreamAscii.h.

◆ writeTypeNL() [7/8]

void geotess::IFStreamAscii::writeTypeNL ( LONG_INT  l)
inline

Definition at line 558 of file IFStreamAscii.h.

◆ writeTypeNL() [8/8]

void geotess::IFStreamAscii::writeTypeNL ( short  s)
inline

Definition at line 550 of file IFStreamAscii.h.


The documentation for this class was generated from the following file: