45 #ifndef Foam_OListStream_H 46 #define Foam_OListStream_H 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)),
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();
353 return buf_.setBlockSize(
n);
357 inline void swap(List<char>& other)
363 template<
int SizeMin>
385 buf_.pubseekpos(0, std::ios_base::out);
426 allocator_type(nbytes),
437 allocator_type(
std::move(buffer)),
442 template<
int SizeMin>
449 allocator_type(
std::move(buffer)),
468 #ifdef Foam_IOstream_extras 500 template<
int SizeMin>
Generic output stream using a standard (STL) stream.
void size(const label n)
Older name for setAddressableSize.
void resize(const label len)
Adjust allocated size of list.
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 reserve(const std::streamsize n)
Reserve output space for at least this amount.
label size() const
The current output position in the buffer, which is also the addressed list size. ...
void setCapacity(const label len)
Alter the size of the underlying storage.
A simple container for options an IOstream can normally have.
void shrink()
Shrink to addressed space, should not affect stream.
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression...
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
constexpr const T & max(const T &a, const T &b)
Return the greater of the parameters.
OListStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty output)
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 printBufInfo(Ostream &os) const
const UList< char > list() const
Const UList access to the characters written (shallow copy).
void rewind()
Move to buffer start, clear errors.
An output streambuf for memory access.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void clearStorage()
Clear storage.
An OSstream attached to a List.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
An stream/stream-buffer output allocator with DynamicList-like storage.
OListStreamAllocator(size_t nbytes=512)
Default construct, with initial reserved number of bytes.
dynbuf buf_
The stream buffer.
const dimensionedScalar c
Speed of light in a vacuum.
label capacity() const
The current list output capacity.
versionNumber version() const noexcept
Get the stream version.
void swap(List< char > &other)
Transfer list contents to other List.
streamFormat
Data format (ascii | binary)
stream_type stream_
The stream.
void setGood() noexcept
Set stream state to be good.
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))
streamFormat format() const noexcept
Get the current stream format.
virtual void rewind()
Rewind the stream, clearing any old errors.
void setBlockSize(int n)
Adjust block size for output.
virtual void print(Ostream &os) const
Print stream description to Ostream.