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);
442 template<
int SizeMin>
468 #ifdef Foam_IOstream_extras
503 template<
int SizeMin>
506 DynamicList<char,SizeMin>&& buffer,
void resize(const label len)
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))
void resize(const label len)
Adjust allocated size of list.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
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.
void setCapacity(const label len)
Alter the size of the underlying storage.
void setGood() noexcept
Set stream state to be good.
OListStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty 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.
The IOstreamOption is a simple container for options an IOstream can normally have.
Generic output stream using a standard (STL) stream.
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.
OBJstream os(runTime.globalPath()/outputName)
virtual void rewind()
Rewind the stream, clearing any old errors.
OListStreamAllocator(DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList.
dynbuf buf_
The stream buffer.
UList< char > list()
Non-const UList access to the characters written (shallow copy).
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.
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.