61 int ntok =
tokenizer.giveNumberOfTokens();
63 for (
int i = 0; i < ntok; i++ ) {
68OOFEMTXTInputRecord :: OOFEMTXTInputRecord(
int linenumber, std :: string source) :
tokenizer(),
72 int ntok =
tokenizer.giveNumberOfTokens();
74 for (
int i = 0; i < ntok; i++ ) {
85 int ntok =
tokenizer.giveNumberOfTokens();
87 for (
int i = 0; i < ntok; i++ ) {
101OOFEMTXTInputRecord :: giveGroupCount(
InputFieldType id,
const std::string& name,
bool optional){
109OOFEMTXTInputRecord :: hasChild(
InputFieldType id,
const std::string& name,
bool optional){
110 if(
id[0]==
'\0')
return true;
112 if(count>1)
OOFEM_ERROR(
"Number of '%s' children (%s) must be 0 or 1 (not %d)",name.c_str(),
id,count);
117OOFEMTXTInputRecord :: setRecordString(std :: string newRec)
119 this->
record = std :: move(newRec);
121 int ntok =
tokenizer.giveNumberOfTokens();
123 for (
int i = 0; i < ntok; i++ ) {
129OOFEMTXTInputRecord :: giveRecordKeywordField(std :: string &answer,
int &value)
131 if (
tokenizer.giveNumberOfTokens() > 0 ) {
132 answer = std :: string(
tokenizer.giveToken(1) );
135 if (
ptr ==
nullptr || *
ptr != 0 ) {
145OOFEMTXTInputRecord :: giveRecordKeywordField(std :: string &answer)
147 if (
tokenizer.giveNumberOfTokens() > 0 ) {
148 answer = std :: string(
tokenizer.giveToken(1) );
162 if (
ptr ==
nullptr || *
ptr != 0 ) {
180 if (
ptr ==
nullptr || *
ptr != 0 ) {
199 if (
ptr ==
nullptr || *
ptr != 0 ) {
227 const char *_token =
tokenizer.giveToken(indx);
229 answer = std :: string(
tokenizer.giveToken(indx) );
246 if (
ptr ==
nullptr || *
ptr != 0) {
253 for (
int i = 1; i <= size; i++ ) {
256 if (
ptr ==
nullptr || *
ptr != 0 ) {
260 answer.
at(i) = value;
278 if (
ptr ==
nullptr || *
ptr != 0 ) {
285 for (
int i = 1; i <= size; i++ ) {
288 if (
ptr ==
nullptr || *
ptr != 0 ) {
292 answer.
at(i) = value;
311 if (
ptr ==
nullptr || *
ptr != 0 ) {
317 if (
ptr ==
nullptr || *
ptr != 0 ) {
334OOFEMTXTInputRecord :: giveField(std :: vector< std :: string > &answer,
InputFieldType id)
342 if (
ptr ==
nullptr || *
ptr != 0 ) {
345 answer.reserve(size);
347 for (
int i = 1; i <= size; i++ ) {
348 answer.push_back(
tokenizer.giveToken(indx + i) );
366 if (
ptr ==
nullptr || *
ptr != 0 ) {
373 for (
int i = 1; i <= size; i++ ) {
375 const char * token =
tokenizer.giveToken(++indx);
377 if ( ptr1 ==
nullptr || *ptr1 != 0 ) {
384 if (
ptr ==
nullptr || *
ptr != 0 ) {
389 answer.
add(key, value);
404 const char *rec =
tokenizer.giveToken(++indx);
405 if ( * rec !=
'{' ) {
416 list.push_back(range);
420 while ( isspace(* rec) ) {
425 if ( * rec !=
'}' ) {
445 if ( * rec ==
'@' ) {
449 if (
ptr ==
nullptr || *
ptr != 0 ) {
454 }
else if ( * rec ==
'$' ) {
458 expr = std :: string(
tokenizer.giveToken(indx) );
460 std :: string _v = expr.substr(1, expr.size() - 2);
466 if (
ptr ==
nullptr || *
ptr != 0 ) {
488 return ( indx > 0 ) ? true :
false;
492OOFEMTXTInputRecord :: printYourself()
494 printf(
"%s", this->
record.c_str() );
498OOFEMTXTInputRecord :: scanInteger(
const char *source,
int &value)
505 if ( source ==
nullptr ) {
510 value = strtol(source, & endptr, 10);
515OOFEMTXTInputRecord :: scanDouble(
const char *source,
double &value)
522 if ( source ==
nullptr ) {
527 value = strtod(source, & endptr);
532OOFEMTXTInputRecord :: giveKeywordIndx(
const char *kwd)
534 int ntokens =
tokenizer.giveNumberOfTokens();
535 for (
int i = 1; i <= ntokens; i++ ) {
536 if ( strcmp( kwd,
tokenizer.giveToken(i) ) == 0 ) {
545OOFEMTXTInputRecord :: finish(
bool wrn)
551 std :: ostringstream buff;
552 bool pf =
true, wf =
false;
553 int ntokens =
tokenizer.giveNumberOfTokens();
554 for (
int i = 0; i < ntokens; i++ ) {
558 buff <<
"Unread token(s) detected in the following record\n\"";
559 for (
int j = 0; j < 40; j++ ) {
560 if ( this->
record [ j ] ==
'\n' || this->
record [ j ] ==
'\0' ) {
563 buff << this->
record [ j ];
566 if ( this->
record.size() > 41 ) {
575 buff <<
"[" <<
tokenizer.giveToken(i + 1) <<
"]";
585OOFEMTXTInputRecord :: readRange(
const char **helpSource,
int &li,
int &hi)
589 while ( isspace(* * helpSource) ) {
594 if ( isdigit(* * helpSource) ) {
596 li = hi = strtol(* helpSource, & endptr, 10);
597 * helpSource = endptr;
599 }
else if ( * * helpSource ==
'(' ) {
603 li = strtol(* helpSource, & endptr, 10);
604 * helpSource = endptr;
606 if ( * * helpSource !=
' ' && * * helpSource !=
'\t' ) {
612 hi = strtol(* helpSource, & endptr, 10);
613 * helpSource = endptr;
615 while ( isspace(* * helpSource) ) {
620 if ( * * helpSource ==
')' ) {
633OOFEMTXTInputRecord :: readMatrix(
const char *helpSource,
int r,
int c,
FloatMatrix &ans)
635 const char *endptr = helpSource;
637 if ( helpSource == NULL ) {
644 while ( isspace(* endptr) ) {
648 if ( * endptr ==
'{' ) {
652 for (
int i = 1; i <= r; i++ ) {
653 for (
int j = 1; j <= c; j++ ) {
659 while ( isspace(* endptr) ) {
664 if ( * endptr ==
';' ) {
674 while ( isspace(* endptr) ) {
679 if ( * endptr ==
'}' ) {
690#ifdef _USE_TRACE_FIELDS
692 if(!InputRecord::TraceFields::active)
return;
700 InputRecord::TraceFields::write(tag+
";"+
id+
";"+type);
void clear()
Clears the receiver.
Pair * add(int aKey, double value)
void resize(Index rows, Index cols)
*Sets size of receiver to be an empty matrix It will have zero rows and zero columns size void clear()
double at(std::size_t i, std::size_t j) const
void setSimpleExpression(std ::string &val)
void setReference(int val)
void setValue(double val)
#define OOFEM_WARNING(...)
const char * InputFieldType
Identifier of fields in input records.