35#ifndef Foam_memoryStreamBuffer_H
36#define Foam_memoryStreamBuffer_H
65 std::ios_base::seekdir way,
66 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
69 const bool testin = which & std::ios_base::in;
70 const bool testout = which & std::ios_base::out;
72 if (way == std::ios_base::beg)
76 setg(eback(), eback(), egptr());
81 setp(pbase(), epptr());
85 else if (way == std::ios_base::cur)
96 else if (way == std::ios_base::end)
100 setg(eback(), eback(), egptr());
101 gbump(egptr() - eback() - off);
105 setp(pbase(), epptr());
106 pbump(epptr() - pbase() - off);
112 return (gptr() - eback());
116 return (pptr() - pbase());
127 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
130 return seekoff(
pos, std::ios_base::beg, which);
148class memorybuf::in_base
155 virtual std::streamsize
xsgetn(
char*
s, std::streamsize
n)
157 std::streamsize count = 0;
158 while (count <
n && gptr() < egptr())
160 *(
s + count++) = *(gptr());
187 void resetg(
char*
s, std::streamsize
n)
195 setg(
nullptr,
nullptr,
nullptr);
200 std::streamsize
span_tellg()
const {
return (gptr() - eback()); }
203 std::streamsize
span_capacity()
const {
return (egptr() - eback()); }
208 return (gptr() < egptr()) ? (egptr() - gptr()) : 0;
215 std::streamsize
size_bytes()
const {
return (egptr() - eback()); }
251 return std::string_view();
291 std::copy(
s, (
s +
n), storage_.
data());
299 storage_(std::move(buffer))
305 template<
int SizeMin>
319 resetg(storage_.data(), storage_.size());
323 void reset(
const char*
s, std::streamsize
n)
327 storage_.resize_nocopy(
n);
328 std::copy(
s, (
s +
n), storage_.data());
340 other.
swap(storage_);
345 template<
int SizeMin>
349 other.
swap(storage_);
376 virtual std::streamsize
xsputn(
const char*
s, std::streamsize
n)
378 std::streamsize count = 0;
379 while (count <
n && pptr() < epptr())
381 *(pptr()) = *(
s + count++);
408 inline void resetp(
char*
s, std::streamsize
n)
418 setp(
nullptr,
nullptr);
423 std::streamsize
span_tellp()
const {
return (pptr() - pbase()); }
426 std::streamsize
span_capacity()
const {
return (epptr() - pbase()); }
432 std::streamsize
size_bytes()
const {
return (pptr() - pbase()); }
447 auto view(
size_t pos,
size_t len)
const
452 if ((len == std::string::npos) || (len > (
size_bytes()-
pos)))
468 return std::string_view();
475 for (; (
n > 0 && (pbase() < pptr())); --
n)
486 std::streamsize count
537 virtual int overflow(int_type c = traits_type::eof())
539 if (c != traits_type::eof())
551 virtual std::streamsize
xsputn(
const char*
s, std::streamsize
n)
556 std::streamsize count = 0;
557 while (count <
n && pptr() < epptr())
559 *(pptr()) = *(
s + count++);
580 storage_(label(nbytes))
588 storage_(std::move(buffer))
594 template<
int SizeMin>
597 buffer.resize(buffer.capacity());
631 resetp(storage_.data(), storage_.size());
636 void reserve(
const std::streamsize len)
638 if (storage_.
size() < len)
653 size = label(2*storage_.size());
658 size = label((storage_.size()/2)*3);
663 size = label((storage_.size()/4)*5);
694 if (storage_.
size() < len)
698 storage_.resize_copy(cur, len);
705 void extend(std::streamsize count)
728 storage_.resize(cur);
737 other.
swap(storage_);
743 template<
int SizeMin>
749 other.
swap(storage_);
762 if (chars.empty()) chars.clearStorage();
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void swap(List< T > &other)
Swap with plain List content. Implies shrink_to_fit().
void clearStorage()
Clear the list and delete storage.
label capacity() const noexcept
Size of the underlying storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void resize_copy(label count, const label len)
Change allocated size of list, retaining the first count elements.
void resize(const label len)
Adjust allocated size of list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
static constexpr label max_size() noexcept
The size of the largest possible UList.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
The base input streambuf with memory access.
virtual std::streamsize xsgetn(char *s, std::streamsize n)
Get sequence of characters from a fixed region.
void resetg(char *s, std::streamsize n)
Reset get buffer with character data (can be nullptr) and count.
char * data_bytes() const
The span data (start of input characters).
std::streamsize span_capacity() const
The get buffer capacity.
bool in_range(std::streampos pos) const
True if position is within the current input range.
std::streamsize span_remaining() const
The number of characters remaining in the get area.
in_base()=default
Default construct.
in_base(char *s, std::streamsize n)
Construct for character array (can be nullptr) and number of bytes.
void info(Ostream &os) const
Some information about the input buffer position/capacity.
auto view() const
A string view of the current input region.
auto view(size_t pos, size_t len) const
A sub-slice string view of the current input region.
std::streamsize span_tellg() const
The current buffer get position.
std::streamsize size_bytes() const
The span size (number of input characters).
An output streambuf for memory access.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
void swap(DynamicList< char, SizeMin > &other)
Exchange buffer content and parameter contents, reset positions.
in_dynamic(const char *s, std::streamsize n)
Copy construct from content.
in_dynamic(::Foam::DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList (added length only).
void sync_gbuffer()
Sync get buffer pointers to agree with list dimensions.
DynamicList< char > release()
Reset buffer and return contents. The list size and capacity are identical.
in_dynamic(::Foam::List< char > &&buffer)
Move construct from List.
void reset(const char *s, std::streamsize n)
Reset content (copy).
in_dynamic()=default
Default construct - empty.
An output streambuf for memory access.
out_base(char *s, std::streamsize n)
Construct for character array (can be nullptr) and number of bytes.
void overwrite(std::streampos pos, char c)
Overwrite a single character.
void resetp(char *s, std::streamsize n)
Reset put buffer with character data (can be nullptr) and count.
std::streamsize span_tellp() const
The current buffer put position.
out_base()=default
Default construct.
char * data_bytes() const
The span data (start of output characters).
std::streamsize span_capacity() const
The put buffer capacity.
bool in_range(std::streampos pos) const
True if position is within the current output range.
void info(Ostream &os) const
Some information about the output buffer position/capacity.
void overwrite(std::streampos pos, const char *data, std::streamsize count)
Overwrite a sub-slice with character content.
auto view() const
A string view of the current output region.
auto view(size_t pos, size_t len) const
A sub-slice string view of the current output region.
void pop_back(int n=1)
Decrease the put area by 1 or more elements.
std::streamsize size_bytes() const
The span size (size of output buffer).
virtual std::streamsize xsputn(const char *s, std::streamsize n)
Put sequence of characters to a fixed region.
An output streambuf for memory access.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
void shrink()
Same as shrink_to_fit().
void reserve_exact(const std::streamsize len)
Increase capacity for at least this size. Does not apply min-size or capacity doubling etc.
void swap(DynamicList< char, SizeMin > &other)
Exchange buffer content and parameter contents, reset positions.
void extend(std::streamsize count)
Increase (reserve) space for another count entries.
DynamicList< char > release()
Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output.
void shrink_to_fit()
Shrink storage to addressed storage.
void sync_pbuffer()
Sync put buffer pointers to agree with list dimensions.
virtual int overflow(int_type c=traits_type::eof())
Handle overflow.
out_dynamic(::Foam::DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList (uses entire capacity).
static constexpr label max_size_2() noexcept
The 1/2 of max_size() - rounded to power-of-two.
void clearStorage()
Clear storage.
out_dynamic(::Foam::List< char > &&buffer)
Move construct from List.
static constexpr label max_size() noexcept
The largest storage size.
static constexpr label min_size() noexcept
Normal lower capacity limit.
out_dynamic()
Default construct - no initial reserved number of bytes.
void extend_exact(std::streamsize count)
Increase (reserve) space for another count entries.
static constexpr label max_size_4() noexcept
The 1/4 of max_size() - rounded to power-of-two.
void reserve(const std::streamsize len)
Increase capacity (if needed) and adjust buffer pointers. Applies a min-size and capacity doubling.
out_dynamic(size_t nbytes)
Default construct with initial reserved number of bytes.
virtual std::streamsize xsputn(const char *s, std::streamsize n)
Put sequence of characters.
A streambuf for memory similar to std::spanbuf (C++23).
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.
OBJstream os(runTime.globalPath()/outputName)
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))
dimensionedScalar pos(const dimensionedScalar &ds)