OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::OOFEMTXTInputRecord Class Reference

Class representing the Input Record for OOFEM txt input file format. More...

#include <oofemtxtinputrecord.h>

+ Inheritance diagram for oofem::OOFEMTXTInputRecord:
+ Collaboration diagram for oofem::OOFEMTXTInputRecord:

Public Member Functions

 OOFEMTXTInputRecord ()
 Constructor. Creates an empty input record. More...
 
 OOFEMTXTInputRecord (int linenumber, std::string source)
 Constructor. Creates the input record corresponding to given string. More...
 
 OOFEMTXTInputRecord (const OOFEMTXTInputRecord &)
 Copy constructor. More...
 
virtual ~OOFEMTXTInputRecord ()
 Destructor. More...
 
OOFEMTXTInputRecordoperator= (const OOFEMTXTInputRecord &)
 Assignment operator. More...
 
virtual InputRecordGiveCopy ()
 Creates a newly allocated copy of the receiver. More...
 
void setRecordString (std::string newStr)
 Sets the record string. More...
 
virtual std::string giveRecordAsString () const
 Returns record string. More...
 
void finish (bool wrn=true)
 Terminates the current record session and if the flag is true, warning is printed for unscanned tokens. More...
 
virtual IRResultType giveRecordKeywordField (std::string &answer, int &value)
 Reads the record id field (type of record) and its corresponding number. More...
 
virtual IRResultType giveRecordKeywordField (std::string &answer)
 Reads the record id field (type of record). More...
 
virtual IRResultType giveField (int &answer, InputFieldType id)
 Reads the integer field value. More...
 
virtual IRResultType giveField (double &answer, InputFieldType id)
 Reads the double field value. More...
 
virtual IRResultType giveField (bool &answer, InputFieldType id)
 Reads the bool field value. More...
 
virtual IRResultType giveField (std::string &answer, InputFieldType id)
 Reads the string field value. More...
 
virtual IRResultType giveField (FloatArray &answer, InputFieldType id)
 Reads the FloatArray field value. More...
 
virtual IRResultType giveField (IntArray &answer, InputFieldType id)
 Reads the IntArray field value. More...
 
virtual IRResultType giveField (FloatMatrix &answer, InputFieldType id)
 Reads the FloatMatrix field value. More...
 
virtual IRResultType giveField (std::vector< std::string > &answer, InputFieldType id)
 Reads the vector of strings. More...
 
virtual IRResultType giveField (Dictionary &answer, InputFieldType id)
 Reads the Dictionary field value. More...
 
virtual IRResultType giveField (std::list< Range > &answer, InputFieldType id)
 Reads the std::list<Range> field value. More...
 
virtual IRResultType giveField (ScalarFunction &answer, InputFieldType id)
 Reads the ScalarFunction field value. More...
 
virtual bool hasField (InputFieldType id)
 Returns true if record contains field identified by idString keyword. More...
 
virtual void printYourself ()
 Print input record. More...
 
virtual void report_error (const char *_class, const char *proc, InputFieldType id, IRResultType result, const char *file, int line)
 Prints the error message. More...
 
void setLineNumber (int lineNumber)
 
- Public Member Functions inherited from oofem::InputRecord
 InputRecord ()
 Constructor. Creates an empty input record. More...
 
 InputRecord (const InputRecord &)
 Copy constructor. More...
 
virtual ~InputRecord ()
 Destructor. More...
 
InputRecordoperator= (const InputRecord &)
 Assignment operator. More...
 
const char * strerror (IRResultType)
 Returns error string corresponding to given value of IRResultType type. More...
 
IRResultType giveOptionalField (int &answer, InputFieldType id)
 Reads the integer field value. More...
 
IRResultType giveOptionalField (double &answer, InputFieldType id)
 Reads the double field value. More...
 
IRResultType giveOptionalField (bool &answer, InputFieldType id)
 Reads the bool field value. More...
 
IRResultType giveOptionalField (std::string &answer, InputFieldType id)
 Reads the string field value. More...
 
IRResultType giveOptionalField (FloatArray &answer, InputFieldType id)
 Reads the FloatArray field value. More...
 
IRResultType giveOptionalField (IntArray &answer, InputFieldType id)
 Reads the IntArray field value. More...
 
IRResultType giveOptionalField (FloatMatrix &answer, InputFieldType id)
 Reads the FloatMatrix field value. More...
 
IRResultType giveOptionalField (std::vector< std::string > &answer, InputFieldType id)
 Reads the vector of strings. More...
 
IRResultType giveOptionalField (Dictionary &answer, InputFieldType id)
 Reads the Dictionary field value. More...
 
IRResultType giveOptionalField (std::list< Range > &answer, InputFieldType id)
 Reads the std::list<Range> field value. More...
 
IRResultType giveOptionalField (ScalarFunction &function, InputFieldType id)
 Reads the ScalarFunction field value. More...
 

