Go to the documentation of this file.
32 static constexpr
const unsigned errLen = 80;
45 static inline bool validVariableChar(
char c)
60 while (
get(c) && isspace(c))
64 if (
bad() || isspace(c))
81 while (
get(c) && c !=
'\n')
90 if (
get(c) && c ==
'*')
147 constexpr
const unsigned maxLen = 1024;
148 static char buf[maxLen];
158 <<
"Invalid first character found : " << c <<
nl;
167 str.assign(buf, nChar);
169 <<
"Truncated variable name : " << str <<
nl;
189 str.append(buf, nChar);
202 str.append(buf, nChar);
210 str.append(buf, nChar);
212 nChar = str.length();
213 if (str.length() >
errLen)
219 <<
"stream terminated while reading variable '"
220 << str.c_str() <<
"...' [" <<
static_cast<int32>(nChar) <<
"]\n";
225 else if (validVariableChar(c))
231 (nChar < maxLen) && get(c)
232 && (validVariableChar(c))
259 <<
"Bad variable name: " << buf <<
nl <<
endl;
267 <<
"variable '" << buf <<
"...'\n"
268 <<
" is too long (max. " <<
static_cast<int32>(maxLen) <<
" characters)";
282 <<
"Problem while reading variable '" << buf <<
"...' after "
283 <<
static_cast<int32>(nChar) <<
" characters\n";
294 <<
"Missing " <<
static_cast<int32>(depth)
295 <<
" closing ')' while parsing" <<
nl <<
nl
300 str.assign(buf, nChar);
310 const word& streamName,
325 setState(is_.rdstate());
332 setState(is_.rdstate());
334 if (good() && c ==
'\n')
351 std::getline(is_, str, delim);
352 setState(is_.rdstate());
366 setState(is_.rdstate());
368 std::streamsize
count = is_.gcount();
370 if (
count && delim ==
'\n')
391 setState(is_.rdstate());
398 constexpr
const unsigned maxLen = 128;
399 static char buf[maxLen];
413 char c = nextValid();
451 if (readString(val).bad())
466 if (read(nextC).bad())
478 if (readVariable(val).bad())
485 t.
setType(token::tokenType::VARIABLE);
500 case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
501 case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
503 int64 int64Val = (c !=
'.');
525 int64Val = isdigit(c);
532 buf[maxLen-1] =
'\0';
535 <<
"number '" << buf <<
"...'\n"
536 <<
" is too long (max. " <<
537 static_cast<int32>(maxLen) <<
" characters)";
546 setState(is_.rdstate());
555 if (nChar == 1 && buf[0] ==
'-')
560 else if (int64Val &&
readInt64(buf, int64Val))
605 constexpr
const unsigned maxLen = 1024;
606 static char buf[maxLen];
639 <<
"word '" << buf <<
"...'\n"
640 <<
" is too long (max. " <<
641 static_cast<int32>(maxLen) <<
" characters)";
655 <<
"Problem while reading word '" << buf <<
"...' after "
656 <<
static_cast<int32>(nChar) <<
" characters\n";
665 <<
"Invalid first character found : " << c;
671 <<
"Missing " <<
static_cast<int32>(depth)
672 <<
" closing ')' while parsing" <<
nl <<
nl
677 str.assign(buf, nChar);
686 constexpr
const unsigned maxLen = 1024;
687 static char buf[maxLen];
694 <<
"cannot read start of string";
704 <<
"Incorrect start of string character found : " << c;
711 bool escaped =
false;
729 str.assign(buf, nChar);
742 buf[
errLen] = buf[nChar] =
'\0';
745 <<
"found '\\n' while reading string \""
769 <<
"string \"" << buf <<
"...\"\n"
770 <<
" is too long (max. " <<
static_cast<int32>(maxLen) <<
" characters)";
777 buf[
errLen] = buf[nChar] =
'\0';
780 <<
"Problem while reading string \"" << buf <<
"...\"";
789 setState(is_.rdstate());
796 setState(is_.rdstate());
803 setState(is_.rdstate());
810 setState(is_.rdstate());
817 setState(is_.rdstate());
824 setState(is_.rdstate());
831 setState(is_.rdstate());
838 setState(is_.rdstate());
846 setState(is_.rdstate());
853 std::streamsize
count
863 readBegin(
"binaryBlock");
864 is_.read(buffer,
count);
865 readEnd(
"binaryBlock");
867 setState(is_.rdstate());
879 stdStream().rdbuf()->pubseekpos(0, std::ios_base::in);
bool setType(const tokenType tokType)
void readWordToken(token &t)
static constexpr const unsigned errLen
#define warningInFunction
Istream(std::istream &is, const word &streamName, writeFormat wf=ASCII)
@ END_BLOCK
End block [isseparator].
bool readReal(const word &w, real &val)
iOstream & endl(iOstream &os)
Add newline and flush stream.
@ BEGIN_BLOCK
Begin block [isseparator].
bool readInt64(const word &w, int64 &val)
virtual iIstream & readString(word &str) override
unsigned short int uint16
bool bad() const
Return true if stream is corrupted.
Istream & readVariable(word &str)
#define fatalErrorInFunction
INLINE_FUNCTION_H Type max(const Type *first, int32 numElems)
virtual iIstream & read(token &t) override
@ BEGIN_STRING
Begin string with double quote.
@ END_LIST
End list [isseparator].
@ DOLLAR
Dollar - start variable.
auto count(const Vector< T, Allocator > &vec, const T &val)
@ COLON
Colon [isseparator].
@ END_STATEMENT
End entry [isseparator].
bool good() const
Return true if next operation might succeed.
@ SUBTRACT
Subtract or start of negative number.
@ BEGIN_LIST
Begin list [isseparator].
@ BEGIN_SQR
Begin dimensions [isseparator].
@ DIVIDE
Divide [isseparator].
#define ioErrorInFile(fileName, lineNumber)
@ COMMA
Comma [isseparator].
virtual ios_base::fmtflags flags() const
Return flags of stream.
@ END_STRING
End string with double quote.
Istream & putback(const char c)
Istream & getLine(word &str, char delim='\n')
@ END_SQR
End dimensions [isseparator].