OOFEM 3.0
Loading...
Searching...
No Matches
oofem::OOFEMTXTInputRecord Class Reference

#include <oofemtxtinputrecord.h>

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

Public Member Functions

 OOFEMTXTInputRecord ()
 Constructor. Creates an empty input record.
 OOFEMTXTInputRecord (int linenumber, std ::string source)
 Constructor. Creates the input record corresponding to given string.
 OOFEMTXTInputRecord (const OOFEMTXTInputRecord &)
 Copy constructor.
OOFEMTXTInputRecordoperator= (const OOFEMTXTInputRecord &)
 Assignment operator.
std::shared_ptr< InputRecordclone () const override
void setRecordString (std ::string newStr)
 Sets the record string.
std::string giveRecordAsString () const override
 Returns record string.
std::string giveRecordInTXTFormat () const override
std::string giveLocation () const override
void finish (bool wrn=true) override
 Terminates the current record session and if the flag is true, warning is printed for unscanned tokens.
void giveRecordKeywordField (std ::string &answer, int &value) override
 Reads the record id field (type of record) and its corresponding number.
void giveRecordKeywordField (std ::string &answer) override
 Reads the record id field (type of record).
void giveField (int &answer, InputFieldType id) override
 Reads the integer field value.
void giveField (double &answer, InputFieldType id) override
 Reads the double field value.
void giveField (bool &answer, InputFieldType id) override
 Reads the bool field value.
void giveField (std ::string &answer, InputFieldType id) override
 Reads the string field value.
void giveField (FloatArray &answer, InputFieldType id) override
 Reads the FloatArray field value.
void giveField (IntArray &answer, InputFieldType id) override
 Reads the IntArray field value.
void giveField (FloatMatrix &answer, InputFieldType id) override
 Reads the FloatMatrix field value.
void giveField (std ::vector< std ::string > &answer, InputFieldType id) override
 Reads the vector of strings.
void giveField (Dictionary &answer, InputFieldType id) override
 Reads the Dictionary field value.
void giveField (std ::list< Range > &answer, InputFieldType id) override
 Reads the std::list<Range> field value.
void giveField (ScalarFunction &answer, InputFieldType id) override
 Reads the ScalarFunction field value.
int giveGroupCount (InputFieldType id, const std::string &name, bool optional) override
bool hasChild (InputFieldType id, const std::string &name, bool optional) override
bool hasField (InputFieldType id) override
 Returns true if record contains field identified by idString keyword.
void printYourself () override
 Print input record.
void setLineNumber (int num)
int giveLineNumber () const
void setInputRecordType (DataReader::InputRecordType irt)
Public Member Functions inherited from oofem::InputRecord
 InputRecord ()
 InputRecord (DataReader *reader_)
virtual ~InputRecord ()=default
 Destructor.
std::shared_ptr< InputRecordptr ()
template<typename T>
void giveOptionalField (T &answer, InputFieldType id)
DataReadergiveReader () const
template<typename AnEnum>
void giveField (AnEnum &answer, InputFieldType id)
 Reads enumeration (must be defined via enum-impl.hpp) directly.
void traceField (InputFieldType id, const char *type) const

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)
int readMatrix (const char *helpSource, int r, int c, FloatMatrix &ans)

Protected Attributes

Tokenizer tokenizer
std ::vector< bool > readFlag
std::string record
 Record representation.
int lineNumber
DataReader::InputRecordType inputRecordType =DataReader::IR_unspecified

Additional Inherited Members

static std::string error_msg_with_hints (const std::string &val, const std::map< int, std::vector< std::string > > &v2nn)
static int giveLevenshteinDist (const std::string &word1, const std::string &word2)

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 52 of file oofemtxtinputrecord.h.

Constructor & Destructor Documentation

◆ OOFEMTXTInputRecord() [1/3]

oofem::OOFEMTXTInputRecord::OOFEMTXTInputRecord ( )

Constructor. Creates an empty input record.

Definition at line 54 of file oofemtxtinputrecord.C.

References record, and tokenizer.

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

◆ OOFEMTXTInputRecord() [2/3]

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