Protected Member Functions

int giveKeywordIndx (const char *kwd)
 
const char * scanInteger (const char *source, int &value)
 
const char * scanDouble (const char *source, double &value)
 
void setReadFlag (int itok)
 
int readRange (const char **helpSource, int &li, int &hi)
 Reads single range record from input record represented by *helpSource string. More...
 
int readMatrix (const char *helpSource, int r, int c, FloatMatrix &ans)
 Reads single matrix record from input record represented by *helpSource string. More...
 

Protected Attributes

Tokenizer tokenizer
 Tokenizer is used to parse records. More...
 
std::vector< bool > readFlag
 
std::string record
 Record representation. More...
 
int lineNumber
 

Detailed Description

Class representing the Input Record for OOFEM txt input file format.

The input record is represented as string consisting of several fields.

Definition at line 49 of file oofemtxtinputrecord.h.

Constructor & Destructor Documentation

oofem::OOFEMTXTInputRecord::OOFEMTXTInputRecord ( )

Constructor. Creates an empty input record.

Definition at line 51 of file oofemtxtinputrecord.C.

oofem::OOFEMTXTInputRecord::OOFEMTXTInputRecord ( int  linenumber,
std::string  source 
)

Constructor. Creates the input record corresponding to given string.

Definition at line 65 of file oofemtxtinputrecord.C.

References oofem::Tokenizer::giveNumberOfTokens(), readFlag, record, oofem::Tokenizer::tokenizeLine(), and tokenizer.

oofem::OOFEMTXTInputRecord::OOFEMTXTInputRecord ( const OOFEMTXTInputRecord src)
virtual oofem::OOFEMTXTInputRecord::~OOFEMTXTInputRecord ( )
inlinevirtual

Destructor.

Definition at line 73 of file oofemtxtinputrecord.h.

Member Function Documentation

void oofem::OOFEMTXTInputRecord::finish ( bool  wrn = true)
virtual

Terminates the current record session and if the flag is true, warning is printed for unscanned tokens.

Implements oofem::InputRecord.

Definition at line 520 of file oofemtxtinputrecord.C.

References oofem::Tokenizer::giveNumberOfTokens(), oofem::Tokenizer::giveToken(), OOFEM_WARNING, readFlag, record, and tokenizer.

virtual InputRecord* oofem::OOFEMTXTInputRecord::GiveCopy ( )
inlinevirtual

Creates a newly allocated copy of the receiver.

Implements oofem::InputRecord.

Definition at line 77 of file oofemtxtinputrecord.h.

IRResultType oofem::OOFEMTXTInputRecord::giveField ( int &  answer,
InputFieldType  id 
)
virtual
IRResultType oofem::OOFEMTXTInputRecord::giveField ( double &  answer,
InputFieldType  id 
)
virtual
IRResultType oofem::OOFEMTXTInputRecord::giveField ( bool &  answer,
InputFieldType  id 
)
virtual
IRResultType oofem::OOFEMTXTInputRecord::giveField ( std::string &  answer,
InputFieldType  id 
)
virtual

Reads the string field value.

Implements oofem::InputRecord.

Definition at line 190 of file oofemtxtinputrecord.C.

References giveKeywordIndx(), oofem::Tokenizer::giveToken(), oofem::IRRT_NOTFOUND, oofem::IRRT_OK, setReadFlag(), and tokenizer.

IRResultType oofem::OOFEMTXTInputRecord::giveField ( FloatMatrix answer,
InputFieldType  id 
)
virtual
IRResultType oofem::OOFEMTXTInputRecord::giveField ( std::vector< std::string > &  answer,
InputFieldType  id 
)
virtual
IRResultType oofem::OOFEMTXTInputRecord::giveField ( std::list< Range > &  answer,
InputFieldType  id 
)
virtual
int oofem::OOFEMTXTInputRecord::giveKeywordIndx ( const char *  kwd)
protected
virtual std :: string oofem::OOFEMTXTInputRecord::giveRecordAsString ( ) const
inlinevirtual

Returns record string.

Implements oofem::InputRecord.

Definition at line 83 of file oofemtxtinputrecord.h.

Referenced by report_error().

IRResultType oofem::OOFEMTXTInputRecord::giveRecordKeywordField ( std::string &  answer,
int &  value 
)
virtual

Reads the record id field (type of record) and its corresponding number.

Implements oofem::InputRecord.

Definition at line 103 of file oofemtxtinputrecord.C.

References oofem::Tokenizer::giveNumberOfTokens(), oofem::Tokenizer::giveToken(), oofem::IRRT_BAD_FORMAT, oofem::IRRT_OK, scanInteger(), setReadFlag(), and tokenizer.

IRResultType oofem::OOFEMTXTInputRecord::giveRecordKeywordField ( std::string &  answer)
virtual

Reads the record id field (type of record).

Implements oofem::InputRecord.

Definition at line 121 of file oofemtxtinputrecord.C.

