35 #ifndef Foam_memoryStreamBuffer_H 36 #define Foam_memoryStreamBuffer_H 42 #include <type_traits> 64 std::ios_base::seekdir way,
65 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
68 const bool testin = which & std::ios_base::in;
69 const bool testout = which & std::ios_base::out;
71 if (way == std::ios_base::beg)
75 setg(eback(), eback(), egptr());
80 setp(pbase(), epptr());
84 else if (way == std::ios_base::cur)
99 setg(eback(), eback(), egptr());
100 gbump(egptr() - eback() - off);
104 setp(pbase(), epptr());
105 pbump(epptr() - pbase() - off);
111 return (gptr() - eback());
115 return (pptr() - pbase());
126 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
129 return seekoff(
pos, std::ios_base::beg, which);
147 class memorybuf::in_base
154 virtual std::streamsize
xsgetn(
char*
s, std::streamsize
n)
156 std::streamsize
count = 0;
159 *(
s +
count++) = *(gptr());
186 void resetg(
char*
s, std::streamsize
n)
194 setg(
nullptr,
nullptr,
nullptr);
199 std::streamsize
span_tellg()
const {
return (gptr() - eback()); }
202 std::streamsize
span_capacity()
const {
return (egptr() - eback()); }
207 return (gptr() < egptr()) ? (egptr() - gptr()) : 0;
214 std::streamsize
size_bytes()
const {
return (egptr() - eback()); }
216 #if __cplusplus >= 201703L 217 std::string_view
view()
const 264 std::copy(
s, (
s +
n), storage_.
data());
272 storage_(
std::move(buffer))
278 template<
int SizeMin>
296 void reset(
const char*
s, std::streamsize
n)
301 std::copy(
s, (
s +
n), storage_.
data());
311 void swap(List<char>& other)
313 other.swap(storage_);
318 template<
int SizeMin>
322 other.
swap(storage_);
348 virtual std::streamsize
xsputn(
const char*
s, std::streamsize
n)
350 std::streamsize
count = 0;
351 while (
count <
n && pptr() < epptr())
353 *(pptr()) = *(
s +
count++);
380 inline void resetp(
char*
s, std::streamsize
n)
390 setp(
nullptr,
nullptr);
395 std::streamsize
span_tellp()
const {
return (pptr() - pbase()); }
398 std::streamsize
span_capacity()
const {
return (epptr() - pbase()); }
404 std::streamsize
size_bytes()
const {
return (pptr() - pbase()); }
406 #if __cplusplus >= 201703L 407 std::string_view
view()
const 419 void info(Ostream&
os)
const 446 virtual int overflow(int_type
c = traits_type::eof())
448 if (
c != traits_type::eof())
460 virtual std::streamsize
xsputn(
const char*
s, std::streamsize
n)
465 std::streamsize
count = 0;
466 while (
count <
n && pptr() < epptr())
485 storage_(label(nbytes))
493 storage_(
std::move(buffer))
499 template<
int SizeMin>
502 buffer.resize(buffer.capacity());
511 void reserve(
const std::streamsize len)
513 if (storage_.
size() < len)
517 label newCapacity = 512;
519 if (newCapacity < len)
531 storage_.
resize(newCapacity);
565 other.
swap(storage_);
571 template<
int SizeMin>
577 other.
swap(storage_);
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
void size(const label n)
Older name for setAddressableSize.
void resetg(char *s, std::streamsize n)
Reset get buffer with character data (can be nullptr) and count.
DynamicList< char > release()
Reset buffer and return contents.
std::streamsize span_capacity() const
The put buffer capacity.
virtual int overflow(int_type c=traits_type::eof())
Handle overflow.
void resize(const label len)
Adjust allocated size of list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
std::streamsize span_capacity() const
The get buffer capacity.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
char * data_bytes() const
The span data (start of output characters)
out_base()=default
Default construct.
virtual std::streamsize xsgetn(char *s, std::streamsize n)
Get sequence of characters from a fixed region.
void info(Ostream &os) const
Some information about the output buffer position/capacity.
label capacity() const noexcept
Size of the underlying storage.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void clear()
Clear the list, i.e. set size to zero.
void shrink()
Shrink storage to addressed storage.
The base input streambuf with memory access.
std::streamsize span_remaining() const
The number of characters remaining in the get area.
virtual std::streampos seekpos(std::streampos pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out)
Set position pointer to absolute position.
virtual std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out)
Set position pointer to relative position.
An output streambuf for memory access.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual std::streamsize xsputn(const char *s, std::streamsize n)
Put sequence of characters to a fixed region.
virtual std::streamsize xsputn(const char *s, std::streamsize n)
Put sequence of characters.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
OBJstream os(runTime.globalPath()/outputName)
void reserve(const std::streamsize len)
Increment capacity (if needed) and adjust buffer pointers.
void swap(List< T > &list)
Swap with plain List content. Implies shrink_to_fit().
DynamicList< char > release()
Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output...
in_dynamic()=default
Default construct - empty.
void sync_pbuffer()
Sync put buffer pointers to agree with list dimensions.
std::streamsize span_tellp() const
The current buffer put position.
void resetp(char *s, std::streamsize n)
Reset put buffer with character data (can be nullptr) and count.
void sync_gbuffer()
Sync get buffer pointers to agree with list dimensions.
void reset(const char *s, std::streamsize n)
Reset content (copy)
out_dynamic(size_t nbytes=512)
Default construct with initial reserved number of bytes.
const dimensionedScalar c
Speed of light in a vacuum.
A streambuf for memory similar to std::spanbuf (C++23)
void clearStorage()
Clear the list and delete storage.
Rudimentary functionality similar to std::span for holding memory view.
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
stdFoam::span< const char > view() const
std::streamsize size_bytes() const
The span size (number of input characters)
void info(Ostream &os) const
Some information about the input buffer position/capacity.
std::streamsize size_bytes() const
The span size (size of output buffer)
void clearStorage()
Clear storage.
stdFoam::span< const char > view() const
An output streambuf for memory access.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
An output streambuf for memory access.
in_base()=default
Default construct.
char * data_bytes() const
The span data (start of input characters)
std::streamsize span_tellg() const
The current buffer get position.