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);
127 inline void setBlockSize(
const int i)
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)
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_);
210 inline label capacity()
const
212 return storage_.
size();
217 inline void sync_pbuffer()
223 inline void clearStorage()
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
488 OListStream(nbytes, IOstreamOption(fmt, ver))
503 template<
int SizeMin>
506 DynamicList<char,SizeMin>&& buffer,
An stream/stream-buffer output allocator with DynamicList-like storage.
void printBufInfo(Ostream &os) const
void swap(List< char > &other)
Transfer list contents to other List.
void shrink()
Shrink to addressed space, should not affect stream.
UList< char > list()
Non-const UList access to the characters written (shallow copy).
void setBlockSize(int n)
Adjust block size for output.
void swap(DynamicList< char, SizeMin > &other)
Transfer list contents to a DynamicList.
const UList< char > list() const
Const UList access to the characters written (shallow copy).
OListStreamAllocator(DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList.
label capacity() const
The current list output capacity.
OListStreamAllocator(size_t nbytes=512)
Default construct, with initial reserved number of bytes.
OListStreamAllocator(List< char > &&buffer)
Move construct from List.
void clearStorage()
Clear storage.
dynbuf buf_
The stream buffer.
void rewind()
Move to buffer start, clear errors.
void reserve(const std::streamsize n)
Reserve output space for at least this amount.
stream_type stream_
The stream.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void resize(const label len)
void setCapacity(const label len)
Alter the size of the underlying storage.
Representation of a major/minor version number.
The IOstreamOption is a simple container for options an IOstream can normally have.
versionNumber version() const noexcept
Get the stream version.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
streamFormat format() const noexcept
Get the current stream format.
streamFormat
Data format (ascii | binary)
static const versionNumber currentVersion
The current version number (2.0)
void setGood() noexcept
Set stream state to be good.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
An OSstream attached to a List.
OListStream(DynamicList< char, SizeMin > &&buffer, IOstreamOption streamOpt=IOstreamOption())
Move construct from an existing DynamicList.
virtual void print(Ostream &os) const
Print stream description to Ostream.
OListStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty output)
OListStream(size_t nbytes, IOstreamOption streamOpt=IOstreamOption())
Construct with initial reserved number of bytes.
OListStream(List< char > &&buffer, IOstreamOption streamOpt=IOstreamOption())
Move construct from an existing List.
virtual void rewind()
Rewind the stream, clearing any old errors.
Generic output stream using a standard (STL) stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
An output streambuf for memory access.
std::streamsize tellp() const
The buffer put position.
void resetp(char *s, std::streamsize n)
Reset for character array (can be nullptr) and number of bytes.
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))
constexpr const T & max(const T &a, const T &b)
Return the greater of the parameters.