References oofem::Tokenizer::giveNumberOfTokens(), oofem::Tokenizer::giveToken(), oofem::IRRT_BAD_FORMAT, oofem::IRRT_OK, setReadFlag(), and tokenizer.

bool oofem::OOFEMTXTInputRecord::hasField ( InputFieldType  id)
virtual

Returns true if record contains field identified by idString keyword.

Implements oofem::InputRecord.

Definition at line 455 of file oofemtxtinputrecord.C.

References giveKeywordIndx(), and setReadFlag().

OOFEMTXTInputRecord & oofem::OOFEMTXTInputRecord::operator= ( const OOFEMTXTInputRecord src)
void oofem::OOFEMTXTInputRecord::printYourself ( )
virtual

Print input record.

Implements oofem::InputRecord.

Definition at line 467 of file oofemtxtinputrecord.C.

References record.

int oofem::OOFEMTXTInputRecord::readMatrix ( const char *  helpSource,
int  r,
int  c,
FloatMatrix ans 
)
protected

Reads single matrix record from input record represented by *helpSource string.

Parameters
helpSourcePointer to current string position, on return helpSource points to next character after reading range record.
rMatrix rows.
cMatrix columns.
ansFloat matrix.
Returns
Nonzero on success.

Definition at line 608 of file oofemtxtinputrecord.C.

References oofem::FloatMatrix::at(), oofem::FloatMatrix::clear(), OOFEM_WARNING, oofem::FloatMatrix::resize(), and scanDouble().

Referenced by giveField().

int oofem::OOFEMTXTInputRecord::readRange ( const char **  helpSource,
int &  li,
int &  hi 
)
protected

Reads single range record from input record represented by *helpSource string.

Parameters
helpSourcePointer to current string position, on return helpSource points to next character after reading range record.
liStarting range index.
hiEnd range index.
Returns
Nonzero on success.

Definition at line 560 of file oofemtxtinputrecord.C.

References OOFEM_WARNING.

Referenced by giveField().

void oofem::OOFEMTXTInputRecord::report_error ( const char *  _class,
const char *  proc,
InputFieldType  id,
IRResultType  result,
const char *  file,
int  line 
)
virtual

Prints the error message.

Todo:
We should never directly exit when dealing with user input.

Implements oofem::InputRecord.

Definition at line 668 of file oofemtxtinputrecord.C.

References giveRecordAsString(), lineNumber, oofem::Logger::LOG_LEVEL_ERROR, OOFEM_EXIT, oofem::oofem_logger, oofem::InputRecord::strerror(), and oofem::Logger::writeELogMsg().

const char * oofem::OOFEMTXTInputRecord::scanDouble ( const char *  source,
double &  value 
)
protected

Definition at line 490 of file oofemtxtinputrecord.C.

Referenced by giveField(), and readMatrix().

const char * oofem::OOFEMTXTInputRecord::scanInteger ( const char *  source,
int &  value 
)
protected

Definition at line 473 of file oofemtxtinputrecord.C.

Referenced by giveField(), and giveRecordKeywordField().

void oofem::OOFEMTXTInputRecord::setLineNumber ( int  lineNumber)
inline

Definition at line 107 of file oofemtxtinputrecord.h.

void oofem::OOFEMTXTInputRecord::setReadFlag ( int  itok)
inlineprotected

Definition at line 113 of file oofemtxtinputrecord.h.

Referenced by giveField(), giveRecordKeywordField(), and hasField().

void oofem::OOFEMTXTInputRecord::setRecordString ( std::string  newStr)

Sets the record string.

Definition at line 91 of file oofemtxtinputrecord.C.

References oofem::Tokenizer::giveNumberOfTokens(), readFlag, record, oofem::Tokenizer::tokenizeLine(), and tokenizer.

Member Data Documentation

int oofem::OOFEMTXTInputRecord::lineNumber
protected

Definition at line 63 of file oofemtxtinputrecord.h.

Referenced by report_error().

std :: vector< bool > oofem::OOFEMTXTInputRecord::readFlag
protected

Definition at line 58 of file oofemtxtinputrecord.h.

Referenced by finish(), OOFEMTXTInputRecord(), operator=(), and setRecordString().

std :: string oofem::OOFEMTXTInputRecord::record
protected

Record representation.

Definition at line 61 of file oofemtxtinputrecord.h.

Referenced by finish(), OOFEMTXTInputRecord(), operator=(), printYourself(), and setRecordString().

Tokenizer oofem::OOFEMTXTInputRecord::tokenizer
protected

Tokenizer is used to parse records.

This also enables to perform additional check for input records, since unread fields can be detected

Definition at line 57 of file oofemtxtinputrecord.h.

Referenced by finish(), giveField(), giveKeywordIndx(), giveRecordKeywordField(), OOFEMTXTInputRecord(), operator=(), and setRecordString().


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

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:39 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011