diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index a7d63ab7b8573fb893fc4b46a403bf06a8e9f8e1..67ff84e1201ef6e68f1fa901072a95b8e1a52055 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -250,11 +250,11 @@ Foam::Istream& Foam::UIPstream::read(token& t) } // String - case token::tokenType::VERBATIMSTRING : + case token::tokenType::VERBATIM : { // Recurse to read actual string read(t); - t.setType(token::tokenType::VERBATIMSTRING); + t.setType(token::tokenType::VERBATIM); return *this; } case token::tokenType::VARIABLE : @@ -293,8 +293,8 @@ Foam::Istream& Foam::UIPstream::read(token& t) return *this; } - // floatScalar - case token::tokenType::FLOAT_SCALAR : + // Float + case token::tokenType::FLOAT : { floatScalar val; if (read(val)) @@ -308,8 +308,8 @@ Foam::Istream& Foam::UIPstream::read(token& t) return *this; } - // doubleScalar - case token::tokenType::DOUBLE_SCALAR : + // Double + case token::tokenType::DOUBLE : { doubleScalar val; if (read(val)) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index 88ae3595fd06d347b39a14b0b3ca952c744d59ee..2aaba2327e39b6ca810c3912e7efdeb8d594e790 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -202,9 +202,9 @@ bool Foam::UOPstream::write(const token& tok) return true; } - case token::tokenType::VERBATIMSTRING : + case token::tokenType::VERBATIM : { - writeToBuffer(char(token::tokenType::VERBATIMSTRING)); + writeToBuffer(char(token::tokenType::VERBATIM)); write(tok.stringToken()); return true; @@ -310,7 +310,7 @@ Foam::Ostream& Foam::UOPstream::write(const int64_t val) Foam::Ostream& Foam::UOPstream::write(const floatScalar val) { - writeToBuffer(char(token::tokenType::FLOAT_SCALAR)); + writeToBuffer(char(token::tokenType::FLOAT)); writeToBuffer(val); return *this; } @@ -318,7 +318,7 @@ Foam::Ostream& Foam::UOPstream::write(const floatScalar val) Foam::Ostream& Foam::UOPstream::write(const doubleScalar val) { - writeToBuffer(char(token::tokenType::DOUBLE_SCALAR)); + writeToBuffer(char(token::tokenType::DOUBLE)); writeToBuffer(val); return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index c4fe37baf51318ed0e85c1bea386114600c476d7..a7847bad20ab2e32b6967573b6846eb54743e1bd 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -187,7 +187,7 @@ Foam::Istream& Foam::ISstream::read(token& t) // Analyse input starting with this character. switch (c) { - // Check for punctuation first - same as token::isSeparator + // Check for punctuation first - same as token::isseparator() case token::END_STATEMENT : case token::BEGIN_LIST : @@ -247,7 +247,7 @@ Foam::Istream& Foam::ISstream::read(token& t) else { t = std::move(val); // Move contents to token - t.setType(token::tokenType::VERBATIMSTRING); + t.setType(token::tokenType::VERBATIM); } } else @@ -382,7 +382,6 @@ Foam::Istream& Foam::ISstream::read(token& t) return *this; } - // Should be a word (which can also be a single character) default: { diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index 4085c6964ae8f5bfac184a8080b60559067b0c89..52f1992b51bf5a0bfe503a334832215170536d15 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ bool Foam::OSstream::write(const token& tok) return true; } - case token::tokenType::VERBATIMSTRING : + case token::tokenType::VERBATIM : { write(char(token::HASH)); write(char(token::BEGIN_BLOCK)); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C index aa6e6b8e2791d0df3d2e6238629414e83c6e4e07..82c7c640094d88b801ca775fbd2822876e376c26 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,7 +55,7 @@ Foam::prefixOSstream::prefixOSstream : OSstream(os, name, format, version, compression), printPrefix_(true), - prefix_("") + prefix_() {} @@ -79,7 +80,7 @@ bool Foam::prefixOSstream::write(const token& tok) return true; } - case token::tokenType::VERBATIMSTRING : + case token::tokenType::VERBATIM : { write(char(token::HASH)); write(char(token::BEGIN_BLOCK)); diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H index 44a0143ff147ae7dc97409c5f4865cc9a8dd6786..8405f31223fcf13232baf141c66fc859b280fca1 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.H +++ b/src/OpenFOAM/db/IOstreams/token/token.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,17 +83,22 @@ public: PUNCTUATION, //!< single character punctuation BOOL, //!< boolean type LABEL, //!< label (integer) type - FLOAT_SCALAR, //!< float (single-precision) type - DOUBLE_SCALAR, //!< double (double-precision) type + FLOAT, //!< float (single-precision) type + DOUBLE, //!< double (double-precision) type // Pointer types WORD, //!< A Foam::word STRING, //!< A string VARIABLE, //!< A dictionary \c \$variable (string variant) - VERBATIMSTRING, //!< Verbatim string content + VERBATIM, //!< Verbatim string content COMPOUND, //!< Compound type such as \c List\<label\> etc. - ERROR //!< A token error encountered + ERROR, //!< A token error encountered + + // Aliases + FLOAT_SCALAR = FLOAT, + DOUBLE_SCALAR = DOUBLE, + VERBATIMSTRING = VERBATIM }; @@ -155,7 +160,7 @@ public: public: - //- Runtime type information + //- Declare type-name, virtual type (with debug switch) TypeName("compound"); //- Declare run-time constructor selection table @@ -171,7 +176,7 @@ public: // Constructors - //- Construct null + //- Default construct compound() : empty_(false) @@ -224,7 +229,7 @@ public: { public: - //- Runtime type information + //- Declare type-name, virtual type (with debug switch) TypeName("Compound<T>"); Compound(Istream& is) @@ -302,7 +307,7 @@ public: // Constructors - //- Construct null, initialized to an UNDEFINED token. + //- Default construct, initialized to an UNDEFINED token. inline constexpr token() noexcept; //- Copy construct @@ -343,7 +348,7 @@ public: inline ~token(); - // Static Member Functions + // Static Functions //- Create a bool token. inline static token boolean(bool on); @@ -375,7 +380,7 @@ public: //- Change the token type, for similar types. // This can be used to change between string-like variants // (eg, STRING, VARIABLE, etc) - // To change types entirely (eg, STRING to DOUBLE_SCALAR), + // To change types entirely (eg, STRING to DOUBLE), // use the corresponding assignment operator. // // \return true if the change was successful or no change was required @@ -411,16 +416,16 @@ public: //- Token is LABEL inline bool isLabel() const; - //- Token is FLOAT_SCALAR - inline bool isFloatScalar() const; + //- Token is FLOAT + inline bool isFloat() const; - //- Token is DOUBLE_SCALAR - inline bool isDoubleScalar() const; + //- Token is DOUBLE + inline bool isDouble() const; - //- Token is FLOAT_SCALAR or DOUBLE_SCALAR + //- Token is FLOAT or DOUBLE inline bool isScalar() const; - //- Token is LABEL, FLOAT_SCALAR or DOUBLE_SCALAR + //- Token is LABEL, FLOAT or DOUBLE inline bool isNumber() const; //- Token is WORD @@ -461,21 +466,21 @@ public: inline label labelToken() const; //- Return float value. - // Report FatalIOError and return \b 0 if token is not FLOAT_SCALAR - inline floatScalar floatScalarToken() const; + // Report FatalIOError and return \b 0 if token is not FLOAT + inline floatScalar floatToken() const; //- Return double value. - // Report FatalIOError and return \b 0 if token is not DOUBLE_SCALAR - inline doubleScalar doubleScalarToken() const; + // Report FatalIOError and return \b 0 if token is not DOUBLE + inline doubleScalar doubleToken() const; //- Return float or double value. // Report FatalIOError and return \b 0 if token is not a - // FLOAT_SCALAR or DOUBLE_SCALAR + // FLOAT or DOUBLE inline scalar scalarToken() const; //- Return label, float or double value. // Report FatalIOError and return \b 0 if token is not a - // LABEL, FLOAT_SCALAR or DOUBLE_SCALAR + // LABEL, FLOAT or DOUBLE inline scalar number() const; //- Return const reference to the word contents. @@ -587,6 +592,22 @@ public: // Housekeeping + //- Token is FLOAT + // \deprecated(2020-01) - isFloat() + bool isFloatScalar() const { return isFloat(); }; + + //- Token is DOUBLE + // \deprecated(2020-01) - isDouble() + bool isDoubleScalar() const { return isDouble(); } + + //- Return float value. + // \deprecated(2020-01) - floatToken() + floatScalar floatScalarToken() const { return floatToken(); } + + //- Return double value. + // \deprecated(2020-01) - doubleToken() + doubleScalar doubleScalarToken() const { return doubleToken(); } + //- Deprecated(2017-11) transfer word pointer to the token // \deprecated(2017-11) - use move assign from word void operator=(word*) = delete; diff --git a/src/OpenFOAM/db/IOstreams/token/tokenI.H b/src/OpenFOAM/db/IOstreams/token/tokenI.H index 6b63aed010c3c15ca884b733bb8b0550279bd0ae..fb70949c3f138eb49ccbc797084c19b70e881a66 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenI.H +++ b/src/OpenFOAM/db/IOstreams/token/tokenI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,6 +52,8 @@ inline Foam::token Foam::token::flag(int bitmask) inline bool Foam::token::isseparator(int c) { + // NOTE: keep synchronized with ISstream::read(token&) + switch (c) { case token::END_STATEMENT : @@ -119,7 +121,7 @@ inline Foam::token::token(const token& tok) case tokenType::STRING: case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: + case tokenType::VERBATIM: { data_.stringPtr = new string(*tok.data_.stringPtr); break; @@ -173,7 +175,7 @@ inline Foam::token::token(const label val, label lineNumber) inline Foam::token::token(const floatScalar val, label lineNumber) : data_(), - type_(tokenType::FLOAT_SCALAR), + type_(tokenType::FLOAT), lineNumber_(lineNumber) { data_.floatVal = val; @@ -183,7 +185,7 @@ inline Foam::token::token(const floatScalar val, label lineNumber) inline Foam::token::token(const doubleScalar val, label lineNumber) : data_(), - type_(tokenType::DOUBLE_SCALAR), + type_(tokenType::DOUBLE), lineNumber_(lineNumber) { data_.doubleVal = val; @@ -252,7 +254,7 @@ inline void Foam::token::reset() case tokenType::STRING: case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: + case tokenType::VERBATIM: { delete data_.stringPtr; break; @@ -327,14 +329,14 @@ inline bool Foam::token::setType(token::tokenType variant) case tokenType::STRING: case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: + case tokenType::VERBATIM: { switch (type_) { // could also go from WORD to STRING etc - to be decided case tokenType::STRING: case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: + case tokenType::VERBATIM: type_ = variant; return true; break; @@ -465,15 +467,15 @@ inline Foam::label Foam::token::labelToken() const } -inline bool Foam::token::isFloatScalar() const +inline bool Foam::token::isFloat() const { - return (type_ == tokenType::FLOAT_SCALAR); + return (type_ == tokenType::FLOAT); } -inline Foam::floatScalar Foam::token::floatScalarToken() const +inline Foam::floatScalar Foam::token::floatToken() const { - if (type_ == tokenType::FLOAT_SCALAR) + if (type_ == tokenType::FLOAT) { return data_.floatVal; } @@ -483,15 +485,15 @@ inline Foam::floatScalar Foam::token::floatScalarToken() const } -inline bool Foam::token::isDoubleScalar() const +inline bool Foam::token::isDouble() const { - return (type_ == tokenType::DOUBLE_SCALAR); + return (type_ == tokenType::DOUBLE); } -inline Foam::doubleScalar Foam::token::doubleScalarToken() const +inline Foam::doubleScalar Foam::token::doubleToken() const { - if (type_ == tokenType::DOUBLE_SCALAR) + if (type_ == tokenType::DOUBLE) { return data_.doubleVal; } @@ -505,19 +507,19 @@ inline bool Foam::token::isScalar() const { return ( - type_ == tokenType::FLOAT_SCALAR - || type_ == tokenType::DOUBLE_SCALAR + type_ == tokenType::FLOAT + || type_ == tokenType::DOUBLE ); } inline Foam::scalar Foam::token::scalarToken() const { - if (type_ == tokenType::FLOAT_SCALAR) + if (type_ == tokenType::FLOAT) { return data_.floatVal; } - else if (type_ == tokenType::DOUBLE_SCALAR) + else if (type_ == tokenType::DOUBLE) { return data_.doubleVal; } @@ -573,7 +575,7 @@ inline bool Foam::token::isString() const ( type_ == tokenType::STRING || type_ == tokenType::VARIABLE - || type_ == tokenType::VERBATIMSTRING + || type_ == tokenType::VERBATIM ); } @@ -586,7 +588,7 @@ inline bool Foam::token::isVariable() const inline bool Foam::token::isVerbatim() const { - return (type_ == tokenType::VERBATIMSTRING); + return (type_ == tokenType::VERBATIM); } @@ -602,7 +604,7 @@ inline const Foam::string& Foam::token::stringToken() const ( type_ == tokenType::STRING || type_ == tokenType::VARIABLE - || type_ == tokenType::VERBATIMSTRING + || type_ == tokenType::VERBATIM ) { return *data_.stringPtr; @@ -671,7 +673,7 @@ inline void Foam::token::operator=(const token& tok) case tokenType::STRING: case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: + case tokenType::VERBATIM: { data_.stringPtr = new string(*tok.data_.stringPtr); } @@ -723,7 +725,7 @@ inline void Foam::token::operator=(const label val) inline void Foam::token::operator=(const floatScalar val) { reset(); - type_ = tokenType::FLOAT_SCALAR; + type_ = tokenType::FLOAT; data_.floatVal = val; } @@ -731,7 +733,7 @@ inline void Foam::token::operator=(const floatScalar val) inline void Foam::token::operator=(const doubleScalar val) { reset(); - type_ = tokenType::DOUBLE_SCALAR; + type_ = tokenType::DOUBLE; data_.doubleVal = val; } @@ -800,10 +802,10 @@ inline bool Foam::token::operator==(const token& tok) const case tokenType::LABEL: return data_.labelVal == tok.data_.labelVal; - case tokenType::FLOAT_SCALAR: + case tokenType::FLOAT: return equal(data_.floatVal, tok.data_.floatVal); - case tokenType::DOUBLE_SCALAR: + case tokenType::DOUBLE: return equal(data_.doubleVal, tok.data_.doubleVal); case tokenType::WORD: @@ -811,7 +813,7 @@ inline bool Foam::token::operator==(const token& tok) const case tokenType::STRING: case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: + case tokenType::VERBATIM: return *data_.stringPtr == *tok.data_.stringPtr; case tokenType::COMPOUND: @@ -856,7 +858,7 @@ inline bool Foam::token::operator==(const floatScalar val) const { return ( - type_ == tokenType::FLOAT_SCALAR + type_ == tokenType::FLOAT && equal(data_.floatVal, val) ); } @@ -866,7 +868,7 @@ inline bool Foam::token::operator==(const doubleScalar val) const { return ( - type_ == tokenType::DOUBLE_SCALAR + type_ == tokenType::DOUBLE && equal(data_.doubleVal, val) ); } diff --git a/src/OpenFOAM/db/IOstreams/token/tokenIO.C b/src/OpenFOAM/db/IOstreams/token/tokenIO.C index 4c527c549757b41a1d2c39ac648fd5289335c52b..8777482b2f3449a114d4f62a531ef42c24b23efb 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenIO.C +++ b/src/OpenFOAM/db/IOstreams/token/tokenIO.C @@ -62,12 +62,12 @@ static OS& printTokenInfo(OS& os, const token& tok) os << "label " << tok.labelToken(); break; - case token::tokenType::FLOAT_SCALAR: - os << "float " << tok.floatScalarToken(); + case token::tokenType::FLOAT: + os << "float " << tok.floatToken(); break; - case token::tokenType::DOUBLE_SCALAR: - os << "double " << tok.doubleScalarToken(); + case token::tokenType::DOUBLE: + os << "double " << tok.doubleToken(); break; case token::tokenType::WORD: @@ -82,8 +82,8 @@ static OS& printTokenInfo(OS& os, const token& tok) os << "variable " << tok.stringToken(); break; - case token::tokenType::VERBATIMSTRING: - os << "verbatim string " << tok.stringToken(); + case token::tokenType::VERBATIM: + os << "verbatim " << tok.stringToken(); break; case token::tokenType::COMPOUND: @@ -132,11 +132,11 @@ Foam::word Foam::token::name() const case token::tokenType::FLAG: return "flag"; case token::tokenType::PUNCTUATION: return "punctuation"; case token::tokenType::LABEL: return "label"; - case token::tokenType::FLOAT_SCALAR: return "float"; - case token::tokenType::DOUBLE_SCALAR: return "double"; + case token::tokenType::FLOAT: return "float"; + case token::tokenType::DOUBLE: return "double"; case token::tokenType::WORD: return "word"; case token::tokenType::STRING: return "string"; - case token::tokenType::VERBATIMSTRING: return "verbatim"; + case token::tokenType::VERBATIM: return "verbatim"; case token::tokenType::VARIABLE: return "variable"; case token::tokenType::COMPOUND: return "compound"; case token::tokenType::ERROR: return "error"; @@ -181,11 +181,11 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok) os << tok.data_.labelVal; break; - case token::tokenType::FLOAT_SCALAR: + case token::tokenType::FLOAT: os << tok.data_.floatVal; break; - case token::tokenType::DOUBLE_SCALAR: + case token::tokenType::DOUBLE: os << tok.data_.doubleVal; break; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C index a4dd8edfab3b55b125bd0a2bf7600c6d8bab88fa..07a632c92b552bc6f1ee883e357e993177f6467a 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -181,7 +181,7 @@ bool Foam::functionEntries::ifeqEntry::equalToken return false; case token::VARIABLE: - case token::VERBATIMSTRING: + case token::VERBATIM: if (eqType) { return t1.stringToken() == t2.stringToken(); @@ -203,10 +203,10 @@ bool Foam::functionEntries::ifeqEntry::equalToken } return false; - case token::FLOAT_SCALAR: + case token::FLOAT: if (eqType) { - return equal(t1.floatScalarToken(), t2.floatScalarToken()); + return equal(t1.floatToken(), t2.floatToken()); } else if (t2.isScalar()) { @@ -214,10 +214,10 @@ bool Foam::functionEntries::ifeqEntry::equalToken } return false; - case token::DOUBLE_SCALAR: + case token::DOUBLE: if (eqType) { - return equal(t1.doubleScalarToken(), t2.doubleScalarToken()); + return equal(t1.doubleToken(), t2.doubleToken()); } else if (t2.isScalar()) {