mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve stream output of std::string etc.
- change write(const string&) to write(const std::string&).
This allows output of std::string without an intermediate copy.
- additional writeQuoted method to handle range of char data:
writeQuoted(const char* str, std::streamsize len, bool)
This helps with supporting string_view and span<char>
- add operator<< for stdFoam::span<char> and std::string_view (c++17)
- avoid duplicate code in OBJstream
STYLE: add override keyword for IO stream methods
This commit is contained in:
committed by
Andrew Heather
parent
d9727fad1c
commit
b76595df42
@ -57,7 +57,7 @@ class IFstreamDelayed
|
|||||||
:
|
:
|
||||||
public IFstream
|
public IFstream
|
||||||
{
|
{
|
||||||
virtual bool readCompoundToken(token& tok, const word& type)
|
virtual bool readCompoundToken(token& tok, const word& type) override
|
||||||
{
|
{
|
||||||
auto& is = *this;
|
auto& is = *this;
|
||||||
|
|
||||||
|
|||||||
3
applications/test/string_view1/Make/files
Normal file
3
applications/test/string_view1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-string_view1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-string_view1
|
||||||
2
applications/test/string_view1/Make/options
Normal file
2
applications/test/string_view1/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
94
applications/test/string_view1/Test-string_view1.C
Normal file
94
applications/test/string_view1/Test-string_view1.C
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test some string_view functionality
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "string.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "List.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
for
|
||||||
|
(
|
||||||
|
const auto& cstr
|
||||||
|
:
|
||||||
|
{
|
||||||
|
"abcdef"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const auto len = strlen(cstr);
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "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;
|
||||||
|
Info<< " span: "
|
||||||
|
<< stdFoam::span<char>(const_cast<char*>(cstr), len) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should fail to compile:
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
labelList values(identity(4));
|
||||||
|
|
||||||
|
Info<< "values: " << values << nl;
|
||||||
|
|
||||||
|
Info<< " span: "
|
||||||
|
<< stdFoam::span<label>(values.data(), values.size()) << nl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -33,11 +33,7 @@ Description
|
|||||||
|
|
||||||
OBJstream os(runTime.globalPath()/outputName);
|
OBJstream os(runTime.globalPath()/outputName);
|
||||||
|
|
||||||
os.writeQuoted
|
os.writeComment(outputName);
|
||||||
(
|
|
||||||
("# " + outputName + "\n"),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
os.write(aMesh.patch().edges(), aMesh.patch().localPoints());
|
os.write(aMesh.patch().edges(), aMesh.patch().localPoints());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,20 +105,20 @@ public:
|
|||||||
// STL stream
|
// STL stream
|
||||||
|
|
||||||
//- Access to underlying std::istream
|
//- Access to underlying std::istream
|
||||||
virtual std::istream& stdStream();
|
virtual std::istream& stdStream() override;
|
||||||
|
|
||||||
//- Const access to underlying std::istream
|
//- Const access to underlying std::istream
|
||||||
virtual const std::istream& stdStream() const;
|
virtual const std::istream& stdStream() const override;
|
||||||
|
|
||||||
//- Rewind the stream so that it may be read again.
|
//- Rewind the stream so that it may be read again.
|
||||||
// Includes special handling for compressed streams.
|
// Includes special handling for compressed streams.
|
||||||
virtual void rewind();
|
virtual void rewind() override;
|
||||||
|
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print stream description
|
//- Print stream description
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -130,11 +130,11 @@ public:
|
|||||||
|
|
||||||
// STL stream
|
// STL stream
|
||||||
|
|
||||||
//- Access to underlying std::ostream
|
|
||||||
virtual std::ostream& stdStream();
|
|
||||||
|
|
||||||
//- Const access to underlying std::ostream
|
//- Const access to underlying std::ostream
|
||||||
virtual const std::ostream& stdStream() const;
|
virtual const std::ostream& stdStream() const override;
|
||||||
|
|
||||||
|
//- Access to underlying std::ostream
|
||||||
|
virtual std::ostream& stdStream() override;
|
||||||
|
|
||||||
//- Rewind the stream so that it may be written again.
|
//- Rewind the stream so that it may be written again.
|
||||||
//- Reopens the file (truncation)
|
//- Reopens the file (truncation)
|
||||||
@ -144,7 +144,7 @@ public:
|
|||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print stream description
|
//- Print stream description
|
||||||
void print(Ostream& os) const;
|
void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Additional constructors and methods
|
// Additional constructors and methods
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -48,16 +48,26 @@ void Foam::Ostream::decrIndent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::Ostream::writeQuoted
|
||||||
|
(
|
||||||
|
const std::string& str,
|
||||||
|
const bool quoted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return writeQuoted(str.data(), str.size(), quoted);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
||||||
{
|
{
|
||||||
return writeQuoted(kw, kw.isPattern());
|
return writeQuoted(kw.data(), kw.size(), kw.isPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
||||||
{
|
{
|
||||||
indent();
|
indent();
|
||||||
writeQuoted(kw, kw.isPattern());
|
writeQuoted(kw.data(), kw.size(), kw.isPattern());
|
||||||
|
|
||||||
if (indentSize_ <= 1)
|
if (indentSize_ <= 1)
|
||||||
{
|
{
|
||||||
@ -86,7 +96,7 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::Ostream::beginBlock(const keyType& kw)
|
Foam::Ostream& Foam::Ostream::beginBlock(const keyType& kw)
|
||||||
{
|
{
|
||||||
indent(); writeQuoted(kw, kw.isPattern()); write('\n');
|
indent(); writeQuoted(kw.data(), kw.size(), kw.isPattern()); write('\n');
|
||||||
beginBlock();
|
beginBlock();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -41,6 +41,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "IOstream.H"
|
#include "IOstream.H"
|
||||||
#include "keyType.H"
|
#include "keyType.H"
|
||||||
|
#include "stdFoam.H" // For span etc.
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -118,28 +119,35 @@ public:
|
|||||||
//- Write character
|
//- Write character
|
||||||
virtual Ostream& write(const char c) = 0;
|
virtual Ostream& write(const char c) = 0;
|
||||||
|
|
||||||
|
//- Write character/string content, with/without surrounding quotes
|
||||||
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted=true
|
||||||
|
) = 0;
|
||||||
|
|
||||||
|
//- Write string content, with/without surrounding quotes
|
||||||
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const std::string& str,
|
||||||
|
const bool quoted=true
|
||||||
|
);
|
||||||
|
|
||||||
//- Write character string
|
//- Write character string
|
||||||
virtual Ostream& write(const char* str) = 0;
|
virtual Ostream& write(const char* str) = 0;
|
||||||
|
|
||||||
//- Write word
|
//- Write word (unquoted)
|
||||||
virtual Ostream& write(const word& str) = 0;
|
virtual Ostream& write(const word& str) = 0;
|
||||||
|
|
||||||
|
//- Write string content (usually quoted)
|
||||||
|
virtual Ostream& write(const std::string& str) = 0;
|
||||||
|
|
||||||
//- Write keyType
|
//- Write keyType
|
||||||
// A plain word is written unquoted.
|
// A plain word is written unquoted.
|
||||||
// A regular expression is written as a quoted string.
|
// A regular expression is written as a quoted string.
|
||||||
virtual Ostream& write(const keyType& kw);
|
virtual Ostream& write(const keyType& kw);
|
||||||
|
|
||||||
//- Write string
|
|
||||||
virtual Ostream& write(const string& str) = 0;
|
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
|
||||||
// Optional write without quotes.
|
|
||||||
virtual Ostream& writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted=true
|
|
||||||
) = 0;
|
|
||||||
|
|
||||||
//- Write int32_t
|
//- Write int32_t
|
||||||
virtual Ostream& write(const int32_t val) = 0;
|
virtual Ostream& write(const int32_t val) = 0;
|
||||||
|
|
||||||
@ -317,9 +325,38 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
// ------ Manipulators (not taking arguments)
|
|
||||||
// --------------------------------------------------------------------
|
#if __cplusplus >= 201703L
|
||||||
|
//- Write operator for std::string_view
|
||||||
|
inline Ostream& operator<<(Ostream& os, std::string_view s)
|
||||||
|
{
|
||||||
|
os.writeQuoted(s.data(), s.size(), true); // quoted
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
os.writeQuoted(s.data(), s.size(), true); // quoted
|
||||||
|
os.check("Foam::operator<<(Ostream&, stdFoam::span<char>)");
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Write operator for const character span. Output like string data
|
||||||
|
inline Ostream& operator<<(Ostream& os, stdFoam::span<const char> s)
|
||||||
|
{
|
||||||
|
os.writeQuoted(s.data(), s.size(), true); // quoted
|
||||||
|
os.check("Foam::operator<<(Ostream&, stdFoam::span<const char>)");
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Manipulators (without arguments)
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
//- An Ostream manipulator
|
//- An Ostream manipulator
|
||||||
typedef Ostream& (*OstreamManip)(Ostream&);
|
typedef Ostream& (*OstreamManip)(Ostream&);
|
||||||
|
|||||||
@ -149,77 +149,71 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Inquiry
|
// Stream State Functions
|
||||||
|
|
||||||
//- Return flags of output stream
|
//- Return stream flags
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Set flags of stream flags
|
||||||
// Read Functions
|
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||||
|
|
||||||
//- Return next token from stream
|
|
||||||
Istream& read(token& t);
|
|
||||||
|
|
||||||
//- Read a character
|
|
||||||
Istream& read(char& c);
|
|
||||||
|
|
||||||
//- Read a word
|
|
||||||
Istream& read(word& str);
|
|
||||||
|
|
||||||
// Read a string
|
|
||||||
Istream& read(string& str);
|
|
||||||
|
|
||||||
//- Read a label
|
|
||||||
Istream& read(label& val);
|
|
||||||
|
|
||||||
//- Read a float
|
|
||||||
Istream& read(float& val);
|
|
||||||
|
|
||||||
//- Read a double
|
|
||||||
Istream& read(double& val);
|
|
||||||
|
|
||||||
//- Read binary block with 8-byte alignment.
|
|
||||||
//- Reading into a null pointer behaves like a forward seek of
|
|
||||||
//- count characters.
|
|
||||||
Istream& read(char* data, std::streamsize count);
|
|
||||||
|
|
||||||
//- Low-level raw binary read.
|
|
||||||
//- Reading into a null pointer behaves like a forward seek of
|
|
||||||
//- count characters.
|
|
||||||
Istream& readRaw(char* data, std::streamsize count);
|
|
||||||
|
|
||||||
//- Start of low-level raw binary read
|
|
||||||
bool beginRawRead();
|
|
||||||
|
|
||||||
//- End of low-level raw binary read
|
|
||||||
bool endRawRead()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Positioning
|
|
||||||
|
|
||||||
//- Rewind the receive stream position so that it may be read again
|
|
||||||
virtual void rewind();
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Set flags of stream
|
|
||||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags)
|
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Read Functions
|
||||||
|
|
||||||
|
//- Return next token from stream
|
||||||
|
virtual Istream& read(token&) override;
|
||||||
|
|
||||||
|
//- Read a character
|
||||||
|
virtual Istream& read(char& c) override;
|
||||||
|
|
||||||
|
//- Read a word
|
||||||
|
virtual Istream& read(word& str) override;
|
||||||
|
|
||||||
|
// Read a string
|
||||||
|
virtual Istream& read(string& str) override;
|
||||||
|
|
||||||
|
//- Read a label
|
||||||
|
virtual Istream& read(label& val) override;
|
||||||
|
|
||||||
|
//- Read a float
|
||||||
|
virtual Istream& read(float& val) override;
|
||||||
|
|
||||||
|
//- Read a double
|
||||||
|
virtual Istream& read(double& val) override;
|
||||||
|
|
||||||
|
//- Read binary block with 8-byte alignment.
|
||||||
|
//- Reading into a null pointer behaves like a forward seek of
|
||||||
|
//- count characters.
|
||||||
|
virtual Istream& read(char* data, std::streamsize count) override;
|
||||||
|
|
||||||
|
//- Low-level raw binary read.
|
||||||
|
//- Reading into a null pointer behaves like a forward seek of
|
||||||
|
//- count characters.
|
||||||
|
virtual Istream& readRaw(char* data, std::streamsize count) override;
|
||||||
|
|
||||||
|
//- Start of low-level raw binary read
|
||||||
|
virtual bool beginRawRead() override;
|
||||||
|
|
||||||
|
//- End of low-level raw binary read
|
||||||
|
virtual bool endRawRead() override { return true; }
|
||||||
|
|
||||||
|
|
||||||
|
// Positioning
|
||||||
|
|
||||||
|
//- Rewind the receive stream position so that it may be read again
|
||||||
|
virtual void rewind() override;
|
||||||
|
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
void print(Ostream& os) const;
|
void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,7 @@ inline void Foam::UIPstreamBase::readFromBuffer
|
|||||||
|
|
||||||
inline Foam::Istream& Foam::UIPstreamBase::readString(std::string& str)
|
inline Foam::Istream& Foam::UIPstreamBase::readString(std::string& str)
|
||||||
{
|
{
|
||||||
// Use std::string::assign() to copy content, including '\0'.
|
// Use std::string::assign() to copy content, including embedded nul chars.
|
||||||
// Stripping (when desired) is the responsibility of the sending side.
|
// Stripping (when desired) is the responsibility of the sending side.
|
||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|||||||
@ -83,8 +83,10 @@ class UOPstreamBase
|
|||||||
//- Add a single char to the send buffer. No alignment needed
|
//- Add a single char to the send buffer. No alignment needed
|
||||||
inline void putChar(const char c);
|
inline void putChar(const char c);
|
||||||
|
|
||||||
//- Write string length and string content.
|
//- Write string length and content, including embedded nul chars.
|
||||||
// The content includes the trailing nul char.
|
inline void putString(const char* str, const size_t len);
|
||||||
|
|
||||||
|
//- Write string length and content, including embedded nul chars.
|
||||||
inline void putString(const std::string& str);
|
inline void putString(const std::string& str);
|
||||||
|
|
||||||
|
|
||||||
@ -142,124 +144,135 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Inquiry
|
// Inquiry
|
||||||
|
|
||||||
//- Return flags of output stream
|
//- Return flags of output stream
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write Functions
|
// Write Functions
|
||||||
|
|
||||||
//- Write token to stream or otherwise handle it.
|
//- Inherit write methods from Ostream
|
||||||
// \return false if the token type was not handled by this method
|
using Ostream::writeQuoted;
|
||||||
virtual bool write(const token& tok);
|
|
||||||
|
|
||||||
//- Write single character. Whitespace is suppressed.
|
//- Write token to stream or otherwise handle it.
|
||||||
virtual Ostream& write(const char c);
|
// \return false if the token type was not handled by this method
|
||||||
|
virtual bool write(const token& tok) override;
|
||||||
|
|
||||||
//- Write the word-characters of a character string.
|
//- Write single character. Whitespace is suppressed.
|
||||||
// Sends as a single char, or as word.
|
virtual Ostream& write(const char c) override;
|
||||||
virtual Ostream& write(const char* str);
|
|
||||||
|
|
||||||
//- Write word
|
//- Write character/string content, with/without surrounding quotes
|
||||||
virtual Ostream& write(const word& str);
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted=true
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Write string
|
//- Write the word-characters of a character string.
|
||||||
virtual Ostream& write(const string& str);
|
// Sends as a single char, or as word.
|
||||||
|
virtual Ostream& write(const char* str) override;
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
//- Write word
|
||||||
// Optional write without quotes.
|
virtual Ostream& write(const word& str) override;
|
||||||
virtual Ostream& writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted=true
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write int32_t as a label
|
//- Write string
|
||||||
virtual Ostream& write(const int32_t val);
|
virtual Ostream& write(const std::string& str) override;
|
||||||
|
|
||||||
//- Write int64_t as a label
|
//- Write int32_t as a label
|
||||||
virtual Ostream& write(const int64_t val);
|
virtual Ostream& write(const int32_t val) override;
|
||||||
|
|
||||||
//- Write float
|
//- Write int64_t as a label
|
||||||
virtual Ostream& write(const float val);
|
virtual Ostream& write(const int64_t val) override;
|
||||||
|
|
||||||
//- Write double
|
//- Write float
|
||||||
virtual Ostream& write(const double val);
|
virtual Ostream& write(const float val) override;
|
||||||
|
|
||||||
//- Write binary block with 8-byte alignment.
|
//- Write double
|
||||||
virtual Ostream& write(const char* data, std::streamsize count);
|
virtual Ostream& write(const double val) override;
|
||||||
|
|
||||||
//- Low-level raw binary output.
|
//- Write binary block with 8-byte alignment.
|
||||||
virtual Ostream& writeRaw(const char* data, std::streamsize count);
|
virtual Ostream& write
|
||||||
|
(
|
||||||
|
const char* data,
|
||||||
|
std::streamsize count
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Begin marker for low-level raw binary output.
|
//- Low-level raw binary output.
|
||||||
// The count indicates the number of bytes for subsequent
|
virtual Ostream& writeRaw
|
||||||
// writeRaw calls.
|
(
|
||||||
virtual bool beginRawWrite(std::streamsize count);
|
const char* data,
|
||||||
|
std::streamsize count
|
||||||
|
) override;
|
||||||
|
|
||||||
//- End marker for low-level raw binary output.
|
//- Begin marker for low-level raw binary output.
|
||||||
virtual bool endRawWrite()
|
// The count indicates the number of bytes for subsequent
|
||||||
{
|
// writeRaw calls.
|
||||||
return true;
|
virtual bool beginRawWrite(std::streamsize count) override;
|
||||||
}
|
|
||||||
|
|
||||||
//- Add indentation characters
|
//- End marker for low-level raw binary output.
|
||||||
virtual void indent()
|
virtual bool endRawWrite() override
|
||||||
{}
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Add indentation characters
|
||||||
|
virtual void indent() override
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Stream state functions
|
// Stream state functions
|
||||||
|
|
||||||
//- Flush stream
|
//- Flush stream
|
||||||
virtual void flush()
|
virtual void flush() override
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Add newline and flush stream
|
//- Add newline and flush stream
|
||||||
virtual void endl()
|
virtual void endl() override
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Get the current padding character
|
//- Get the current padding character
|
||||||
// \return previous padding character
|
// \return previous padding character
|
||||||
virtual char fill() const
|
virtual char fill() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set padding character for formatted field up to field width
|
//- Set padding character for formatted field up to field width
|
||||||
virtual char fill(const char)
|
virtual char fill(const char) override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get width of output field
|
//- Get width of output field
|
||||||
virtual int width() const
|
virtual int width() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set width of output field
|
//- Set width of output field
|
||||||
// \return previous width
|
// \return previous width
|
||||||
virtual int width(const int)
|
virtual int width(const int) override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get precision of output field
|
//- Get precision of output field
|
||||||
virtual int precision() const
|
virtual int precision() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set precision of output field
|
//- Set precision of output field
|
||||||
// \return old precision
|
// \return old precision
|
||||||
virtual int precision(const int)
|
virtual int precision(const int) override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Positioning
|
// Positioning
|
||||||
@ -271,7 +284,7 @@ public:
|
|||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Set flags of stream
|
//- Set flags of stream
|
||||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags)
|
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
@ -280,7 +293,7 @@ public:
|
|||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
void print(Ostream& os) const;
|
void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -121,11 +121,20 @@ inline void Foam::UOPstreamBase::putChar(const char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::UOPstreamBase::putString
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
const size_t len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
writeToBuffer(len);
|
||||||
|
writeToBuffer(str, len, 1); // no-op when len == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::UOPstreamBase::putString(const std::string& str)
|
inline void Foam::UOPstreamBase::putString(const std::string& str)
|
||||||
{
|
{
|
||||||
const size_t len = str.size();
|
putString(str.data(), str.size());
|
||||||
writeToBuffer(len);
|
|
||||||
writeToBuffer(str.data(), len, 1); // no-op when len == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -253,6 +262,27 @@ Foam::Ostream& Foam::UOPstreamBase::write(const char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::UOPstreamBase::writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (quoted)
|
||||||
|
{
|
||||||
|
putChar(token::tokenType::STRING);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
putChar(token::tokenType::WORD);
|
||||||
|
}
|
||||||
|
putString(str, len);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::UOPstreamBase::write(const char* str)
|
Foam::Ostream& Foam::UOPstreamBase::write(const char* str)
|
||||||
{
|
{
|
||||||
const word nonWhiteChars(string::validate<word>(str));
|
const word nonWhiteChars(string::validate<word>(str));
|
||||||
@ -279,7 +309,7 @@ Foam::Ostream& Foam::UOPstreamBase::write(const word& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::UOPstreamBase::write(const string& str)
|
Foam::Ostream& Foam::UOPstreamBase::write(const std::string& str)
|
||||||
{
|
{
|
||||||
putChar(token::tokenType::STRING);
|
putChar(token::tokenType::STRING);
|
||||||
putString(str);
|
putString(str);
|
||||||
@ -288,26 +318,6 @@ Foam::Ostream& Foam::UOPstreamBase::write(const string& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::UOPstreamBase::writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (quoted)
|
|
||||||
{
|
|
||||||
putChar(token::tokenType::STRING);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
putChar(token::tokenType::WORD);
|
|
||||||
}
|
|
||||||
putString(str);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::UOPstreamBase::write(const int32_t val)
|
Foam::Ostream& Foam::UOPstreamBase::write(const int32_t val)
|
||||||
{
|
{
|
||||||
putChar(token::tokenType::LABEL);
|
putChar(token::tokenType::LABEL);
|
||||||
|
|||||||
@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
//- The name of the input serial stream.
|
//- The name of the input serial stream.
|
||||||
//- (eg, the name of the Fstream file name)
|
//- (eg, the name of the Fstream file name)
|
||||||
virtual const fileName& name() const { return name_; }
|
virtual const fileName& name() const override { return name_; }
|
||||||
|
|
||||||
//- The name of the input serial stream, for modification.
|
//- The name of the input serial stream, for modification.
|
||||||
virtual fileName& name() { return name_; }
|
virtual fileName& name() { return name_; }
|
||||||
@ -144,13 +144,13 @@ public:
|
|||||||
// Stream State
|
// Stream State
|
||||||
|
|
||||||
//- Return flags of output stream
|
//- Return flags of output stream
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
return is_.flags();
|
return is_.flags();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set stream flags
|
//- Set stream flags
|
||||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags f)
|
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) override
|
||||||
{
|
{
|
||||||
return is_.flags(f);
|
return is_.flags(f);
|
||||||
}
|
}
|
||||||
@ -181,74 +181,81 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Read Functions
|
// Serial-stream functions
|
||||||
|
|
||||||
//- Raw, low-level get character function.
|
//- Raw, low-level get character function.
|
||||||
inline ISstream& get(char& c);
|
inline ISstream& get(char& c);
|
||||||
|
|
||||||
//- Raw, low-level peek function.
|
//- Raw, low-level peek function.
|
||||||
// Does not remove the character from the stream.
|
// Does not remove the character from the stream.
|
||||||
// Returns the next character in the stream or EOF if the
|
// Returns the next character in the stream or EOF if the
|
||||||
// end of file is read.
|
// end of file is read.
|
||||||
inline int peek();
|
inline int peek();
|
||||||
|
|
||||||
//- Raw, low-level getline (until delimiter) into a string.
|
//- Raw, low-level getline (until delimiter) into a string.
|
||||||
inline ISstream& getLine(std::string& str, char delim = '\n');
|
inline ISstream& getLine(std::string& str, char delim = '\n');
|
||||||
|
|
||||||
//- Low-level discard until delimiter
|
//- Low-level discard until delimiter
|
||||||
// \return the number of characters extracted
|
// \return the number of characters extracted
|
||||||
inline std::streamsize getLine(std::nullptr_t, char delim = '\n');
|
inline std::streamsize getLine(std::nullptr_t, char delim = '\n');
|
||||||
|
|
||||||
//- Raw, low-level putback character function.
|
//- Raw, low-level putback character function.
|
||||||
inline ISstream& putback(const char c);
|
inline ISstream& putback(const char c);
|
||||||
|
|
||||||
//- Return next token from stream
|
|
||||||
virtual Istream& read(token& t);
|
|
||||||
|
|
||||||
//- Read a character
|
|
||||||
virtual Istream& read(char& c);
|
|
||||||
|
|
||||||
//- Read a word
|
|
||||||
virtual Istream& read(word& str);
|
|
||||||
|
|
||||||
//- Read a string (including enclosing double-quotes).
|
|
||||||
// Backslashes are retained, except when escaping double-quotes
|
|
||||||
// and an embedded newline character.
|
|
||||||
virtual Istream& read(string& str);
|
|
||||||
|
|
||||||
//- Read a label
|
|
||||||
virtual Istream& read(label& val);
|
|
||||||
|
|
||||||
//- Read a float
|
|
||||||
virtual Istream& read(float& val);
|
|
||||||
|
|
||||||
//- Read a double
|
|
||||||
virtual Istream& read(double& val);
|
|
||||||
|
|
||||||
//- Read binary block (with any possible block delimiters).
|
|
||||||
//- Reading into a null pointer behaves like a forward seek of
|
|
||||||
//- count characters.
|
|
||||||
virtual Istream& read(char* data, std::streamsize count);
|
|
||||||
|
|
||||||
//- Low-level raw binary read (without possible block delimiters).
|
|
||||||
//- Reading into a null pointer behaves like a forward seek of
|
|
||||||
//- count characters.
|
|
||||||
virtual Istream& readRaw(char* data, std::streamsize count);
|
|
||||||
|
|
||||||
//- Start of low-level raw binary read
|
|
||||||
virtual bool beginRawRead();
|
|
||||||
|
|
||||||
//- End of low-level raw binary read
|
|
||||||
virtual bool endRawRead();
|
|
||||||
|
|
||||||
//- Rewind the stream so that it may be read again
|
|
||||||
virtual void rewind();
|
|
||||||
|
|
||||||
|
|
||||||
// Print
|
// Read Functions
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Return next token from stream
|
||||||
virtual void print(Ostream& os) const;
|
virtual Istream& read(token& t) override;
|
||||||
|
|
||||||
|
//- Read a character
|
||||||
|
virtual Istream& read(char& c) override;
|
||||||
|
|
||||||
|
//- Read a word
|
||||||
|
virtual Istream& read(word& str) override;
|
||||||
|
|
||||||
|
//- Read a string (including enclosing double-quotes).
|
||||||
|
// Backslashes are retained, except when escaping double-quotes
|
||||||
|
// and an embedded newline character.
|
||||||
|
virtual Istream& read(string& str) override;
|
||||||
|
|
||||||
|
//- Read a label
|
||||||
|
virtual Istream& read(label& val) override;
|
||||||
|
|
||||||
|
//- Read a float
|
||||||
|
virtual Istream& read(float& val) override;
|
||||||
|
|
||||||
|
//- Read a double
|
||||||
|
virtual Istream& read(double& val) override;
|
||||||
|
|
||||||
|
//- Read binary block (with any possible block delimiters).
|
||||||
|
//- Reading into a null pointer behaves like a forward seek of
|
||||||
|
//- count characters.
|
||||||
|
virtual Istream& read(char* data, std::streamsize count) override;
|
||||||
|
|
||||||
|
//- Low-level raw binary read (without possible block delimiters).
|
||||||
|
//- Reading into a null pointer behaves like a forward seek of
|
||||||
|
//- count characters.
|
||||||
|
virtual Istream& readRaw
|
||||||
|
(
|
||||||
|
char* data,
|
||||||
|
std::streamsize count
|
||||||
|
) override;
|
||||||
|
|
||||||
|
//- Start of low-level raw binary read
|
||||||
|
virtual bool beginRawRead() override;
|
||||||
|
|
||||||
|
//- End of low-level raw binary read
|
||||||
|
virtual bool endRawRead() override;
|
||||||
|
|
||||||
|
//- Rewind the stream so that it may be read again
|
||||||
|
virtual void rewind() override;
|
||||||
|
|
||||||
|
|
||||||
|
// Print
|
||||||
|
|
||||||
|
//- Print stream description to Ostream
|
||||||
|
virtual void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,7 +29,7 @@ License
|
|||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "token.H"
|
#include "token.H"
|
||||||
#include "OSstream.H"
|
#include "OSstream.H"
|
||||||
#include "stringOps.H"
|
#include <algorithm>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -89,70 +89,67 @@ bool Foam::OSstream::write(const token& tok)
|
|||||||
Foam::Ostream& Foam::OSstream::write(const char c)
|
Foam::Ostream& Foam::OSstream::write(const char c)
|
||||||
{
|
{
|
||||||
os_ << c;
|
os_ << c;
|
||||||
if (c == token::NL)
|
|
||||||
{
|
|
||||||
++lineNumber_;
|
|
||||||
}
|
|
||||||
syncState();
|
syncState();
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Advance line number on newline
|
||||||
Foam::Ostream& Foam::OSstream::write(const char* str)
|
if (c == token::NL) ++lineNumber_;
|
||||||
{
|
|
||||||
lineNumber_ += stringOps::count(str, token::NL);
|
|
||||||
os_ << str;
|
|
||||||
syncState();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OSstream::write(const word& str)
|
|
||||||
{
|
|
||||||
os_ << str;
|
|
||||||
syncState();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OSstream::writeQuoted
|
Foam::Ostream& Foam::OSstream::writeQuoted
|
||||||
(
|
(
|
||||||
const std::string& str,
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
const bool quoted
|
const bool quoted
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (!str || len <= 0) return *this;
|
||||||
|
|
||||||
|
const char* last = (str + len);
|
||||||
|
|
||||||
if (!quoted)
|
if (!quoted)
|
||||||
{
|
{
|
||||||
// Output unquoted, only advance line number on newline
|
#if __cplusplus >= 201703L
|
||||||
lineNumber_ += stringOps::count(str, token::NL);
|
os_ << std::string_view(str, len);
|
||||||
os_ << str;
|
#else
|
||||||
|
for (const char* iter = str; iter != last; ++iter)
|
||||||
|
{
|
||||||
|
os_ << *iter;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
syncState();
|
syncState();
|
||||||
|
|
||||||
|
// Unquoted, only advance line number on newline
|
||||||
|
lineNumber_ += std::count(str, last, '\n');
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Output with surrounding quotes and backslash escaping
|
// Output with surrounding quotes and backslash escaping
|
||||||
|
// - functionality like std::quoted (from <iomanip>), while also
|
||||||
|
// counting the newlines.
|
||||||
|
|
||||||
os_ << token::DQUOTE;
|
os_ << token::DQUOTE;
|
||||||
|
|
||||||
unsigned backslash = 0;
|
unsigned backslash = 0;
|
||||||
for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
|
for (auto iter = str; iter != last; ++iter)
|
||||||
{
|
{
|
||||||
const char c = *iter;
|
const char c = *iter;
|
||||||
|
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
{
|
{
|
||||||
++backslash;
|
++backslash;
|
||||||
continue; // only output after escaped character is known
|
continue; // Delay output until escaped character is known
|
||||||
}
|
}
|
||||||
else if (c == token::NL)
|
else if (c == token::NL)
|
||||||
{
|
{
|
||||||
++lineNumber_;
|
++backslash; // Add backslash escape for newline
|
||||||
++backslash; // backslash escape for newline
|
++lineNumber_; // Advance line number on newline
|
||||||
}
|
}
|
||||||
else if (c == token::DQUOTE)
|
else if (c == token::DQUOTE)
|
||||||
{
|
{
|
||||||
++backslash; // backslash escape for quote
|
++backslash; // Add backslash escape for quote
|
||||||
}
|
}
|
||||||
|
|
||||||
// output all pending backslashes
|
// output all pending backslashes
|
||||||
@ -174,9 +171,34 @@ Foam::Ostream& Foam::OSstream::writeQuoted
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OSstream::write(const string& str)
|
Foam::Ostream& Foam::OSstream::write(const char* str)
|
||||||
{
|
{
|
||||||
return writeQuoted(str, true);
|
if (!str) return *this;
|
||||||
|
|
||||||
|
const char* last = (str + strlen(str));
|
||||||
|
|
||||||
|
os_ << str;
|
||||||
|
syncState();
|
||||||
|
|
||||||
|
// Advance line number on newline
|
||||||
|
lineNumber_ += std::count(str, last, '\n');
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::OSstream::write(const word& str)
|
||||||
|
{
|
||||||
|
// Unquoted, and no newlines expected.
|
||||||
|
os_ << str;
|
||||||
|
syncState();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::OSstream::write(const std::string& str)
|
||||||
|
{
|
||||||
|
return writeQuoted(str.data(), str.size(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -117,7 +117,7 @@ public:
|
|||||||
|
|
||||||
//- Get the name of the output serial stream.
|
//- Get the name of the output serial stream.
|
||||||
//- (eg, the name of the Fstream file name)
|
//- (eg, the name of the Fstream file name)
|
||||||
virtual const fileName& name() const { return name_; }
|
virtual const fileName& name() const override { return name_; }
|
||||||
|
|
||||||
|
|
||||||
// STL stream
|
// STL stream
|
||||||
@ -132,13 +132,13 @@ public:
|
|||||||
// Stream State
|
// Stream State
|
||||||
|
|
||||||
//- Get stream flags
|
//- Get stream flags
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
return os_.flags();
|
return os_.flags();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set stream flags
|
//- Set stream flags
|
||||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags f)
|
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) override
|
||||||
{
|
{
|
||||||
return os_.flags(f);
|
return os_.flags(f);
|
||||||
}
|
}
|
||||||
@ -152,101 +152,108 @@ public:
|
|||||||
|
|
||||||
// Write Functions
|
// Write Functions
|
||||||
|
|
||||||
//- Write token to stream or otherwise handle it.
|
//- Inherit write methods from Ostream
|
||||||
// \return false if the token type was not handled by this method
|
using Ostream::writeQuoted;
|
||||||
virtual bool write(const token& tok);
|
|
||||||
|
|
||||||
//- Write character
|
//- Write token to stream or otherwise handle it.
|
||||||
virtual Ostream& write(const char c);
|
// \return false if the token type was not handled by this method
|
||||||
|
virtual bool write(const token& tok) override;
|
||||||
|
|
||||||
//- Write character string
|
//- Write character
|
||||||
virtual Ostream& write(const char* str);
|
virtual Ostream& write(const char c) override;
|
||||||
|
|
||||||
//- Write word
|
//- Write character/string content, with/without surrounding quotes
|
||||||
virtual Ostream& write(const word& str);
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted=true
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Write string (quoted)
|
//- Write character string
|
||||||
// In the rare case that the string contains a final trailing
|
virtual Ostream& write(const char* str) override;
|
||||||
// backslash, it will be dropped to the appearance of an escaped
|
|
||||||
// double-quote.
|
|
||||||
virtual Ostream& write(const string& str);
|
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
//- Write word
|
||||||
// Optional write without quotes.
|
virtual Ostream& write(const word& str) override;
|
||||||
virtual Ostream& writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted=true
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write int32_t
|
//- Write string (quoted)
|
||||||
virtual Ostream& write(const int32_t val);
|
// In the rare case that the string contains a final trailing
|
||||||
|
// backslash, it will be dropped to the appearance of an escaped
|
||||||
|
// double-quote.
|
||||||
|
virtual Ostream& write(const std::string& str) override;
|
||||||
|
|
||||||
//- Write int64_t
|
//- Write int32_t
|
||||||
virtual Ostream& write(const int64_t val);
|
virtual Ostream& write(const int32_t val) override;
|
||||||
|
|
||||||
//- Write float
|
//- Write int64_t
|
||||||
virtual Ostream& write(const float val);
|
virtual Ostream& write(const int64_t val) override;
|
||||||
|
|
||||||
//- Write double
|
//- Write float
|
||||||
virtual Ostream& write(const double val);
|
virtual Ostream& write(const float val) override;
|
||||||
|
|
||||||
//- Write binary block
|
//- Write double
|
||||||
virtual Ostream& write(const char* data, std::streamsize count);
|
virtual Ostream& write(const double val) override;
|
||||||
|
|
||||||
//- Low-level raw binary output
|
//- Write binary block
|
||||||
virtual Ostream& writeRaw
|
virtual Ostream& write
|
||||||
(
|
(
|
||||||
const char* data,
|
const char* data,
|
||||||
std::streamsize count
|
std::streamsize count
|
||||||
);
|
) override;
|
||||||
|
|
||||||
//- Begin marker for low-level raw binary output.
|
//- Low-level raw binary output
|
||||||
// The count indicates the number of bytes for subsequent
|
virtual Ostream& writeRaw
|
||||||
// writeRaw calls.
|
(
|
||||||
virtual bool beginRawWrite(std::streamsize count);
|
const char* data,
|
||||||
|
std::streamsize count
|
||||||
|
) override;
|
||||||
|
|
||||||
//- End marker for low-level raw binary output.
|
//- Begin marker for low-level raw binary output.
|
||||||
virtual bool endRawWrite();
|
// The count indicates the number of bytes for subsequent
|
||||||
|
// writeRaw calls.
|
||||||
|
virtual bool beginRawWrite(std::streamsize count) override;
|
||||||
|
|
||||||
//- Add indentation characters
|
//- End marker for low-level raw binary output.
|
||||||
virtual void indent();
|
virtual bool endRawWrite() override;
|
||||||
|
|
||||||
|
//- Add indentation characters
|
||||||
|
virtual void indent() override;
|
||||||
|
|
||||||
|
|
||||||
// Stream state functions
|
// Stream state functions
|
||||||
|
|
||||||
//- Flush stream
|
//- Flush stream
|
||||||
virtual void flush();
|
virtual void flush() override;
|
||||||
|
|
||||||
//- Add newline and flush stream
|
//- Add newline and flush stream
|
||||||
virtual void endl();
|
virtual void endl() override;
|
||||||
|
|
||||||
//- Get the current padding character
|
//- Get the current padding character
|
||||||
virtual char fill() const;
|
virtual char fill() const override;
|
||||||
|
|
||||||
//- Set padding character for formatted field up to field width
|
//- Set padding character for formatted field up to field width
|
||||||
// \return previous padding character
|
// \return previous padding character
|
||||||
virtual char fill(const char fillch);
|
virtual char fill(const char fillch) override;
|
||||||
|
|
||||||
//- Get width of output field
|
//- Get width of output field
|
||||||
virtual int width() const;
|
virtual int width() const override;
|
||||||
|
|
||||||
//- Set width of output field
|
//- Set width of output field
|
||||||
// \return previous width
|
// \return previous width
|
||||||
virtual int width(const int w);
|
virtual int width(const int w) override;
|
||||||
|
|
||||||
//- Get precision of output field
|
//- Get precision of output field
|
||||||
virtual int precision() const;
|
virtual int precision() const override;
|
||||||
|
|
||||||
//- Set precision of output field
|
//- Set precision of output field
|
||||||
// \return old precision
|
// \return old precision
|
||||||
virtual int precision(const int p);
|
virtual int precision(const int p) override;
|
||||||
|
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -77,11 +77,21 @@ Foam::Ostream& Foam::prefixOSstream::write(const char c)
|
|||||||
checkWritePrefix();
|
checkWritePrefix();
|
||||||
OSstream::write(c);
|
OSstream::write(c);
|
||||||
|
|
||||||
if (c == token::NL)
|
// Reset prefix state on newline
|
||||||
{
|
if (c == token::NL) printPrefix_ = true;
|
||||||
printPrefix_ = true;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::prefixOSstream::writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
checkWritePrefix();
|
||||||
|
OSstream::writeQuoted(str, len, quoted);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +102,9 @@ Foam::Ostream& Foam::prefixOSstream::write(const char* str)
|
|||||||
OSstream::write(str);
|
OSstream::write(str);
|
||||||
|
|
||||||
const size_t len = strlen(str);
|
const size_t len = strlen(str);
|
||||||
if (len && str[len-1] == token::NL)
|
if (len > 0 && str[len-1] == token::NL)
|
||||||
{
|
{
|
||||||
|
// Reset prefix state on newline
|
||||||
printPrefix_ = true;
|
printPrefix_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,26 +114,15 @@ Foam::Ostream& Foam::prefixOSstream::write(const char* str)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::prefixOSstream::write(const word& val)
|
Foam::Ostream& Foam::prefixOSstream::write(const word& val)
|
||||||
{
|
{
|
||||||
|
// Unquoted, and no newlines expected.
|
||||||
checkWritePrefix();
|
checkWritePrefix();
|
||||||
return OSstream::write(val);
|
return OSstream::write(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::prefixOSstream::write(const string& val)
|
Foam::Ostream& Foam::prefixOSstream::write(const std::string& str)
|
||||||
{
|
{
|
||||||
checkWritePrefix();
|
return writeQuoted(str.data(), str.size(), true);
|
||||||
return OSstream::write(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::prefixOSstream::writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& val,
|
|
||||||
const bool quoted
|
|
||||||
)
|
|
||||||
{
|
|
||||||
checkWritePrefix();
|
|
||||||
return OSstream::writeQuoted(val, quoted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -65,6 +65,7 @@ class prefixOSstream
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Emit pending prefix before any output
|
||||||
inline void checkWritePrefix();
|
inline void checkWritePrefix();
|
||||||
|
|
||||||
|
|
||||||
@ -83,70 +84,67 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Enquiry
|
// Enquiry
|
||||||
|
|
||||||
//- Return the stream prefix
|
//- Return the stream prefix
|
||||||
const string& prefix() const noexcept
|
const string& prefix() const noexcept { return prefix_; }
|
||||||
{
|
|
||||||
return prefix_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return non-const access to the stream prefix
|
//- Return non-const access to the stream prefix
|
||||||
string& prefix() noexcept
|
string& prefix() noexcept { return prefix_; }
|
||||||
{
|
|
||||||
return prefix_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Write Functions
|
// Write Functions
|
||||||
|
|
||||||
//- Write token to stream or otherwise handle it.
|
//- Inherit write methods from OSstream
|
||||||
// \return false if the token type was not handled by this method
|
using OSstream::writeQuoted;
|
||||||
virtual bool write(const token& tok);
|
|
||||||
|
|
||||||
//- Write character
|
//- Write token to stream or otherwise handle it.
|
||||||
virtual Ostream& write(const char c);
|
// \return false if the token type was not handled by this method
|
||||||
|
virtual bool write(const token& tok) override;
|
||||||
|
|
||||||
//- Write character string
|
//- Write character
|
||||||
virtual Ostream& write(const char* str);
|
virtual Ostream& write(const char c) override;
|
||||||
|
|
||||||
//- Write word
|
//- Write character/string content, with/without surrounding quotes
|
||||||
virtual Ostream& write(const word& val);
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted=true
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Write string
|
//- Write character string
|
||||||
virtual Ostream& write(const string& val);
|
virtual Ostream& write(const char* str) override;
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
//- Write word
|
||||||
// Optional write without quotes.
|
virtual Ostream& write(const word& val) override;
|
||||||
virtual Ostream& writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& val,
|
|
||||||
const bool quoted=true
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write int32_t
|
//- Write string
|
||||||
virtual Ostream& write(const int32_t val);
|
virtual Ostream& write(const std::string& val) override;
|
||||||
|
|
||||||
//- Write int64_t
|
//- Write int32_t
|
||||||
virtual Ostream& write(const int64_t val);
|
virtual Ostream& write(const int32_t val) override;
|
||||||
|
|
||||||
//- Write float
|
//- Write int64_t
|
||||||
virtual Ostream& write(const float val);
|
virtual Ostream& write(const int64_t val) override;
|
||||||
|
|
||||||
//- Write double
|
//- Write float
|
||||||
virtual Ostream& write(const double val);
|
virtual Ostream& write(const float val) override;
|
||||||
|
|
||||||
//- Write binary block
|
//- Write double
|
||||||
virtual Ostream& write(const char* buf, std::streamsize count);
|
virtual Ostream& write(const double val) override;
|
||||||
|
|
||||||
//- Add indentation characters
|
//- Write binary block
|
||||||
virtual void indent();
|
virtual Ostream& write(const char* buf, std::streamsize count) override;
|
||||||
|
|
||||||
|
//- Add indentation characters
|
||||||
|
virtual void indent() override;
|
||||||
|
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -166,7 +166,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
@ -263,7 +263,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Older style, without stream option (including 2012 release)
|
// Older style, without stream option (including 2012 release)
|
||||||
|
|||||||
@ -223,7 +223,7 @@ public:
|
|||||||
// Characteristics
|
// Characteristics
|
||||||
|
|
||||||
//- The name of the input token stream.
|
//- The name of the input token stream.
|
||||||
virtual const fileName& name() const { return name_; }
|
virtual const fileName& name() const override { return name_; }
|
||||||
|
|
||||||
//- The name of the input token stream, for modification.
|
//- The name of the input token stream, for modification.
|
||||||
virtual fileName& name() { return name_; }
|
virtual fileName& name() { return name_; }
|
||||||
@ -371,13 +371,13 @@ public:
|
|||||||
// Stream State Functions
|
// Stream State Functions
|
||||||
|
|
||||||
//- Get stream flags - always 0
|
//- Get stream flags - always 0
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set flags of stream - ignored
|
//- Set flags of stream - ignored
|
||||||
ios_base::fmtflags flags(const ios_base::fmtflags)
|
ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
@ -386,47 +386,47 @@ public:
|
|||||||
// Read Functions
|
// Read Functions
|
||||||
|
|
||||||
//- Return next token from stream
|
//- Return next token from stream
|
||||||
virtual Istream& read(token& tok);
|
virtual Istream& read(token& tok) override;
|
||||||
|
|
||||||
//- Read a character : triggers not implemented error
|
//- Read a character : triggers not implemented error
|
||||||
virtual Istream& read(char&);
|
virtual Istream& read(char&) override;
|
||||||
|
|
||||||
//- Read a word : triggers not implemented error
|
//- Read a word : triggers not implemented error
|
||||||
virtual Istream& read(word&);
|
virtual Istream& read(word&) override;
|
||||||
|
|
||||||
//- Read a string (including enclosing double-quotes) :
|
//- Read a string (including enclosing double-quotes) :
|
||||||
//- triggers not implemented error
|
//- triggers not implemented error
|
||||||
virtual Istream& read(string&);
|
virtual Istream& read(string&) override;
|
||||||
|
|
||||||
//- Read a label : triggers not implemented error
|
//- Read a label : triggers not implemented error
|
||||||
virtual Istream& read(label&);
|
virtual Istream& read(label&) override;
|
||||||
|
|
||||||
//- Read a float : triggers not implemented error
|
//- Read a float : triggers not implemented error
|
||||||
virtual Istream& read(float&);
|
virtual Istream& read(float&) override;
|
||||||
|
|
||||||
//- Read a double : triggers not implemented error
|
//- Read a double : triggers not implemented error
|
||||||
virtual Istream& read(double&);
|
virtual Istream& read(double&) override;
|
||||||
|
|
||||||
//- Read binary block : triggers not implemented error
|
//- Read binary block : triggers not implemented error
|
||||||
virtual Istream& read(char* data, std::streamsize);
|
virtual Istream& read(char* data, std::streamsize) override;
|
||||||
|
|
||||||
//- Low-level raw binary read : triggers not implemented error
|
//- Low-level raw binary read : triggers not implemented error
|
||||||
virtual Istream& readRaw(char* data, std::streamsize count);
|
virtual Istream& readRaw(char* data, std::streamsize count) override;
|
||||||
|
|
||||||
//- Start of low-level raw binary read : no-op
|
//- Start of low-level raw binary read : no-op
|
||||||
virtual bool beginRawRead() { return false; }
|
virtual bool beginRawRead() override { return false; }
|
||||||
|
|
||||||
//- End of low-level raw binary read : no-op
|
//- End of low-level raw binary read : no-op
|
||||||
virtual bool endRawRead() { return false; }
|
virtual bool endRawRead() override { return false; }
|
||||||
|
|
||||||
//- Rewind the stream so that it may be read again. Same as seek(0)
|
//- Rewind the stream so that it may be read again. Same as seek(0)
|
||||||
virtual void rewind();
|
virtual void rewind() override;
|
||||||
|
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
void print(Ostream& os) const;
|
void print(Ostream& os) const override;
|
||||||
|
|
||||||
//- Concatenate tokens into a space-separated std::string.
|
//- Concatenate tokens into a space-separated std::string.
|
||||||
//- The resulting string may contain quote characters.
|
//- The resulting string may contain quote characters.
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -55,9 +55,31 @@ Foam::Ostream& Foam::OTstream::write(const char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::OTstream::writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (quoted)
|
||||||
|
{
|
||||||
|
// tokenType::STRING
|
||||||
|
tokens().emplace_back() = string(str, len);
|
||||||
|
}
|
||||||
|
else if (len > 0)
|
||||||
|
{
|
||||||
|
// tokenType::WORD
|
||||||
|
tokens().emplace_back() = word(str, len, false); // No stripping
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OTstream::write(const char* str)
|
Foam::Ostream& Foam::OTstream::write(const char* str)
|
||||||
{
|
{
|
||||||
const word nonWhiteChars(string::validate<word>(str));
|
word nonWhiteChars(string::validate<word>(str));
|
||||||
|
|
||||||
if (nonWhiteChars.size() == 1)
|
if (nonWhiteChars.size() == 1)
|
||||||
{
|
{
|
||||||
@ -67,7 +89,7 @@ Foam::Ostream& Foam::OTstream::write(const char* str)
|
|||||||
else if (nonWhiteChars.size())
|
else if (nonWhiteChars.size())
|
||||||
{
|
{
|
||||||
// As a word
|
// As a word
|
||||||
write(nonWhiteChars);
|
tokens().emplace_back() = std::move(nonWhiteChars); // Move assign
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@ -76,34 +98,17 @@ Foam::Ostream& Foam::OTstream::write(const char* str)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::OTstream::write(const word& str)
|
Foam::Ostream& Foam::OTstream::write(const word& str)
|
||||||
{
|
{
|
||||||
tokens().push_back(token(str)); // tokenType::WORD
|
// tokenType::WORD
|
||||||
|
tokens().emplace_back() = str; // Copy assign
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OTstream::write(const string& str)
|
Foam::Ostream& Foam::OTstream::write(const std::string& str)
|
||||||
{
|
{
|
||||||
tokens().push_back(token(str)); // tokenType::STRING
|
// tokenType::STRING
|
||||||
|
tokens().emplace_back() = Foam::string(str); // Move assign
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OTstream::writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (quoted)
|
|
||||||
{
|
|
||||||
tokens().push_back(token(string(str))); // tokenType::STRING
|
|
||||||
}
|
|
||||||
else if (!str.empty())
|
|
||||||
{
|
|
||||||
tokens().push_back(token(word(str, false))); // tokenType::WORD
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -115,122 +115,133 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
|
//- Inherit write methods from Ostream
|
||||||
|
using Ostream::writeQuoted;
|
||||||
|
|
||||||
//- Write token to stream or otherwise handle it.
|
//- Write token to stream or otherwise handle it.
|
||||||
// \return false if the token type was not handled by this method
|
// \return false if the token type was not handled by this method
|
||||||
virtual bool write(const token& tok);
|
virtual bool write(const token& tok) override;
|
||||||
|
|
||||||
//- Write single character. Whitespace is suppressed.
|
//- Write single character. Whitespace is suppressed.
|
||||||
virtual Ostream& write(const char c);
|
virtual Ostream& write(const char c) override;
|
||||||
|
|
||||||
|
//- Write character/string content, with/without surrounding quotes
|
||||||
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted=true
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Write the word-characters of a character string.
|
//- Write the word-characters of a character string.
|
||||||
// Sends as a single char, or as word.
|
// Sends as a single char, or as word.
|
||||||
virtual Ostream& write(const char* str);
|
virtual Ostream& write(const char* str) override;
|
||||||
|
|
||||||
//- Write word
|
//- Write word
|
||||||
virtual Ostream& write(const word& str);
|
virtual Ostream& write(const word& str) override;
|
||||||
|
|
||||||
//- Write string
|
//- Write string
|
||||||
virtual Ostream& write(const string& str);
|
virtual Ostream& write(const std::string& str) override;
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
|
||||||
// Optional write without quotes.
|
|
||||||
virtual Ostream& writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted=true
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write int32_t as a label
|
//- Write int32_t as a label
|
||||||
virtual Ostream& write(const int32_t val);
|
virtual Ostream& write(const int32_t val) override;
|
||||||
|
|
||||||
//- Write int64_t as a label
|
//- Write int64_t as a label
|
||||||
virtual Ostream& write(const int64_t val);
|
virtual Ostream& write(const int64_t val) override;
|
||||||
|
|
||||||
//- Write float
|
//- Write float
|
||||||
virtual Ostream& write(const float val);
|
virtual Ostream& write(const float val) override;
|
||||||
|
|
||||||
//- Write double
|
//- Write double
|
||||||
virtual Ostream& write(const double val);
|
virtual Ostream& write(const double val) override;
|
||||||
|
|
||||||
//- Write binary block with 8-byte alignment.
|
//- Write binary block with 8-byte alignment.
|
||||||
virtual Ostream& write(const char* data, std::streamsize count);
|
virtual Ostream& write
|
||||||
|
(
|
||||||
|
const char* data,
|
||||||
|
std::streamsize count
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Low-level raw binary output.
|
//- Low-level raw binary output.
|
||||||
virtual Ostream& writeRaw(const char* data, std::streamsize count);
|
virtual Ostream& writeRaw
|
||||||
|
(
|
||||||
|
const char* data,
|
||||||
|
std::streamsize count
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Begin marker for low-level raw binary output.
|
//- Begin marker for low-level raw binary output.
|
||||||
// The count indicates the number of bytes for subsequent
|
// The count indicates the number of bytes for subsequent
|
||||||
// writeRaw calls.
|
// writeRaw calls.
|
||||||
virtual bool beginRawWrite(std::streamsize count);
|
virtual bool beginRawWrite(std::streamsize count) override;
|
||||||
|
|
||||||
//- End marker for low-level raw binary output.
|
//- End marker for low-level raw binary output.
|
||||||
virtual bool endRawWrite()
|
virtual bool endRawWrite() override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add indentation characters
|
//- Add indentation characters
|
||||||
virtual void indent()
|
virtual void indent() override
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Stream State Functions
|
// Stream State Functions
|
||||||
|
|
||||||
//- Get flags of output stream
|
//- Get flags of output stream
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set flags of stream - ignored
|
//- Set flags of stream - ignored
|
||||||
std::ios_base::fmtflags flags(const ios_base::fmtflags)
|
std::ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return ios_base::fmtflags(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Flush stream
|
//- Flush stream
|
||||||
virtual void flush()
|
virtual void flush() override
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Add newline and flush stream
|
//- Add newline and flush stream
|
||||||
virtual void endl()
|
virtual void endl() override
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Get the current padding character
|
//- Get the current padding character
|
||||||
// \return previous padding character
|
// \return previous padding character
|
||||||
virtual char fill() const
|
virtual char fill() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set padding character for formatted field up to field width
|
//- Set padding character for formatted field up to field width
|
||||||
virtual char fill(const char)
|
virtual char fill(const char) override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get width of output field
|
//- Get width of output field
|
||||||
virtual int width() const
|
virtual int width() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set width of output field
|
//- Set width of output field
|
||||||
// \return previous width
|
// \return previous width
|
||||||
virtual int width(const int)
|
virtual int width(const int) override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get precision of output field
|
//- Get precision of output field
|
||||||
virtual int precision() const
|
virtual int precision() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set precision of output field
|
//- Set precision of output field
|
||||||
// \return old precision
|
// \return old precision
|
||||||
virtual int precision(const int)
|
virtual int precision(const int) override
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -253,7 +264,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
void print(Ostream& os) const;
|
void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Additional constructors and methods (as per v2012 and earlier)
|
// Additional constructors and methods (as per v2012 and earlier)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017 OpenFOAM Foundation
|
Copyright (C) 2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -71,98 +71,101 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Read Functions
|
// Stream-state
|
||||||
|
|
||||||
//- Return next token from stream
|
//- Return flags of stream
|
||||||
virtual Istream& read(token&)
|
virtual ios_base::fmtflags flags() const override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
return ios_base::fmtflags(0);
|
||||||
return *this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//- Read a character
|
//- Set flags of stream
|
||||||
virtual Istream& read(char&)
|
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
return ios_base::fmtflags(0);
|
||||||
return *this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//- Read a word
|
|
||||||
virtual Istream& read(word&)
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read a string (including enclosing double-quotes)
|
// Read Functions
|
||||||
virtual Istream& read(string&)
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Read a label
|
//- Return next token from stream
|
||||||
virtual Istream& read(label&)
|
virtual Istream& read(token&) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Read a float
|
//- Read a character
|
||||||
virtual Istream& read(float&)
|
virtual Istream& read(char&) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Read a double
|
//- Read a word
|
||||||
virtual Istream& read(double&)
|
virtual Istream& read(word&) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Read binary block
|
// Read a string (including enclosing double-quotes)
|
||||||
virtual Istream& read(char*, std::streamsize)
|
virtual Istream& read(string&) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Low-level raw binary read
|
//- Read a label
|
||||||
virtual Istream& readRaw(char*, std::streamsize)
|
virtual Istream& read(label&) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Start of low-level raw binary read
|
//- Read a float
|
||||||
virtual bool beginRawRead()
|
virtual Istream& read(float&) override
|
||||||
{
|
{
|
||||||
return false;
|
NotImplemented;
|
||||||
}
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//- End of low-level raw binary read
|
//- Read a double
|
||||||
virtual bool endRawRead()
|
virtual Istream& read(double&) override
|
||||||
{
|
{
|
||||||
return false;
|
NotImplemented;
|
||||||
}
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//- Rewind the stream so that it may be read again
|
//- Read binary block
|
||||||
virtual void rewind()
|
virtual Istream& read(char*, std::streamsize) override
|
||||||
{}
|
{
|
||||||
|
NotImplemented;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//- Return flags of stream
|
//- Low-level raw binary read
|
||||||
virtual ios_base::fmtflags flags() const
|
virtual Istream& readRaw(char*, std::streamsize) override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
NotImplemented;
|
||||||
}
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//- Set flags of stream
|
//- Start of low-level raw binary read
|
||||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags)
|
virtual bool beginRawRead() override
|
||||||
{
|
{
|
||||||
return ios_base::fmtflags(0);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- End of low-level raw binary read
|
||||||
|
virtual bool endRawRead() override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Rewind the stream so that it may be read again
|
||||||
|
virtual void rewind() override
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -191,9 +191,9 @@ public:
|
|||||||
|
|
||||||
//- Add (unquoted) string contents.
|
//- Add (unquoted) string contents.
|
||||||
// Ensures that SHA1 of C-string or C++-string content are identical.
|
// Ensures that SHA1 of C-string or C++-string content are identical.
|
||||||
virtual Ostream& write(const string& str)
|
virtual Ostream& write(const std::string& str) override
|
||||||
{
|
{
|
||||||
return writeQuoted(str, false); // Unquoted!
|
return writeQuoted(str, false); // Unquoted!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -296,13 +296,6 @@ public:
|
|||||||
//- Span of the input characters (is modifiable!)
|
//- Span of the input characters (is modifiable!)
|
||||||
UList<char> list() const { return stream_.list(); }
|
UList<char> list() const { return stream_.list(); }
|
||||||
|
|
||||||
//- Rewind the stream, clearing any old errors
|
|
||||||
virtual void rewind()
|
|
||||||
{
|
|
||||||
stream_.rewind();
|
|
||||||
syncState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Reset content (copy)
|
//- Reset content (copy)
|
||||||
void reset(const char* buffer, size_t nbytes)
|
void reset(const char* buffer, size_t nbytes)
|
||||||
{
|
{
|
||||||
@ -325,8 +318,15 @@ public:
|
|||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Rewind the stream, clearing any old errors
|
||||||
|
virtual void rewind() override
|
||||||
|
{
|
||||||
|
stream_.rewind();
|
||||||
|
syncState();
|
||||||
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|||||||
@ -319,14 +319,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Rewind the stream, clearing any old errors
|
//- Rewind the stream, clearing any old errors
|
||||||
virtual void rewind()
|
virtual void rewind() override
|
||||||
{
|
{
|
||||||
stream_.rewind();
|
stream_.rewind();
|
||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|||||||
@ -272,13 +272,6 @@ public:
|
|||||||
//- Span of the current output characters (is modifiable!)
|
//- Span of the current output characters (is modifiable!)
|
||||||
UList<char> list() const { return stream_.list(); }
|
UList<char> list() const { return stream_.list(); }
|
||||||
|
|
||||||
//- Rewind the stream, clearing any old errors
|
|
||||||
virtual void rewind()
|
|
||||||
{
|
|
||||||
stream_.rewind();
|
|
||||||
syncState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Transfer list contents to List buffer
|
//- Transfer list contents to List buffer
|
||||||
void swap(List<char>& other)
|
void swap(List<char>& other)
|
||||||
{
|
{
|
||||||
@ -294,8 +287,15 @@ public:
|
|||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Rewind the stream, clearing any old errors
|
||||||
|
virtual void rewind()
|
||||||
|
{
|
||||||
|
stream_.rewind();
|
||||||
|
syncState();
|
||||||
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
|
|
||||||
|
|
||||||
// Houskeeping
|
// Houskeeping
|
||||||
|
|||||||
@ -255,7 +255,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -343,7 +343,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Print stream description to Ostream
|
//- Print stream description to Ostream
|
||||||
virtual void print(Ostream& os) const;
|
virtual void print(Ostream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ Foam::Istream& Foam::operator>>(Istream& is, string& val)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const string& val)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const string& val)
|
||||||
{
|
{
|
||||||
os.write(val);
|
os.write(static_cast<const std::string&>(val));
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const string& val)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const std::string& val)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const std::string& val)
|
||||||
{
|
{
|
||||||
os.write(string(val));
|
os.write(val);
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -147,13 +147,16 @@ float Foam::ensightFile::undefValue(float value) noexcept
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::Ostream& Foam::ensightFile::writeString(const char* str)
|
Foam::Ostream& Foam::ensightFile::writeString(const char* str, size_t len)
|
||||||
{
|
{
|
||||||
// Output 80 chars, but allocate for trailing nul character
|
// Output 79 chars (ASCII) or 80 chars (BINARY)
|
||||||
// to avoid -Wstringop-truncation warnings/errors.
|
char buf[80];
|
||||||
|
if (len > 80) len = 80;
|
||||||
|
|
||||||
char buf[80+1];
|
// TBD: truncate at newline? (shouldn't really occur anyhow)
|
||||||
strncpy(buf, str, 80); // max 80 chars or padded with nul if smaller
|
|
||||||
|
std::copy_n(str, len, buf);
|
||||||
|
std::fill_n(buf + len, (len - 80), '\0'); // Pad trailing with nul
|
||||||
|
|
||||||
if (format() == IOstreamOption::BINARY)
|
if (format() == IOstreamOption::BINARY)
|
||||||
{
|
{
|
||||||
@ -161,7 +164,7 @@ Foam::Ostream& Foam::ensightFile::writeString(const char* str)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf[79] = 0; // max 79 in ASCII, ensure it is indeed nul-terminated
|
buf[79] = 0; // Max 79 in ASCII
|
||||||
stdStream() << buf;
|
stdStream() << buf;
|
||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
@ -170,27 +173,33 @@ Foam::Ostream& Foam::ensightFile::writeString(const char* str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::ensightFile::writeString(const char* str)
|
||||||
|
{
|
||||||
|
return writeString(str, strlen(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::ensightFile::writeString(const std::string& str)
|
Foam::Ostream& Foam::ensightFile::writeString(const std::string& str)
|
||||||
{
|
{
|
||||||
return writeString(str.c_str());
|
return writeString(str.data(), str.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::ensightFile::write(const char* str)
|
Foam::Ostream& Foam::ensightFile::write(const char* str)
|
||||||
{
|
{
|
||||||
return writeString(str);
|
return writeString(str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::ensightFile::write(const word& str)
|
Foam::Ostream& Foam::ensightFile::write(const word& str)
|
||||||
{
|
{
|
||||||
return writeString(str);
|
return writeString(str.data(), str.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::ensightFile::write(const string& str)
|
Foam::Ostream& Foam::ensightFile::write(const std::string& str)
|
||||||
{
|
{
|
||||||
return writeString(str);
|
return writeString(str.data(), str.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -145,13 +145,12 @@ public:
|
|||||||
|
|
||||||
// Output
|
// Output
|
||||||
|
|
||||||
//- Write element keyword with trailing newline,
|
|
||||||
//- optionally with undef and the value for undefined
|
|
||||||
virtual Ostream& writeKeyword(const keyType& key);
|
|
||||||
|
|
||||||
//- Write "C Binary" string for binary files (eg, geometry/measured)
|
//- Write "C Binary" string for binary files (eg, geometry/measured)
|
||||||
Ostream& writeBinaryHeader();
|
Ostream& writeBinaryHeader();
|
||||||
|
|
||||||
|
//- Write character/string content as "%79s" or as binary (max 80 chars)
|
||||||
|
Ostream& writeString(const char* str, size_t len);
|
||||||
|
|
||||||
//- Write C-string as "%79s" or as binary (max 80 chars)
|
//- Write C-string as "%79s" or as binary (max 80 chars)
|
||||||
Ostream& writeString(const char* str);
|
Ostream& writeString(const char* str);
|
||||||
|
|
||||||
@ -162,46 +161,50 @@ public:
|
|||||||
Ostream& writeUndef();
|
Ostream& writeUndef();
|
||||||
|
|
||||||
|
|
||||||
|
//- Write element keyword with trailing newline,
|
||||||
|
//- optionally with undef and the value for undefined
|
||||||
|
virtual Ostream& writeKeyword(const keyType& key) override;
|
||||||
|
|
||||||
//- Writing token does not make sense
|
//- Writing token does not make sense
|
||||||
virtual bool write(const token&)
|
virtual bool write(const token&) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Writing single character does not make sense
|
//- Writing single character does not make sense
|
||||||
virtual Ostream& write(const char)
|
virtual Ostream& write(const char) override
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Binary write
|
//- Binary write
|
||||||
virtual Ostream& write(const char* buf, std::streamsize count);
|
virtual Ostream& write(const char* buf, std::streamsize count) override;
|
||||||
|
|
||||||
//- Write C-string, uses writeString()
|
//- Write C-string, uses writeString()
|
||||||
virtual Ostream& write(const char* str);
|
virtual Ostream& write(const char* str) override;
|
||||||
|
|
||||||
//- Write word, uses writeString()
|
//- Write word, uses writeString()
|
||||||
virtual Ostream& write(const word& str);
|
virtual Ostream& write(const word& str) override;
|
||||||
|
|
||||||
//- Write string, uses writeString()
|
//- Write string, uses writeString()
|
||||||
virtual Ostream& write(const string& str);
|
virtual Ostream& write(const std::string& str) override;
|
||||||
|
|
||||||
//- Write integer as "%10d" or as binary
|
//- Write integer as "%10d" or as binary
|
||||||
virtual Ostream& write(const int32_t val);
|
virtual Ostream& write(const int32_t val) override;
|
||||||
|
|
||||||
//- Write integer as "%10d" or as binary
|
//- Write integer as "%10d" or as binary
|
||||||
virtual Ostream& write(const int64_t val);
|
virtual Ostream& write(const int64_t val) override;
|
||||||
|
|
||||||
//- Write integer with specified width or as binary
|
//- Write integer with specified width or as binary
|
||||||
Ostream& write(const label value, const label fieldWidth);
|
Ostream& write(const label value, const label fieldWidth);
|
||||||
|
|
||||||
//- Write floating-point as "%12.5e" or as binary
|
//- Write floating-point as "%12.5e" or as binary
|
||||||
virtual Ostream& write(const float val);
|
virtual Ostream& write(const float val) override;
|
||||||
|
|
||||||
//- Write floating-point as "%12.5e" or as binary (narrowed to float)
|
//- Write floating-point as "%12.5e" or as binary (narrowed to float)
|
||||||
virtual Ostream& write(const double val);
|
virtual Ostream& write(const double val) override;
|
||||||
|
|
||||||
//- Add carriage return to ascii stream
|
//- Add carriage return to ascii stream
|
||||||
void newline();
|
void newline();
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -96,22 +96,22 @@ public:
|
|||||||
using Istream::read;
|
using Istream::read;
|
||||||
|
|
||||||
//- Binary read
|
//- Binary read
|
||||||
virtual Istream& read(char* buf, std::streamsize count);
|
virtual Istream& read(char* buf, std::streamsize count) override;
|
||||||
|
|
||||||
//- Read string as "%80s" or as binary
|
//- Read string as "%80s" or as binary
|
||||||
virtual Istream& read(string& value);
|
virtual Istream& read(string& value) override;
|
||||||
|
|
||||||
//- Read integer as "%10d" or as binary
|
//- Read integer as "%10d" or as binary
|
||||||
virtual Istream& read(label& value);
|
virtual Istream& read(label& value) override;
|
||||||
|
|
||||||
//- Read floating-point as "%12.5e" or as binary
|
//- Read floating-point as "%12.5e" or as binary
|
||||||
virtual Istream& read(float& value);
|
virtual Istream& read(float& value) override;
|
||||||
|
|
||||||
//- Read floating-point as "%12.5e" or as a binary (narrowed) float
|
//- Read floating-point as "%12.5e" or as a binary (narrowed) float
|
||||||
virtual Istream& read(double& value);
|
virtual Istream& read(double& value) override;
|
||||||
|
|
||||||
//- Read element keyword
|
//- Read element keyword. Currently the same as read(string)
|
||||||
virtual Istream& readKeyword(string& key);
|
Istream& readKeyword(string& key);
|
||||||
|
|
||||||
//- Read "C Binary" for binary files (eg, geometry/measured)
|
//- Read "C Binary" for binary files (eg, geometry/measured)
|
||||||
Istream& readBinaryHeader();
|
Istream& readBinaryHeader();
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,7 +40,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::OBJstream::writeAndCheck(const char c)
|
inline void Foam::OBJstream::vertex_state(const char c)
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
@ -54,8 +54,6 @@ void Foam::OBJstream::writeAndCheck(const char c)
|
|||||||
++nVertices_;
|
++nVertices_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream::write(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,16 +75,51 @@ Foam::OBJstream::OBJstream
|
|||||||
|
|
||||||
Foam::Ostream& Foam::OBJstream::write(const char c)
|
Foam::Ostream& Foam::OBJstream::write(const char c)
|
||||||
{
|
{
|
||||||
writeAndCheck(c);
|
OFstream::write(c);
|
||||||
|
vertex_state(c);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::OBJstream::writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OFstream::writeQuoted(str, len, quoted);
|
||||||
|
|
||||||
|
// NOTE:
|
||||||
|
// Since vertex_state() handling only tracks newline followed by
|
||||||
|
// an initial 'v' (vertex) character, it probably should not be possible
|
||||||
|
// to triggered from within a quoted string.
|
||||||
|
|
||||||
|
if (str && len >= 0)
|
||||||
|
{
|
||||||
|
if (quoted) vertex_state(0); // Begin quote: reset state
|
||||||
|
|
||||||
|
const char* last = (str + len);
|
||||||
|
|
||||||
|
// std::for_each
|
||||||
|
for (const char* iter = str; iter != last; ++iter)
|
||||||
|
{
|
||||||
|
vertex_state(*iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quoted) vertex_state(0); // End quote
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OBJstream::write(const char* str)
|
Foam::Ostream& Foam::OBJstream::write(const char* str)
|
||||||
{
|
{
|
||||||
|
OFstream::write(str);
|
||||||
for (const char* iter = str; *iter; ++iter)
|
for (const char* iter = str; *iter; ++iter)
|
||||||
{
|
{
|
||||||
writeAndCheck(*iter);
|
vertex_state(*iter);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -94,68 +127,54 @@ Foam::Ostream& Foam::OBJstream::write(const char* str)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::OBJstream::write(const word& str)
|
Foam::Ostream& Foam::OBJstream::write(const word& str)
|
||||||
{
|
{
|
||||||
return writeQuoted(str, false);
|
return writeQuoted(str.data(), str.size(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OBJstream::write(const string& str)
|
Foam::Ostream& Foam::OBJstream::write(const std::string& str)
|
||||||
{
|
{
|
||||||
return writeQuoted(str, true);
|
return writeQuoted(str.data(), str.size(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::OBJstream::writeQuoted
|
Foam::Ostream& Foam::OBJstream::writeComment(const std::string& str)
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!quoted)
|
if (!startOfLine_)
|
||||||
{
|
{
|
||||||
// Output unquoted, only advance line number on newline
|
OFstream::write('\n');
|
||||||
for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
|
startOfLine_ = true;
|
||||||
{
|
}
|
||||||
writeAndCheck(*iter);
|
|
||||||
}
|
if (str.empty())
|
||||||
|
{
|
||||||
|
OFstream::write("#\n");
|
||||||
|
startOfLine_ = true;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output with surrounding quotes and backslash escaping
|
const char* iter = str.data();
|
||||||
OFstream::write(static_cast<char>(token::DQUOTE));
|
const char* last = (str.data() + str.size());
|
||||||
|
|
||||||
unsigned backslash = 0;
|
// std::for_each
|
||||||
for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
|
for (; iter != last; ++iter)
|
||||||
{
|
{
|
||||||
const char c = *iter;
|
const char c = *iter;
|
||||||
|
|
||||||
if (c == '\\')
|
if (startOfLine_)
|
||||||
{
|
{
|
||||||
++backslash;
|
OFstream::write("# ");
|
||||||
continue; // only output after escaped character is known
|
startOfLine_ = false;
|
||||||
}
|
|
||||||
else if (c == token::NL)
|
|
||||||
{
|
|
||||||
++lineNumber_;
|
|
||||||
++backslash; // backslash escape for newline
|
|
||||||
}
|
|
||||||
else if (c == token::DQUOTE)
|
|
||||||
{
|
|
||||||
++backslash; // backslash escape for quote
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// output all pending backslashes
|
startOfLine_ = (c == '\n');
|
||||||
while (backslash)
|
OFstream::write(c);
|
||||||
{
|
|
||||||
OFstream::write('\\');
|
|
||||||
--backslash;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeAndCheck(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// silently drop any trailing backslashes
|
if (!startOfLine_)
|
||||||
// they would otherwise appear like an escaped end-quote
|
{
|
||||||
OFstream::write(static_cast<char>(token::DQUOTE));
|
OFstream::write('\n');
|
||||||
|
startOfLine_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012-2015 OpenFOAM Foundation
|
Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -70,7 +70,9 @@ class OBJstream
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
void writeAndCheck(const char c);
|
//- State engine to count number of vertices.
|
||||||
|
//- Triggered on newline and 'v' (vertex).
|
||||||
|
inline void vertex_state(const char c);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -105,104 +107,107 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
//- Return the number of vertices written
|
//- Return the number of vertices written
|
||||||
label nVertices() const noexcept
|
label nVertices() const noexcept { return nVertices_; }
|
||||||
{
|
|
||||||
return nVertices_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream implementation
|
// Write Functions
|
||||||
|
|
||||||
//- Inherit write from Ostream
|
//- Inherit write methods from OFstream
|
||||||
using Ostream::write;
|
using OFstream::write;
|
||||||
|
using OFstream::writeQuoted;
|
||||||
|
|
||||||
//- Write character
|
//- Write character
|
||||||
virtual Ostream& write(const char c);
|
virtual Ostream& write(const char c) override;
|
||||||
|
|
||||||
//- Write character string
|
//- Write character/string content, with/without surrounding quotes
|
||||||
virtual Ostream& write(const char* str);
|
virtual Ostream& writeQuoted
|
||||||
|
(
|
||||||
|
const char* str,
|
||||||
|
std::streamsize len,
|
||||||
|
const bool quoted=true
|
||||||
|
) override;
|
||||||
|
|
||||||
//- Write word
|
//- Write character string
|
||||||
virtual Ostream& write(const word& str);
|
virtual Ostream& write(const char* str) override;
|
||||||
|
|
||||||
//- Write string
|
//- Write word
|
||||||
virtual Ostream& write(const string& str);
|
virtual Ostream& write(const word& str) override;
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
//- Write string
|
||||||
// Optional write without quotes.
|
virtual Ostream& write(const std::string& str) override;
|
||||||
virtual Ostream& writeQuoted
|
|
||||||
(
|
|
||||||
const std::string& str,
|
|
||||||
const bool quoted=true
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Direct write functionality
|
// Direct write functionality
|
||||||
|
|
||||||
//- Write point
|
//- Write comment (with '# ' prefix)
|
||||||
Ostream& write(const point& p);
|
Ostream& writeComment(const std::string& str);
|
||||||
|
|
||||||
//- Write point and vector normal ('vn')
|
//- Write point (vertex)
|
||||||
Ostream& write(const point& p, const vector& n);
|
Ostream& write(const point& p);
|
||||||
|
|
||||||
//- Write multiple points
|
//- Write point and vector normal ('vn')
|
||||||
Ostream& write(const UList<point>& points);
|
Ostream& write(const point& p, const vector& n);
|
||||||
|
|
||||||
//- Write edge as points with line
|
//- Write multiple points
|
||||||
Ostream& write(const edge& e, const UList<point>& points);
|
Ostream& write(const UList<point>& points);
|
||||||
|
|
||||||
//- Write line
|
//- Write edge as points with line
|
||||||
Ostream& write(const linePointRef& ln);
|
Ostream& write(const edge& e, const UList<point>& points);
|
||||||
|
|
||||||
//- Write line with points and vector normals ('vn')
|
//- Write line
|
||||||
Ostream& write
|
Ostream& write(const linePointRef& ln);
|
||||||
(
|
|
||||||
const linePointRef& ln,
|
|
||||||
const vector& n0,
|
|
||||||
const vector& n1
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write line joining two points
|
//- Write line with points and vector normals ('vn')
|
||||||
Ostream& writeLine(const point& p0, const point& p1);
|
Ostream& write
|
||||||
|
(
|
||||||
|
const linePointRef& ln,
|
||||||
|
const vector& n0,
|
||||||
|
const vector& n1
|
||||||
|
);
|
||||||
|
|
||||||
//- Write triangle as points with lines/filled-polygon
|
//- Write line joining two points
|
||||||
Ostream& write(const triPointRef& f, const bool lines = true);
|
Ostream& writeLine(const point& p0, const point& p1);
|
||||||
|
|
||||||
//- Write face loop points with lines/filled-polygon
|
//- Write triangle as points with lines/filled-polygon
|
||||||
Ostream& writeFace
|
Ostream& write(const triPointRef& f, const bool lines = true);
|
||||||
(
|
|
||||||
const UList<point>& points,
|
|
||||||
const bool lines = true
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write face as points with lines/filled-polygon
|
//- Write face loop points with lines/filled-polygon
|
||||||
Ostream& write
|
Ostream& writeFace
|
||||||
(
|
(
|
||||||
const face& f,
|
const UList<point>& points,
|
||||||
const UList<point>& points,
|
const bool lines = true
|
||||||
const bool lines = true
|
);
|
||||||
);
|
|
||||||
|
|
||||||
//- Write patch faces as points with lines/filled-polygon
|
//- Write face as points with lines/filled-polygon
|
||||||
Ostream& write
|
Ostream& write
|
||||||
(
|
(
|
||||||
const UList<face>& faces,
|
const face& f,
|
||||||
const pointField& points,
|
const UList<point>& points,
|
||||||
const bool lines = true
|
const bool lines = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write edges as points with lines.
|
//- Write patch faces as points with lines/filled-polygon
|
||||||
// Optionally eliminate unused points.
|
Ostream& write
|
||||||
Ostream& write
|
(
|
||||||
(
|
const UList<face>& faces,
|
||||||
const UList<edge>& edges,
|
const pointField& points,
|
||||||
const UList<point>& points,
|
const bool lines = true
|
||||||
const bool compact = false
|
);
|
||||||
);
|
|
||||||
|
|
||||||
//- Write tree-bounding box with lines/filled-polygons
|
//- Write edges as points with lines.
|
||||||
Ostream& write(const treeBoundBox& bb, const bool lines = true);
|
// Optionally eliminate unused points.
|
||||||
|
Ostream& write
|
||||||
|
(
|
||||||
|
const UList<edge>& edges,
|
||||||
|
const UList<point>& points,
|
||||||
|
const bool compact = false
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write tree-bounding box with lines/filled-polygons
|
||||||
|
Ostream& write(const treeBoundBox& bb, const bool lines = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user