mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: remove old (__cplusplus >= 201703L) checks
- now using c++17 throughout
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
Test-Hashing2.C
|
||||
Test-Hashing2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2
|
||||
|
||||
@ -274,9 +274,7 @@ int main(int argc, char *argv[])
|
||||
Info<< nl << "No " << is.name() << " file found ..." << nl;
|
||||
}
|
||||
|
||||
token tok;
|
||||
|
||||
while (is.good() && is.read(tok) && tok.good())
|
||||
for (token tok; tok.read(is); /*nil*/)
|
||||
{
|
||||
const word listType(tok.wordToken());
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ICharStream1.C
|
||||
Test-ICharStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,12 +83,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
@ -138,17 +136,10 @@ void printInfo(const List<char>& buf)
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
token t;
|
||||
while (is.good())
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
is >> t;
|
||||
if (t.good())
|
||||
{
|
||||
++count;
|
||||
Info<<"token: " << t << endl;
|
||||
}
|
||||
Info<< "token: " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
@ -73,14 +73,13 @@ Ostream& toString(Ostream& os, const List<char>& list)
|
||||
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
Info<< "stream tokens:" << endl;
|
||||
|
||||
label count = 0;
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
Info<< " : " << tok << endl;
|
||||
Info<< " : " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
||||
// constexpr label chunkSize = 128;
|
||||
typedef std::unique_ptr<List<T>> chunkType;
|
||||
|
||||
is >> tok;
|
||||
tok.read(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
if (tok.isPunctuation(token::END_LIST))
|
||||
@ -149,7 +149,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
is >> tok;
|
||||
tok.read(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OCharStream1.C
|
||||
Test-OCharStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,12 +83,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
@ -129,17 +127,10 @@ void printInfo(const BufType& buf)
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
token t;
|
||||
while (is.good())
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
is >> t;
|
||||
if (t.good())
|
||||
{
|
||||
++count;
|
||||
Info<<"token: " << t << endl;
|
||||
}
|
||||
Info<< "token: " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SpanStream1.C
|
||||
Test-SpanStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,12 +85,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
@ -145,17 +143,10 @@ void printInfo(const UList<char>& buf)
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
token t;
|
||||
while (is.good())
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
is >> t;
|
||||
if (t.good())
|
||||
{
|
||||
++count;
|
||||
Info<<"token: " << t << endl;
|
||||
}
|
||||
Info<< "token: " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Test-dictionaryTokens.C
|
||||
dictionaryTokens.C
|
||||
Test-dictionaryTokens.cxx
|
||||
dictionaryTokens.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-string_view1.C
|
||||
Test-string_view1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-string_view1
|
||||
|
||||
@ -40,11 +40,6 @@ using namespace Foam;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Compiled with C++ " << __cplusplus;
|
||||
#if __cplusplus >= 201703L
|
||||
Info<< " - has std::string_view" << nl << nl;
|
||||
#else
|
||||
Info<< " - NO std::string_view" << nl << nl;
|
||||
#endif
|
||||
|
||||
// basics
|
||||
{
|
||||
@ -63,9 +58,7 @@ int main(int argc, char *argv[])
|
||||
<< "input: <" << cstr << '>'
|
||||
<< " type: " << typeid(cstr).name() << " len:" << len << nl;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Info<< " view: " << std::string_view(cstr) << nl;
|
||||
#endif
|
||||
|
||||
Info<< " span: "
|
||||
<< stdFoam::span<const char>(cstr, len) << nl;
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -134,50 +134,51 @@ int main(int argc, char *argv[])
|
||||
Info<< "resized: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
|
||||
// Using isA<> on compoundToken()
|
||||
if
|
||||
(
|
||||
const auto* listptr
|
||||
= ctok1.compoundToken().isA<scalarList>()
|
||||
)
|
||||
{
|
||||
// Using isA<> on compoundToken()
|
||||
const auto* listptr = ctok1.compoundToken().isA<scalarList>();
|
||||
if (listptr)
|
||||
{
|
||||
// sneaky, SubField bypasses const!
|
||||
scalarField::subField fld(*listptr);
|
||||
fld *= 5;
|
||||
// sneaky, SubField bypasses const!
|
||||
scalarField::subField fld(*listptr);
|
||||
fld *= 5;
|
||||
|
||||
Info<< "multiplied List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
Info<< "multiplied List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
|
||||
// Using isCompound<...> - combined check
|
||||
if
|
||||
(
|
||||
const auto* listptr
|
||||
= ctok1.isCompound<scalarList>()
|
||||
)
|
||||
{
|
||||
// Using isCompound<...> - combined check
|
||||
scalarField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
const auto* listptr = ctok1.isCompound<scalarList>();
|
||||
if (listptr)
|
||||
{
|
||||
scalarField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
Info<< "divided List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
Info<< "divided List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
|
||||
// Using isCompound<...> - combined check
|
||||
if
|
||||
(
|
||||
const auto* listptr
|
||||
= ctok1.isCompound<labelList>()
|
||||
)
|
||||
{
|
||||
// Using isCompound<...> - combined check
|
||||
labelField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
const auto* listptr = ctok1.isCompound<labelList>();
|
||||
if (listptr)
|
||||
{
|
||||
labelField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
Info<< "divided List<label>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "compound is not List<label>" << nl;
|
||||
}
|
||||
Info<< "divided List<label>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "compound is not List<label>" << nl;
|
||||
}
|
||||
|
||||
Info<< "Before fill_zero: " << ctok1 << endl;
|
||||
@ -248,13 +249,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
token tok;
|
||||
|
||||
if (auto v = obuf.view(); !v.empty())
|
||||
{
|
||||
auto v = obuf.view();
|
||||
if (!v.empty())
|
||||
{
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
tok = token();
|
||||
}
|
||||
|
||||
Info<< "tok: " << tok.name() << nl << nl;
|
||||
@ -274,13 +276,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
obuf.endBlock();
|
||||
|
||||
if (auto v = obuf.view(); !v.empty())
|
||||
{
|
||||
auto v = obuf.view();
|
||||
if (!v.empty())
|
||||
{
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
tok = token();
|
||||
}
|
||||
|
||||
// Output like xml:
|
||||
@ -349,10 +352,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
typedef List<scalar> ListType;
|
||||
|
||||
auto* inputDataPtr =
|
||||
const_cast<ListType*>(entry0.stream().findCompound<ListType>());
|
||||
|
||||
if (inputDataPtr)
|
||||
if
|
||||
(
|
||||
auto* inputDataPtr
|
||||
= const_cast<ListType*>(entry0.stream().findCompound<ListType>())
|
||||
)
|
||||
{
|
||||
Info<< "found input data" << nl;
|
||||
Info<< entry0 << nl;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-tokenize.C
|
||||
Test-tokenize.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-tokenize
|
||||
|
||||
@ -327,7 +327,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Write operator for std::string_view
|
||||
inline Ostream& operator<<(Ostream& os, std::string_view s)
|
||||
{
|
||||
@ -335,7 +334,6 @@ inline Ostream& operator<<(Ostream& os, std::string_view s)
|
||||
os.check("Foam::operator<<(Ostream&, std::string_view)");
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
|
||||
//- Write operator for character span. Output like string data
|
||||
inline Ostream& operator<<(Ostream& os, stdFoam::span<char> s)
|
||||
|
||||
@ -117,14 +117,7 @@ Foam::Ostream& Foam::OSstream::writeQuoted
|
||||
|
||||
if (!quoted)
|
||||
{
|
||||
#if __cplusplus >= 201703L
|
||||
os_ << std::string_view(str, len);
|
||||
#else
|
||||
for (const char* iter = str; iter != last; ++iter)
|
||||
{
|
||||
os_ << *iter;
|
||||
}
|
||||
#endif
|
||||
syncState();
|
||||
|
||||
// Unquoted, only advance line number on newline
|
||||
|
||||
@ -165,11 +165,7 @@ public:
|
||||
// Uses static parse function internally.
|
||||
explicit ITstream
|
||||
(
|
||||
#if __cplusplus >= 201703L
|
||||
std::string_view s,
|
||||
#else
|
||||
const std::string& s,
|
||||
#endif
|
||||
IOstreamOption streamOpt = IOstreamOption(),
|
||||
const string& name = "input"
|
||||
)
|
||||
@ -281,7 +277,6 @@ public:
|
||||
return parse_chars(input, strlen(input), streamOpt);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Create token list by parsing the input character sequence
|
||||
//- until no good tokens remain.
|
||||
static tokenList parse
|
||||
@ -292,7 +287,6 @@ public:
|
||||
{
|
||||
return parse_chars(s.data(), s.size(), streamOpt);
|
||||
}
|
||||
#endif
|
||||
|
||||
//- Create token list by parsing the input character sequence
|
||||
//- until no good tokens remain.
|
||||
|
||||
@ -116,14 +116,12 @@ public:
|
||||
stream_type(static_cast<buffer_type*>(this))
|
||||
{}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Construct (shallow copy) from std::string_view content
|
||||
explicit ispanstream(std::string_view s)
|
||||
:
|
||||
buffer_type(const_cast<char*>(s.data()), s.size()),
|
||||
stream_type(static_cast<buffer_type*>(this))
|
||||
{}
|
||||
#endif
|
||||
|
||||
//- Construct (shallow copy) from span character content
|
||||
explicit ispanstream(stdFoam::span<char> s)
|
||||
@ -215,14 +213,12 @@ public:
|
||||
stream_type::clear(); // Clear old errors
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Reset the get buffer area to use the data from a string_view
|
||||
void reset(std::string_view s)
|
||||
{
|
||||
buffer_type::resetg(const_cast<char*>(s.data()), s.size());
|
||||
stream_type::clear(); // Clear old errors
|
||||
}
|
||||
#endif
|
||||
|
||||
//- Some information about the input buffer position/capacity
|
||||
void debug_info(Ostream& os) const
|
||||
@ -292,7 +288,6 @@ public:
|
||||
ISpanStream(s.data(), s.size(), streamOpt)
|
||||
{}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Use data area from string_view content
|
||||
explicit ISpanStream
|
||||
(
|
||||
@ -302,7 +297,6 @@ public:
|
||||
:
|
||||
ISpanStream(s.data(), s.size(), streamOpt)
|
||||
{}
|
||||
#endif
|
||||
|
||||
//- Construct using data area from a List and its inherent storage size
|
||||
// Uses addressed size, thus no special treatment for a DynamicList
|
||||
@ -384,14 +378,12 @@ public:
|
||||
syncState();
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Reset input area to use data from a std::string_view
|
||||
void reset(std::string_view s)
|
||||
{
|
||||
stream_.reset(s.data(), s.size());
|
||||
syncState();
|
||||
}
|
||||
#endif
|
||||
|
||||
//- Reset input area to use data from span character content
|
||||
void reset(stdFoam::span<char> s)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -213,17 +213,10 @@ public:
|
||||
//- The span size (number of input characters)
|
||||
std::streamsize size_bytes() const { return (egptr() - eback()); }
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
std::string_view view() const
|
||||
{
|
||||
return std::string_view(data_bytes(), size_bytes());
|
||||
}
|
||||
#else
|
||||
stdFoam::span<const char> view() const
|
||||
{
|
||||
return stdFoam::span<const char>(data_bytes(), size_bytes());
|
||||
}
|
||||
#endif
|
||||
|
||||
//- Some information about the input buffer position/capacity
|
||||
void info(Ostream& os) const
|
||||
@ -403,17 +396,10 @@ public:
|
||||
//- The span size (size of output buffer)
|
||||
std::streamsize size_bytes() const { return (pptr() - pbase()); }
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
std::string_view view() const
|
||||
{
|
||||
return std::string_view(data_bytes(), size_bytes());
|
||||
}
|
||||
#else
|
||||
stdFoam::span<const char> view() const
|
||||
{
|
||||
return stdFoam::span<const char>(data_bytes(), size_bytes());
|
||||
}
|
||||
#endif
|
||||
|
||||
//- Some information about the output buffer position/capacity
|
||||
void info(Ostream& os) const
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 Sergey Lesnik
|
||||
Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2023-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,7 +37,7 @@ namespace Foam
|
||||
// Write tokens without keyword, suppress/ignore bad tokens.
|
||||
// Mostly like primitiveEntry::write(os, true);
|
||||
|
||||
static void writeTokens(Ostream& os, const tokenList& toks)
|
||||
static void writeTokens(Ostream& os, const UList<token>& toks)
|
||||
{
|
||||
bool started = false; // Separate from previous token?
|
||||
|
||||
@ -110,7 +110,7 @@ Foam::formattingEntry::formattingEntry
|
||||
primitiveEntry
|
||||
(
|
||||
key,
|
||||
token(token::tokenType::CHAR_DATA, std::move(content))
|
||||
token(token::tokenType::CHAR_DATA, content)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -57,7 +57,6 @@ public:
|
||||
|
||||
// Static Functions
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Return match as a string_view
|
||||
static std::string_view view(const std::ssub_match& m)
|
||||
{
|
||||
@ -74,7 +73,6 @@ public:
|
||||
);
|
||||
#endif
|
||||
}
|
||||
#endif /* __cplusplus >= 201703L */
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -105,13 +103,11 @@ public:
|
||||
return (*this)[pos].str();
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//- Return element at pos as a string_view
|
||||
std::string_view view(size_t pos) const
|
||||
{
|
||||
return view((*this)[pos]);
|
||||
}
|
||||
#endif /* __cplusplus >= 201703L */
|
||||
|
||||
//- Append sub-string defined by begin/end iterators
|
||||
void append
|
||||
|
||||
Reference in New Issue
Block a user