Go to the documentation of this file.
75 constexpr
static int min_size(
int n)
94 inline void minCapacity
96 const std::streamsize
n,
97 const std::streamsize cur = 0
100 const auto newEnd =
n + cur;
101 if (newEnd > storage_.size())
105 (storage_.size() + block_)
106 - (storage_.size() % block_)
109 while (newCapacity < newEnd)
111 newCapacity += block_;
120 storage_.
resize(newCapacity);
129 const auto prev = block_;
130 block_ = min_size(i);
134 minCapacity(0, tellp());
139 virtual int overflow(
int c = EOF)
144 minCapacity(block_, tellp());
154 virtual std::streamsize xsputn(
const char*
s, std::streamsize
n)
157 minCapacity(
n, tellp());
159 std::streamsize
count = 0;
160 while (
count <
n && pptr() < epptr())
162 *(pptr()) = *(
s +
count++);
170 void init_pbuffer(
const std::streamsize
n)
182 dynbuf(
size_t nbytes = 512)
186 init_pbuffer(min_size(nbytes));
192 storage_(std::move(buffer))
194 init_pbuffer(block_);
198 template<
int SizeMin>
201 storage_(std::move(buffer))
203 init_pbuffer(block_);
212 return storage_.size();
217 inline void sync_pbuffer()
219 resetp(storage_.data(), storage_.size());
232 const auto cur = tellp();
242 const auto cur = tellp();
244 storage_.swap(other);
250 template<
int SizeMin>
253 const auto cur = tellp();
255 storage_.swap(other);
288 buf_(std::move(buffer)),
293 template<
int SizeMin>
296 buf_(std::move(buffer)),
305 os <<
"put=" <<
buf_.tellp()
306 <<
"/" <<
buf_.capacity()
307 <<
" block=" <<
buf_.block_;
329 return buf_.capacity();
334 inline label
size()
const
340 inline void reserve(
const std::streamsize
n)
343 const auto cur =
buf_.tellp();
346 buf_.minCapacity(
n - cur, cur);
353 return buf_.setBlockSize(
n);
363 template<
int SizeMin>
385 buf_.pubseekpos(0, std::ios_base::out);
445 template<
int SizeMin>
void reserve(const std::streamsize n)
Reserve output space for at least this amount.
An stream/stream-buffer output allocator with DynamicList-like storage.
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))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void printBufInfo(Ostream &os) const
streamFormat format() const noexcept
Get the current stream format.
static const versionNumber currentVersion
The current version number (2.0)
An OSstream attached to a List.
OListStreamAllocator(size_t nbytes=512)
Default construct, with initial reserved number of bytes.
const UList< char > list() const
Const UList access to the characters written (shallow copy).
void setBlockSize(int n)
Adjust block size for output.
Representation of a major/minor version number.
An output streambuf for memory access.
void shrink()
Shrink to addressed space, should not affect stream.
OSstream(const OSstream &)=default
Copy construct.
Generic output stream using a standard (STL) stream.
void resize(const label newSize)
Adjust allocated size of list.
versionNumber version() const noexcept
Get the stream version.
constexpr const T & max(const T &a, const T &b)
Return the greater of the parameters.
streamFormat
Data format (ascii | binary)
label capacity() const
The current list output capacity.
virtual void rewind()
Rewind the stream, clearing any old errors.
OListStreamAllocator(DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList.
dynbuf buf_
The stream buffer.
void setCapacity(const label nElem)
Alter the size of the underlying storage.
void resize(const label nElem)
Alter addressable list size.
UList< char > list()
Non-const UList access to the characters written (shallow copy).
void setGood()
Set stream to be good.
virtual void print(Ostream &os) const
Print stream description to Ostream.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void swap(DynamicList< char, SizeMin > &other)
Transfer list contents to a DynamicList.
void clear()
Clear the list, i.e. set size to zero.
OListStream(streamFormat format=ASCII, versionNumber version=currentVersion)
Default construct (empty output)
void rewind()
Move to buffer start, clear errors.
stream_type stream_
The stream.
const dimensionedScalar c
Speed of light in a vacuum.
OListStreamAllocator(List< char > &&buffer)
Move construct from List.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void clearStorage()
Clear storage.
void swap(List< char > &other)
Transfer list contents to other List.