ENH: consolidate stream allocators

- add count() member for output span streams (consistency)

- ITstream construct/parse from span/view

COMP: remove old/unused first()/last() methods from SubStrings
This commit is contained in:
Mark Olesen
2024-02-09 11:03:48 +01:00
parent 732c8b3330
commit 5a0fba84b4
15 changed files with 280 additions and 352 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2023 OpenCFD Ltd.
Copyright (C) 2020-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -132,7 +132,7 @@ public:
// Member Functions
//- True if compiled with libz support
static bool supports_gz();
static bool supports_gz() noexcept;
// Access
@ -276,7 +276,7 @@ public:
// Member Functions
//- True if compiled with libz support
static bool supports_gz();
static bool supports_gz() noexcept;
// Access

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,7 +40,7 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::ifstreamPointer::supports_gz()
bool Foam::ifstreamPointer::supports_gz() noexcept
{
#ifdef HAVE_LIBZ
return true;
@ -50,7 +50,7 @@ bool Foam::ifstreamPointer::supports_gz()
}
bool Foam::ofstreamPointer::supports_gz()
bool Foam::ofstreamPointer::supports_gz() noexcept
{
#ifdef HAVE_LIBZ
return true;
@ -71,7 +71,7 @@ Foam::ifstreamPointer::ifstreamPointer
IOstreamOption streamOpt // Currently unused
)
:
ptr_(nullptr)
ptr_()
{
open(pathname, streamOpt);
}
@ -82,7 +82,7 @@ Foam::ifstreamPointer::ifstreamPointer
const fileName& pathname
)
:
ptr_(nullptr)
ptr_()
{
open(pathname);
}
@ -110,7 +110,7 @@ Foam::ofstreamPointer::ofstreamPointer
const bool atomic
)
:
ptr_(nullptr),
ptr_(),
atomic_(atomic)
{
std::ios_base::openmode mode

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -468,6 +468,41 @@ inline IOstream& scientific(IOstream& io)
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::StreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A wrapper to hold a std::stream type for OpenFOAM wrapped streams.
//- This is necessary since the OpenFOAM streams hold a reference to
//- the normal std::stream
template<class StreamType>
class StreamAllocator
{
protected:
// Protected Data
//- The std::stream
StreamType stream_;
// Constructors
//- Default construct (empty)
StreamAllocator() = default;
};
} // End namespace Detail
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Functions/Algorithms
namespace Detail
{
//- Termination for input looping (no-op)
template<class IS> inline void inputLoop(IS&) {}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -46,60 +46,6 @@ SourceFiles
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::StringStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- Allocator for variants of a std stringstream
template<class StreamType>
class StringStreamAllocator
{
protected:
// Protected Member Data
//- The stream type
typedef StreamType stream_type;
//- The input/output stream.
stream_type stream_;
// Constructors
//- Default construct
StringStreamAllocator() = default;
//- Copy construct from string
StringStreamAllocator(const std::string& s)
:
stream_(s)
{}
public:
// Member Functions
//- Get the string - as Foam::string rather than std::string
Foam::string str() const
{
return Foam::string(stream_.str());
}
//- Set the string
void str(const std::string& s)
{
stream_.str(s);
}
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class IStringStream Declaration
\*---------------------------------------------------------------------------*/
@ -107,10 +53,12 @@ public:
//- Input from string buffer, using a ISstream. Always UNCOMPRESSED.
class IStringStream
:
public Detail::StringStreamAllocator<std::istringstream>,
public ISstream
public Foam::Detail::StreamAllocator<std::istringstream>,
public Foam::ISstream
{
typedef Detail::StringStreamAllocator<std::istringstream> allocator_type;
typedef
Foam::Detail::StreamAllocator<std::istringstream>
allocator_type;
public:
@ -133,9 +81,11 @@ public:
IOstreamOption streamOpt = IOstreamOption()
)
:
allocator_type(s),
allocator_type(),
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
{}
{
stream_.str(s);
}
//- Construct from char*
explicit IStringStream
@ -144,20 +94,32 @@ public:
IOstreamOption streamOpt = IOstreamOption()
)
:
allocator_type(s),
allocator_type(),
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
{}
{
stream_.str(s);
}
//- Copy construct, copies content and format
IStringStream(const IStringStream& str)
:
allocator_type(str.str()),
allocator_type(),
ISstream(stream_, str.name(), static_cast<IOstreamOption>(str))
{}
{
stream_.str(str.str());
}
// Member Functions
//- Get the string.
//- As Foam::string instead of std::string (may change in future)
Foam::string str() const { return Foam::string(stream_.str()); }
//- Set the string
void str(const std::string& s) { stream_.str(s); }
//- Reset the input buffer and rewind the stream
virtual void reset(const std::string& s)
{
@ -220,10 +182,12 @@ public:
//- Output to string buffer, using a OSstream. Always UNCOMPRESSED.
class OStringStream
:
public Detail::StringStreamAllocator<std::ostringstream>,
public OSstream
public Foam::Detail::StreamAllocator<std::ostringstream>,
public Foam::OSstream
{
typedef Detail::StringStreamAllocator<std::ostringstream> allocator_type;
typedef
Foam::Detail::StreamAllocator<std::ostringstream>
allocator_type;
public:
@ -242,13 +206,23 @@ public:
//- Copy construct, copies content and format
OStringStream(const OStringStream& str)
:
allocator_type(str.str()),
allocator_type(),
OSstream(stream_, str.name(), static_cast<IOstreamOption>(str))
{}
{
stream_.str(str.str());
}
// Member Functions
//- Get the string.
//- As Foam::string instead of std::string (may change in future)
Foam::string str() const { return Foam::string(stream_.str()); }
//- Set the string
void str(const std::string& s) { stream_.str(s); }
//- Reset the output buffer and rewind the stream
void reset()
{

View File

@ -91,13 +91,14 @@ Foam::ITstream& Foam::ITstream::empty_stream()
}
Foam::tokenList Foam::ITstream::parse
Foam::tokenList Foam::ITstream::parse_chars
(
const UList<char>& input,
const char* s,
size_t nbytes,
IOstreamOption streamOpt
)
{
ISpanStream is(input, streamOpt);
ISpanStream is(s, nbytes, streamOpt);
tokenList tokens;
parseStream(is, tokens);
@ -105,31 +106,14 @@ Foam::tokenList Foam::ITstream::parse
}
Foam::tokenList Foam::ITstream::parse
(
const std::string& input,
IOstreamOption streamOpt
)
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::ITstream::reset(const char* input, size_t nbytes)
{
ISpanStream is(input, streamOpt);
ISpanStream is(input, nbytes, static_cast<IOstreamOption>(*this));
tokenList tokens;
parseStream(is, tokens);
return tokens;
}
Foam::tokenList Foam::ITstream::parse
(
const char* input,
IOstreamOption streamOpt
)
{
ISpanStream is(input, strlen(input), streamOpt);
tokenList tokens;
parseStream(is, tokens);
return tokens;
parseStream(is, static_cast<tokenList&>(*this));
ITstream::seek(0); // rewind(), but bypasss virtual
}
@ -254,10 +238,7 @@ Foam::ITstream::ITstream
:
ITstream(streamOpt, name)
{
ISpanStream is(input, streamOpt);
parseStream(is, static_cast<tokenList&>(*this));
ITstream::seek(0); // rewind(), but bypasss virtual
reset(input.cdata(), input.size_bytes());
}
@ -270,10 +251,7 @@ Foam::ITstream::ITstream
:
ITstream(streamOpt, name)
{
ISpanStream is(input, streamOpt);
parseStream(is, static_cast<tokenList&>(*this));
ITstream::seek(0); // rewind(), but bypasss virtual
reset(input.data(), input.size());
}
@ -286,10 +264,7 @@ Foam::ITstream::ITstream
:
ITstream(streamOpt, name)
{
ISpanStream is(input, strlen(input), streamOpt);
parseStream(is, static_cast<tokenList&>(*this));
ITstream::seek(0); // rewind(), but bypasss virtual
reset(input, strlen(input));
}

View File

@ -77,6 +77,18 @@ class ITstream
// but leave any excess capacity (ie, like reserve).
void reserveCapacity(const label newCapacity);
//- Convert input sequence into a list of tokens,
static tokenList parse_chars
(
const char* s,
size_t nbytes,
IOstreamOption streamOpt
);
//- Convert input sequence into a list of tokens,
//- using the existing stream format. Rewinds the stream
void reset(const char* input, size_t nbytes);
//- Failsafe read-access to token at specified location
//- or undefinedToken
inline const token& peekNoFail(const label i) const
@ -158,6 +170,47 @@ public:
const string& name = "input"
);
#if __cplusplus >= 201703L
//- Construct token list by parsing the input character sequence
// Uses static parse function internally.
explicit ITstream
(
std::string_view s,
IOstreamOption streamOpt = IOstreamOption()
)
:
ITstream(streamOpt)
{
reset(s.data(), s.size());
}
#endif
//- Construct token list by parsing the input character sequence
// Uses static parse function internally.
explicit ITstream
(
stdFoam::span<char> s,
IOstreamOption streamOpt = IOstreamOption()
)
:
ITstream(streamOpt)
{
reset(s.data(), s.size());
}
//- Construct token list by parsing the input character sequence
// Uses static parse function internally.
explicit ITstream
(
stdFoam::span<const char> s,
IOstreamOption streamOpt = IOstreamOption()
)
:
ITstream(streamOpt)
{
reset(s.data(), s.size());
}
// Additional constructors
@ -207,7 +260,10 @@ public:
(
const UList<char>& input,
IOstreamOption streamOpt = IOstreamOption()
);
)
{
return parse_chars(input.cdata(), input.size(), streamOpt);
}
//- Create token list by parsing the input string
//- until no good tokens remain.
@ -215,7 +271,10 @@ public:
(
const std::string& input,
IOstreamOption streamOpt = IOstreamOption()
);
)
{
return parse_chars(input.data(), input.size(), streamOpt);
}
//- Create token list by parsing the input character sequence
//- until no good tokens remain.
@ -223,7 +282,45 @@ public:
(
const char* input,
IOstreamOption streamOpt = IOstreamOption()
);
)
{
return parse_chars(input, strlen(input), streamOpt);
}
#if __cplusplus >= 201703L
//- Create token list by parsing the input character sequence
//- until no good tokens remain.
static tokenList parse
(
std::string_view s,
IOstreamOption streamOpt = IOstreamOption()
)
{
return parse_chars(s.data(), s.size(), streamOpt);
}
#endif
//- Create token list by parsing the input character sequence
//- until no good tokens remain.
static tokenList parse
(
stdFoam::span<char> s,
IOstreamOption streamOpt = IOstreamOption()
)
{
return parse_chars(s.data(), s.size(), streamOpt);
}
//- Create token list by parsing the input character sequence
//- until no good tokens remain.
static tokenList parse
(
stdFoam::span<const char> s,
IOstreamOption streamOpt = IOstreamOption()
)
{
return parse_chars(s.data(), s.size(), streamOpt);
}
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ Description
#ifndef Foam_OSHA1stream_H
#define Foam_OSHA1stream_H
#include "OSstream.H"
#include "SHA1.H"
#include "OSstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -114,33 +114,6 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::OSHA1streamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for holding Foam::osha1stream
class OSHA1streamAllocator
{
protected:
// Protected Data
//- The output stream
Foam::osha1stream stream_;
// Constructors
//- Default construct
OSHA1streamAllocator() = default;
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class OSHA1stream Declaration
\*---------------------------------------------------------------------------*/
@ -148,10 +121,12 @@ protected:
//- The output stream for calculating SHA1 digests
class OSHA1stream
:
public Detail::OSHA1streamAllocator,
public OSstream
public Foam::Detail::StreamAllocator<Foam::osha1stream>,
public Foam::OSstream
{
typedef Detail::OSHA1streamAllocator allocator_type;
typedef
Foam::Detail::StreamAllocator<Foam::osha1stream>
allocator_type;
public:

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,8 +42,6 @@ See Also
#define Foam_ICharStream_H
#include "ISpanStream.H"
#include "List.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -205,33 +203,6 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::ICharStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for holding Foam::icharstream
class ICharStreamAllocator
{
protected:
// Protected Data
//- The stream
Foam::icharstream stream_;
// Constructors
//- Default construct
ICharStreamAllocator() = default;
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class ICharStream Declaration
\*---------------------------------------------------------------------------*/
@ -239,10 +210,12 @@ protected:
//- An ISstream with internal List storage. Always UNCOMPRESSED.
class ICharStream
:
public Detail::ICharStreamAllocator,
public Foam::Detail::StreamAllocator<Foam::icharstream>,
public Foam::ISstream
{
typedef Detail::ICharStreamAllocator allocator_type;
typedef
Foam::Detail::StreamAllocator<Foam::icharstream>
allocator_type;
public:

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,7 +65,6 @@ See Also
#define Foam_ISpanStream_H
#include "memoryStreamBuffer.H"
#include "UList.H"
#include "ISstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -213,49 +212,23 @@ public:
//- Some information about the input buffer position/capacity
void debug_info(Ostream& os) const
{
os << "get="
<< input_pos() << '/' << capacity();
os << "get=" << input_pos() << '/' << capacity();
}
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::ISpanStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for holding Foam::ispanstream
class ISpanStreamAllocator
{
protected:
// Protected Data
//- The stream
Foam::ispanstream stream_;
// Constructors
//- Default construct (empty)
ISpanStreamAllocator() = default;
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class ISpanStream Declaration
\*---------------------------------------------------------------------------*/
class ISpanStream
:
public Detail::ISpanStreamAllocator,
public Foam::Detail::StreamAllocator<Foam::ispanstream>,
public Foam::ISstream
{
typedef Detail::ISpanStreamAllocator allocator_type;
typedef
Foam::Detail::StreamAllocator<Foam::ispanstream>
allocator_type;
public:

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -109,7 +109,13 @@ public:
//- The current output position within the buffer (tellp)
std::streampos output_pos() const
{
return (buffer_type::span_tellp());
return buffer_type::span_tellp();
}
//- The number of bytes outputted
std::streamsize count() const
{
return buffer_type::size_bytes();
}
//- The put buffer capacity
@ -189,33 +195,6 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::OCharStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for holding Foam::ocharstream
class OCharStreamAllocator
{
protected:
// Protected Data
//- The stream
Foam::ocharstream stream_;
// Constructors
//- Default construct - empty
OCharStreamAllocator() = default;
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class OCharStream Declaration
\*---------------------------------------------------------------------------*/
@ -223,10 +202,12 @@ protected:
//- An OSstream with internal List storage
class OCharStream
:
public Detail::OCharStreamAllocator,
public Foam::Detail::StreamAllocator<Foam::ocharstream>,
public Foam::OSstream
{
typedef Detail::OCharStreamAllocator allocator_type;
typedef
Foam::Detail::StreamAllocator<Foam::ocharstream>
allocator_type;
public:
@ -277,8 +258,11 @@ public:
//- The current output position within the buffer (tellp)
std::streampos output_pos() const { return stream_.output_pos(); }
//- The current output size. Same as tellp(), output_pos()
label size() const { return label(stream_.output_pos()); }
//- The number of bytes outputted
std::streamsize count() const { return stream_.count(); }
//- The current output size. Same as count(), output_pos(), tellp().
label size() const { return label(stream_.count()); }
//- The put buffer capacity
std::streamsize capacity() const { return stream_.capacity(); }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +35,6 @@ Description
#define Foam_OScountStream_H
#include "OSstream.H"
#include <iostream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -126,7 +125,7 @@ class ocountstream
// Member Functions
//- The number of bytes counted.
//- The number of bytes counted
std::streamsize count() const noexcept { return size_; }
//- Reset the count
@ -155,7 +154,7 @@ public:
//- This hides both signatures of std::basic_ios::rdbuf()
countbuf* rdbuf() { return &buf_; }
//- \return The number of bytes counted
//- The number of bytes counted
std::streamsize count() const noexcept { return buf_.count(); }
//- Reset the count
@ -173,33 +172,6 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::OCountStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for holding Foam::ocountstream
class OCountStreamAllocator
{
protected:
// Protected Data
//- The output stream
Foam::ocountstream stream_;
// Constructors
//- Default construct
OCountStreamAllocator() = default;
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class OCountStream Declaration
\*---------------------------------------------------------------------------*/
@ -207,10 +179,12 @@ protected:
//- An output stream for calculating byte counts
class OCountStream
:
public Detail::OCountStreamAllocator,
public OSstream
public Foam::Detail::StreamAllocator<Foam::ocountstream>,
public Foam::OSstream
{
typedef Detail::OCountStreamAllocator allocator_type;
typedef
Foam::Detail::StreamAllocator<Foam::ocountstream>
allocator_type;
public:
@ -238,10 +212,10 @@ public:
// Member Functions
//- \return The number of bytes counted
//- The number of bytes counted
std::streamsize count() const noexcept { return stream_.count(); }
//- \return The number of bytes counted
//- The number of bytes counted
std::streamsize size() const noexcept { return stream_.count(); }
//- Reset the count

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -83,7 +83,6 @@ See Also
#define Foam_OSpanStream_H
#include "memoryStreamBuffer.H"
#include "DynamicList.H"
#include "OSstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -141,6 +140,12 @@ public:
return buffer_type::span_tellp();
}
//- The number of bytes outputted
std::streamsize count() const
{
return buffer_type::size_bytes();
}
//- The put buffer capacity
std::streamsize capacity() const
{
@ -199,49 +204,23 @@ public:
//- Some information about the output buffer position/capacity
void debug_info(Ostream& os) const
{
os << "put="
<< output_pos() << '/' << capacity();
os << "put=" << output_pos() << '/' << capacity();
}
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::OSpanStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for holding Foam::ospanstream
class OSpanStreamAllocator
{
protected:
// Protected Data
//- The stream
Foam::ospanstream stream_;
// Constructors
//- Default construct (empty)
OSpanStreamAllocator() = default;
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class OSpanStream Declaration
\*---------------------------------------------------------------------------*/
class OSpanStream
:
public Detail::OSpanStreamAllocator,
public Foam::Detail::StreamAllocator<Foam::ospanstream>,
public Foam::OSstream
{
typedef Detail::OSpanStreamAllocator allocator_type;
typedef
Foam::Detail::StreamAllocator<Foam::ospanstream>
allocator_type;
public:
@ -314,8 +293,11 @@ public:
//- The current output position within the buffer (tellp)
std::streampos output_pos() const { return stream_.output_pos(); }
//- The current output size. Same as tellp(), output_pos()
label size() const { return label(stream_.output_pos()); }
//- The number of bytes outputted
std::streamsize count() const { return stream_.count(); }
//- The current output size. Same as count(), output_pos(), tellp().
label size() const { return label(stream_.count()); }
//- The put buffer capacity
std::streamsize capacity() const { return stream_.capacity(); }

View File

@ -109,19 +109,14 @@ public:
this->push_back(range);
}
//- Const reference to the first element,
//- for consistency with other OpenFOAM containers
auto first() const -> decltype(this->front())
{
return this->front();
}
//- Const reference to the last element,
//- for consistency with other OpenFOAM containers
auto last() const -> decltype(this->back())
{
return this->back();
}
// FUTURE?
// #if __cplusplus >= 201703L
// std::string_view view(size_t pos) const
// {}
// #else
// stdFoam::span<const char> view(size_t pos) const
// {}
// #endif
};

View File

@ -63,14 +63,6 @@ Foam::Detail::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::Detail::MeshedSurfaceIOAllocator::~MeshedSurfaceIOAllocator()
{
clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::Detail::MeshedSurfaceIOAllocator::setInstance

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,7 +39,7 @@ SourceFiles
#define Foam_MeshedSurfaceIOAllocator_H
#include "pointIOField.H"
#include "faceIOList.H"
#include "faceIOList.H" // faceIOList and faceCompactIOList
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,8 +62,9 @@ class MeshedSurfaceIOAllocator
//- Faces
faceCompactIOList faces_;
public:
// Private Member Functions
// Generated Methods
//- No copy construct
MeshedSurfaceIOAllocator(const MeshedSurfaceIOAllocator&) = delete;
@ -72,8 +73,6 @@ class MeshedSurfaceIOAllocator
void operator=(const MeshedSurfaceIOAllocator&) = delete;
public:
// Constructors
//- Read construct from IOobjects
@ -99,7 +98,7 @@ public:
//- Destructor
virtual ~MeshedSurfaceIOAllocator();
virtual ~MeshedSurfaceIOAllocator() = default;
// Member Functions
@ -116,25 +115,25 @@ public:
// Access
//- Non-const access to the points
pointIOField& storedIOPoints()
pointIOField& storedIOPoints() noexcept
{
return points_;
}
//- Non-const access to the faces
faceCompactIOList& storedIOFaces()
faceCompactIOList& storedIOFaces() noexcept
{
return faces_;
}
//- Const access to the points
const pointIOField& storedIOPoints() const
const pointIOField& storedIOPoints() const noexcept
{
return points_;
}
//- Const access to the faces
const faceCompactIOList& storedIOFaces() const
const faceCompactIOList& storedIOFaces() const noexcept
{
return faces_;
}