34 #ifndef Foam_OScountStream_H 35 #define Foam_OScountStream_H 54 virtual public std::ios,
58 class countbuf :
public std::streambuf
61 std::streamsize size_;
66 virtual std::streampos seekoff
69 std::ios_base::seekdir way,
70 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
73 if (which & std::ios_base::out)
75 if (way == std::ios_base::beg)
79 else if (way == std::ios_base::cur)
96 virtual std::streampos seekpos
99 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
102 return seekoff(
pos, std::ios_base::beg, which);
106 virtual int overflow(int_type
c = traits_type::eof())
108 if (
c != traits_type::eof()) ++size_;
113 virtual std::streamsize xsputn(
const char*
s, std::streamsize
n)
124 countbuf() : size_(0) {}
139 typedef countbuf buffer_type;
140 typedef std::ostream stream_type;
156 countbuf*
rdbuf() {
return &buf_; }
159 std::streamsize
count()
const noexcept {
return buf_.count(); }
171 os <<
"count=" << buf_.count();
184 class OCountStreamAllocator
210 public Detail::OCountStreamAllocator,
Generic output stream using a standard (STL) stream.
An output stream for calculating byte counts.
An allocator for holding Foam::ocountstream.
void syncState()
Set stream state to match that of the std::ostream.
Trivial output stream for calculating byte counts.
OCountStream(IOstreamOption streamOpt=IOstreamOption())
Default construct.
Foam::ocountstream stream_
The output stream.
void debug_info(Ostream &os) const
Some information about the output buffer position/capacity.
OCountStreamAllocator()=default
Default construct.
A simple container for options an IOstream can normally have.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
virtual void rewind()
Rewind the stream, reset the count, clearing any old errors.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression...
virtual void print(Ostream &os) const override
Print stream description to Ostream.
dimensionedScalar pos(const dimensionedScalar &ds)
void reset(std::streamsize n=0) noexcept
Reset the count.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
countbuf * rdbuf()
This hides both signatures of std::basic_ios::rdbuf()
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
OBJstream os(runTime.globalPath()/outputName)
std::streamsize count() const noexcept
void reset(std::streamsize n=0) noexcept
Reset the count.
ocountstream()
Default construct.
std::streamsize size() const noexcept
const dimensionedScalar c
Speed of light in a vacuum.
std::streamsize count() const noexcept
versionNumber version() const noexcept
Get the stream version.
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.