Constructor. Creates the input record corresponding to given string.

Definition at line 68 of file oofemtxtinputrecord.C.

References lineNumber, readFlag, record, and tokenizer.

◆ OOFEMTXTInputRecord() [3/3]

oofem::OOFEMTXTInputRecord::OOFEMTXTInputRecord ( const OOFEMTXTInputRecord & src)

Copy constructor.

Definition at line 57 of file oofemtxtinputrecord.C.

References inputRecordType, lineNumber, OOFEMTXTInputRecord(), readFlag, record, and tokenizer.

Member Function Documentation

◆ clone()

std::shared_ptr< InputRecord > oofem::OOFEMTXTInputRecord::clone ( ) const
inlineoverridevirtual

Creates a newly allocated copy of the receiver

Implements oofem::InputRecord.

Definition at line 77 of file oofemtxtinputrecord.h.

◆ finish()

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

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

Implements oofem::InputRecord.

Definition at line 545 of file oofemtxtinputrecord.C.

References OOFEM_WARNING, readFlag, record, and tokenizer.

◆ giveField() [1/11]

void oofem::OOFEMTXTInputRecord::giveField ( bool & answer,
InputFieldType id )
overridevirtual

◆ giveField() [2/11]

void oofem::OOFEMTXTInputRecord::giveField ( Dictionary & answer,
InputFieldType id )
overridevirtual

◆ giveField() [3/11]

void oofem::OOFEMTXTInputRecord::giveField ( double & answer,
InputFieldType id )
overridevirtual

◆ giveField() [4/11]

void oofem::OOFEMTXTInputRecord::giveField ( FloatArray & answer,
InputFieldType id )
overridevirtual

◆ giveField() [5/11]

void oofem::OOFEMTXTInputRecord::giveField ( FloatMatrix & answer,
InputFieldType id )
overridevirtual

◆ giveField() [6/11]

void oofem::OOFEMTXTInputRecord::giveField ( int & answer,
InputFieldType id )
overridevirtual

◆ giveField() [7/11]

void oofem::OOFEMTXTInputRecord::giveField ( IntArray & answer,
InputFieldType id )
overridevirtual

◆ giveField() [8/11]

◆ giveField() [9/11]

void oofem::OOFEMTXTInputRecord::giveField ( std ::list< Range > & answer,
InputFieldType id )
overridevirtual

Reads the std::list<Range> field value.

Implements oofem::InputRecord.

Definition at line 397 of file oofemtxtinputrecord.C.

References giveKeywordIndx(), lineNumber, OOFEM_WARNING, readRange(), setReadFlag(), tokenizer, and oofem::InputRecord::traceField().

◆ giveField() [10/11]

void oofem::OOFEMTXTInputRecord::giveField ( std ::string & answer,
InputFieldType id )
overridevirtual

Reads the string field value.

Implements oofem::InputRecord.

Definition at line 212 of file oofemtxtinputrecord.C.

References giveKeywordIndx(), lineNumber, setReadFlag(), tokenizer, and oofem::InputRecord::traceField().

◆ giveField() [11/11]

void oofem::OOFEMTXTInputRecord::giveField ( std ::vector< std ::string > & answer,
InputFieldType id )
overridevirtual

◆ giveGroupCount()

int oofem::OOFEMTXTInputRecord::giveGroupCount ( InputFieldType id,
const std::string & name,
bool optional )
overridevirtual

Implements oofem::InputRecord.

Definition at line 101 of file oofemtxtinputrecord.C.

References giveField(), and oofem::InputRecord::giveOptionalField().

Referenced by hasChild().

◆ giveKeywordIndx()

int oofem::OOFEMTXTInputRecord::giveKeywordIndx ( const char * kwd)
protected

◆ giveLineNumber()

int oofem::OOFEMTXTInputRecord::giveLineNumber ( ) const
inline

Definition at line 111 of file oofemtxtinputrecord.h.

References lineNumber.

Referenced by giveLocation().

◆ giveLocation()

std::string oofem::OOFEMTXTInputRecord::giveLocation ( ) const
overridevirtual

