Go to the documentation of this file.
37 static constexpr
const unsigned errLen = 80;
52 static inline bool validVariableChar(
char c)
62 char Foam::ISstream::nextValid()
90 while (
get(
c) &&
c !=
'\n')
99 if (
get(
c) &&
c ==
'*')
140 void Foam::ISstream::readWordToken(token& t)
160 constexpr
const unsigned maxLen = 128;
161 static char buf[maxLen];
175 char c = nextValid();
233 if (
read(nextC).bad())
243 if (readVerbatim(
val).bad())
250 t.
setType(token::tokenType::VERBATIMSTRING);
269 if (
read(nextC).bad())
281 if (readVariable(
val).bad())
288 t.
setType(token::tokenType::VARIABLE);
303 case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
304 case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
306 label labelVal = (
c !=
'.');
328 labelVal = isdigit(
c);
335 buf[maxLen-1] =
'\0';
338 <<
"number '" << buf <<
"...'\n"
339 <<
" is too long (max. " << maxLen <<
" characters)"
348 setState(is_.rdstate());
357 if (nChar == 1 && buf[0] ==
'-')
362 else if (labelVal &&
Foam::read(buf, labelVal))
370 if (readScalar(buf, scalarVal))
407 constexpr
const unsigned maxLen = 1024;
408 static char buf[maxLen];
442 <<
"word '" << buf <<
"...'\n"
443 <<
" is too long (max. " << maxLen <<
" characters)"
457 <<
"Problem while reading word '" << buf <<
"...' after "
458 << nChar <<
" characters\n"
467 <<
"Invalid first character found : " <<
c
473 <<
"Missing " << depth
474 <<
" closing ')' while parsing" <<
nl <<
nl
479 str.assign(buf, nChar);
488 constexpr
const unsigned maxLen = 1024;
489 static char buf[maxLen];
496 <<
"cannot read start of string"
506 <<
"Incorrect start of string character found : " <<
c
513 bool escaped =
false;
531 str.assign(buf, nChar);
544 buf[
errLen] = buf[nChar] =
'\0';
547 <<
"found '\\n' while reading string \""
571 <<
"string \"" << buf <<
"...\"\n"
572 <<
" is too long (max. " << maxLen <<
" characters)"
579 buf[
errLen] = buf[nChar] =
'\0';
582 <<
"Problem while reading string \"" << buf <<
"...\""
589 Foam::Istream& Foam::ISstream::readVariable(std::string& str)
591 constexpr
const unsigned maxLen = 1024;
592 static char buf[maxLen];
602 <<
"Invalid first character found : " <<
c <<
nl
611 str.assign(buf, nChar);
614 <<
"Truncated variable name : " << str <<
nl;
634 (nChar < maxLen) && get(
c)
658 else if (validVariableChar(
c))
664 (nChar < maxLen) && get(
c)
665 && (validVariableChar(
c))
692 <<
"Bad variable name: " << buf <<
nl <<
endl;
700 <<
"variable '" << buf <<
"...'\n"
701 <<
" is too long (max. " << maxLen <<
" characters)"
715 <<
"Problem while reading variable '" << buf <<
"...' after "
716 << nChar <<
" characters\n"
725 <<
"Missing " << depth
726 <<
" closing '" << endChar <<
"' while parsing" <<
nl <<
nl
731 str.assign(buf, nChar);
738 Foam::Istream& Foam::ISstream::readVerbatim(std::string& str)
740 constexpr
const unsigned maxLen = 8000;
741 static char buf[maxLen];
756 str.append(buf, nChar);
768 str.append(buf, nChar);
774 buf[
errLen] = buf[nChar] =
'\0';
777 <<
"Problem while reading string \"" << buf <<
"...\""
787 setState(is_.rdstate());
795 setState(is_.rdstate());
803 setState(is_.rdstate());
821 setState(is_.rdstate());
832 <<
"stream format not binary"
836 readBegin(
"binaryBlock");
837 setState(is_.rdstate());
845 readEnd(
"binaryBlock");
846 setState(is_.rdstate());
860 stdStream().rdbuf()->pubseekpos(0, std::ios_base::in);
Subtract or start of negative number.
Assignment/equals [isseparator].
label ListType::const_reference val
double doubleScalar
Floating-point double precision scalar type.
A class for handling words, derived from Foam::string.
float floatScalar
Floating-point single precision scalar type.
bool read(const char *buf, int32_t &val)
Same as readInt32.
End string with double quote.
static Foam::word charToWord(char c)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
virtual void rewind()
Rewind the stream so that it may be read again.
virtual Istream & readRaw(char *data, std::streamsize count)
Low-level raw binary read.
ISstream & get(char &c)
Raw, low-level get character function.
word format(conversionProperties.get< word >("format"))
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual bool endRawRead()
End of low-level raw binary read.
Begin dimensions [isseparator].
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static bool isCompound(const word &name)
Return true if name is a known (registered) compound type.
ISstream & putback(const char c)
Raw, low-level putback character function.
static bool valid(char c)
Is this character valid for a word?
bool bad() const
Return true if stream is corrupted.
End dimensions [isseparator].
Hash - directive or verbatim string.
bool setType(const tokenType variant)
Change the token type, for similar types.
Begin block [isseparator].
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool getBack(token &tok)
Get the put back token if there is one and return true.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
virtual ios_base::fmtflags flags() const
Return flags of output stream.
virtual Istream & read(token &t)
Return next token from stream.
static constexpr const unsigned errLen
const dimensionedScalar c
Speed of light in a vacuum.
static autoPtr< compound > New(const word &type, Istream &is)
Select null constructed.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
label lineNumber() const
The line number for the token.
bool good() const
Return true if next operation might succeed.
virtual bool beginRawRead()
Start of low-level raw binary read.
Begin list [isseparator].
bool isspace(char c)
Test for horizontal whitespace.
Begin string with double quote.
punctuationToken
Standard punctuation tokens (a character)
virtual Istream & read(token &)=0
Return next token from stream.
void setBad()
Clear token and set to be ERROR.