38static constexpr const unsigned errLen = 80;
54inline bool validVariableChar(
char c)
60inline void inplaceTrimRight(std::string&
s)
62 auto end =
s.length();
111char Foam::ISstream::nextValid()
135 (void) getLine(
nullptr,
'\n');
140 if (!seekCommentEnd_Cstyle())
178 constexpr const unsigned bufLen = 8000;
179 static char buf[bufLen];
194 str.append(buf, nChar);
207 str.append(buf, nChar);
214 str.append(buf, nChar);
215 strncpy(buf, str.c_str(),
errLen);
219 <<
"Problem while reading verbatim \"" << buf
220 <<
"...\" [after " << str.length() <<
" chars]\n"
241 constexpr const unsigned bufLen = 1024;
242 static char buf[bufLen];
259 int lookahead = is.
peek();
269 <<
"Ignoring empty ${}" <<
endl;
287 str.append(buf, nChar);
305 (void) is.
getLine(
nullptr,
'\n');
326 str.append(buf, nChar);
334 str.append(buf, nChar);
335 strncpy(buf, str.c_str(),
errLen);
339 <<
"stream terminated while reading variable '" << buf
340 <<
"...' [after " << str.length() <<
" chars]\n"
345 else if (validVariableChar(c))
351 if (!validVariableChar(c))
376 str.append(buf, nChar);
381 str.append(buf, nChar);
385 strncpy(buf, str.c_str(),
errLen);
389 <<
"Missing " << depth
390 <<
" closing ')' while parsing" <<
nl <<
nl
403 <<
"Ignoring bad variable name: " << buf <<
nl <<
endl;
417 const bool stripComments,
418 const char delimOpen,
419 const char delimClose
422 constexpr const unsigned bufLen = 1024;
423 static char buf[bufLen];
432 if ((str.empty() && !nChar) &&
isspace(c))
445 else if (c == delimClose)
452 str.append(buf, nChar);
453 inplaceTrimRight(str);
457 else if (stripComments && c ==
'/')
471 (void) is.
getLine(
nullptr,
'\n');
492 str.append(buf, nChar);
500 str.append(buf, nChar);
501 inplaceTrimRight(str);
515 const bool stripComments
532 constexpr const unsigned bufLen = 128;
533 static char buf[bufLen];
547 char c = nextValid();
605 int lookahead = peek();
625 else if (
read(nextC).bad())
655 <<
"Invalid sequence #" << char(nextC)
656 <<
" ... ignoring the leading '#'" <<
nl <<
endl;
666 if (
read(nextC).bad())
701 case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
702 case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
704 label labelVal = (c !=
'.');
726 labelVal = isdigit(c);
733 buf[bufLen-1] =
'\0';
736 <<
"Number '" << buf <<
"...'\n"
737 <<
" is too long (max. " << bufLen <<
" characters)"
746 setState(is_.rdstate());
755 if (nChar == 1 && buf[0] ==
'-')
760 else if (labelVal &&
Foam::read(buf, labelVal))
768 if (readScalar(buf, scalarVal))
817 constexpr const unsigned bufLen = 1024;
818 static char buf[bufLen];
852 str.append(buf, nChar);
857 str.append(buf, nChar);
863 strncpy(buf, str.c_str(),
errLen);
867 <<
"Problem while reading word '" << buf
868 <<
"...' [after " << str.length() <<
" chars]\n"
877 <<
"Invalid first character found : " << c
882 strncpy(buf, str.c_str(),
errLen);
886 <<
"Missing " << depth
887 <<
" closing ')' while parsing" <<
nl <<
nl
897 constexpr const unsigned bufLen = 1024;
898 static char buf[bufLen];
906 <<
"cannot read start of string"
916 <<
"Incorrect start of string character found : " << c
923 bool escaped =
false;
940 str.append(buf, nChar);
953 str.append(buf, nChar);
954 strncpy(buf, str.c_str(),
errLen);
958 <<
"Unescaped '\\n' while reading string \"" << buf
959 <<
"...\" [after " << str.length() <<
" chars]\n"
974 str.append(buf, nChar-1);
984 str.append(buf, nChar);
985 strncpy(buf, str.c_str(),
errLen);
989 <<
"Problem while reading string \"" << buf <<
"...\""
999 setState(is_.rdstate());
1007 setState(is_.rdstate());
1015 setState(is_.rdstate());
1023 readRaw(buf, count);
1032 is_.
read(buf, count);
1033 setState(is_.rdstate());
1044 <<
"stream format not binary"
1048 readBegin(
"binaryBlock");
1049 setState(is_.rdstate());
1057 readEnd(
"binaryBlock");
1058 setState(is_.rdstate());
1068 stdStream().clear();
1072 stdStream().rdbuf()->pubseekpos(0, std::ios_base::in);
1086 return is_.flags(
f);
static constexpr const unsigned errLen
bool bad() const noexcept
True if stream is corrupted.
Generic input stream using a standard (STL) stream.
ISstream & get(char &c)
Raw, low-level get character function.
virtual bool endRawRead()
End of low-level raw binary read.
ISstream & putback(const char c)
Raw, low-level putback character function.
int peek()
Raw, low-level peek function.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
bool seekCommentEnd_Cstyle()
Discard until end of C-style comment '*/'.
virtual void rewind()
Rewind the stream so that it may be read again.
bool continueReadUntilRightBrace(std::string &str, const bool stripComments=true)
virtual bool beginRawRead()
Start of low-level raw binary read.
virtual Istream & readRaw(char *data, std::streamsize count)
Low-level raw binary read.
virtual ios_base::fmtflags flags() const
Return flags of output stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool getBack(token &tok)
Get the put-back token if there is one.
virtual Istream & read(token &)=0
Return next token from stream.
virtual bool read()
Re-read model coefficients if they have changed.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
bool valid() const
True if all internal ids are non-negative.
A token holds an item read from Istream.
tokenType
Enumeration defining the types of token.
@ ERROR
Token error encountered.
label lineNumber() const noexcept
The line number for the token.
punctuationToken
Standard punctuation tokens (a character)
@ DIVIDE
Divide [isseparator].
@ BEGIN_BLOCK
Begin block [isseparator].
@ BEGIN_SQR
Begin dimensions [isseparator].
@ COLON
Colon [isseparator].
@ END_BLOCK
End block [isseparator].
@ HASH
Hash - directive or start verbatim string.
@ ASSIGN
Assignment/equals [isseparator].
@ END_STATEMENT
End entry [isseparator].
@ BEGIN_LIST
Begin list [isseparator].
@ PLUS
Addition [isseparator].
@ DOLLAR
Dollar - start variable or expression.
@ END_LIST
End list [isseparator].
@ END_SQR
End dimensions [isseparator].
@ MULTIPLY
Multiply [isseparator].
@ MINUS
Subtract or start of negative number.
@ COMMA
Comma [isseparator].
void setBad()
Clear token and set to be ERROR.
bool setType(const tokenType tokType) noexcept
Change the token type, for similar types.
bool isCompound() const noexcept
Token is COMPOUND.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
static Foam::word charToWord(char c)
bool read(const char *buf, int32_t &val)
Same as readInt32.
double doubleScalar
A typedef for double.
static ISstream & readVerbatim(ISstream &is, std::string &str)
bool isspace(char c) noexcept
Test for whitespace (C-locale)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static token::tokenType readVariable(ISstream &is, std::string &str, char c)
float floatScalar
A typedef for float.
static bool readUntilBalancedDelimiter(ISstream &is, std::string &str, const bool stripComments, const char delimOpen, const char delimClose)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
word format(conversionProperties.get< word >("format"))