Implements oofem::InputRecord.

Definition at line 96 of file oofemtxtinputrecord.C.

References giveLineNumber(), and oofem::InputRecord::giveReader().

◆ giveRecordAsString()

std::string oofem::OOFEMTXTInputRecord::giveRecordAsString ( ) const
inlineoverridevirtual

Returns record string.

Implements oofem::InputRecord.

Definition at line 83 of file oofemtxtinputrecord.h.

◆ giveRecordInTXTFormat()

std::string oofem::OOFEMTXTInputRecord::giveRecordInTXTFormat ( ) const
inlineoverridevirtual

Implements oofem::InputRecord.

Definition at line 84 of file oofemtxtinputrecord.h.

◆ giveRecordKeywordField() [1/2]

void oofem::OOFEMTXTInputRecord::giveRecordKeywordField ( std ::string & answer)
overridevirtual

Reads the record id field (type of record).

Implements oofem::InputRecord.

Definition at line 145 of file oofemtxtinputrecord.C.

References lineNumber, setReadFlag(), and tokenizer.

◆ giveRecordKeywordField() [2/2]

void oofem::OOFEMTXTInputRecord::giveRecordKeywordField ( std ::string & answer,
int & value )
overridevirtual

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

Implements oofem::InputRecord.

Definition at line 129 of file oofemtxtinputrecord.C.

References lineNumber, oofem::InputRecord::ptr(), scanInteger(), setReadFlag(), and tokenizer.

◆ hasChild()

bool oofem::OOFEMTXTInputRecord::hasChild ( InputFieldType id,
const std::string & name,
bool optional )
overridevirtual

Implements oofem::InputRecord.

Definition at line 109 of file oofemtxtinputrecord.C.

References giveGroupCount(), and OOFEM_ERROR.

◆ hasField()

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

Returns true if record contains field identified by idString keyword.

Implements oofem::InputRecord.

Definition at line 479 of file oofemtxtinputrecord.C.

References giveKeywordIndx(), setReadFlag(), and oofem::InputRecord::traceField().

◆ operator=()

OOFEMTXTInputRecord & oofem::OOFEMTXTInputRecord::operator= ( const OOFEMTXTInputRecord & src)

Assignment operator.

Definition at line 80 of file oofemtxtinputrecord.C.

References inputRecordType, OOFEMTXTInputRecord(), readFlag, record, and tokenizer.

◆ printYourself()

void oofem::OOFEMTXTInputRecord::printYourself ( )
overridevirtual

Print input record.

Implements oofem::InputRecord.

Definition at line 492 of file oofemtxtinputrecord.C.

References record.

◆ readMatrix()

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 633 of file oofemtxtinputrecord.C.

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

Referenced by giveField().

◆ readRange()

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 585 of file oofemtxtinputrecord.C.

References OOFEM_WARNING.

Referenced by giveField().

◆ scanDouble()

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

Definition at line 515 of file oofemtxtinputrecord.C.

Referenced by giveField(), giveField(), giveField(), giveField(), and readMatrix().

◆ scanInteger()

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

◆ setInputRecordType()

void oofem::OOFEMTXTInputRecord::setInputRecordType ( DataReader::InputRecordType irt)
inline

Definition at line 112 of file oofemtxtinputrecord.h.

References inputRecordType.

◆ setLineNumber()

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

Definition at line 110 of file oofemtxtinputrecord.h.

◆ setReadFlag()

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

◆ setRecordString()

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

Sets the record string.

Definition at line 117 of file oofemtxtinputrecord.C.

References readFlag, record, and tokenizer.

Member Data Documentation

◆ inputRecordType

DataReader::InputRecordType oofem::OOFEMTXTInputRecord::inputRecordType =DataReader::IR_unspecified
protected

Definition at line 66 of file oofemtxtinputrecord.h.

Referenced by OOFEMTXTInputRecord(), operator=(), and setInputRecordType().

◆ lineNumber

◆ readFlag

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

◆ record

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

◆ tokenizer

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 60 of file oofemtxtinputrecord.h.

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


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011