12 #ifndef __UT_OSTREAM_H_INCLUDED__
13 #define __UT_OSTREAM_H_INCLUDED__
26 #if defined(MBSD) || (!defined(AMD64) && !defined(WIN32))
27 #define UT_NEED_LONG_OSTREAM_INSERTER
92 { myOS->setstate(state); }
106 #ifdef UT_NEED_LONG_OSTREAM_INSERTER
148 template <
typename DEST_TYPE>
150 template <
typename DEST_TYPE>
184 template <
typename DEST_TYPE>
186 template <
typename DEST_TYPE>
232 bool awrite(
const UT_String &str,
bool nl=
false);
234 bool awrite(
const std::string &str,
bool nl=
false);
270 , myOldIsBinary(os.isBinary())
276 , myOldIsBinary(os.isBinary())
278 myOS.myIsBinary = bin;
283 myOS.myIsBinary = myOldIsBinary;
301 , myOldPrecision(os.
precision(new_precision))
307 (
void) myStream.precision(myOldPrecision);
346 myOS->write(str, (std::streamsize)count);
363 myOS->seekp(offset, std::ios_base::beg);
366 myOS->seekp(offset, std::ios_base::cur);
378 return myOS->tellp();
382 #define UT_OSTREAM_ACCESSOR(FUNCNAME) \
383 inline int UT_OStream::FUNCNAME() const \
385 return myOS->FUNCNAME(); \
387 inline int UT_OStream::FUNCNAME(int value) \
389 return myOS->FUNCNAME(value); \
394 #undef UT_OSTREAM_ACCESSOR
397 #define UT_OSTREAM_INSERTER(T) \
398 inline UT_OStream & \
399 operator<<(UT_OStream &os, T value) \
416 #ifdef UT_NEED_LONG_OSTREAM_INSERTER
420 #undef UT_OSTREAM_INSERTER
424 UT_OStream::operator bool()
const
426 return !myOS->fail();
436 #define UT_OSTREAM_FLAG_GETTOR(FUNCNAME) \
437 inline bool UT_OStream::FUNCNAME() const { return myOS->FUNCNAME(); }
443 #undef UT_OSTREAM_FLAG_GETTOR
446 #define UT_OSTREAM_WRITE(TYPENAME) \
448 UT_OStream::write(const TYPENAME *buf, int64 cnt, bool nl) \
450 return myIsBinary ? bwrite(buf, cnt) : awrite(buf, cnt, nl); \
460 #undef UT_OSTREAM_WRITE
474 return myIsBinary ?
bwrite(std_str) :
awrite(std_str, nl);
477 #define UT_OSTREAM_BWRITE(TYPENAME) \
479 UT_OStream::bwrite(const TYPENAME *buf, int64 cnt) \
481 return UTwrite(*myOS, buf, cnt).bad() ? 0 : cnt; \
493 #undef UT_OSTREAM_BWRITE
497 return UTwrite(*myOS, (
char *)buf, cnt).bad() ? 0 : cnt;
501 #define UT_OSTREAM_AWRITE(TYPENAME) \
503 UT_OStream::awrite(const TYPENAME *buf, int64 cnt, bool nl) \
508 for (int64 i = 1; i < cnt; i++) \
509 *myOS << ' ' << buf[i]; \
510 *myOS << (nl ? '\n' : ' '); \
511 return myOS->bad() ? 0 : cnt; \
525 #undef UT_OSTREAM_AWRITE
531 *myOS <<
int32(buf[0] ? 1 : 0);
532 for (
int64 i = 1; i < cnt; i++)
533 *myOS <<
' ' <<
int32(buf[i] ? 1 : 0);
534 *myOS << (nl ?
'\n' :
' ');
535 return myOS->bad() ? 0 : cnt;
539 #define UT_OSTREAM_WRITEFLOAT(TYPENAME) \
540 template <typename DEST_TYPE> \
542 UT_OStream::write(const TYPENAME *buf, int64 cnt, bool nl) \
544 return myIsBinary ? bwrite<DEST_TYPE>(buf, cnt) : awrite(buf, cnt, nl); \
546 template <typename DEST_TYPE> \
548 UT_OStream::bwrite(const TYPENAME *buf, int64 cnt) \
550 return UTwrite<DEST_TYPE>(*myOS, buf, cnt).bad() ? 0 : cnt; \
555 #undef UT_OSTREAM_WRITEFLOAT
558 #endif // __UT_OSTREAM_H_INCLUDED__
UT_OStream(Uninitialized, UT_IOS_TYPE bin)
void setStreamRef(UT_OStream &os)
#define UT_OSTREAM_INSERTER(T)
UT_OStream & seekp(pos_type offset, seek_type dir=UT_IOS_SEEK_BEG)
Compatibility methods for std::ostream replacement.
UT_OStream & write(const char_type *str, int64 count)
Compatibility methods for std::ostream replacement.
GLint GLint GLint GLint GLint GLint GLsizei width
UT_AutoPrecision(UT_OStream &os, int new_precision)
bool isBinary() const
Determine if the stream is currently in ASCII or binary mode.
std::ostream & getOStream()
Manipulation of the underlying std::ostream reference.
#define UT_OSTREAM_ACCESSOR(FUNCNAME)
int64 bwrite(const bool *buf, int64 cnt=1)
UT_OStream & operator<<(UT_OStream &os, UT_OStream &(*manip)(UT_OStream &))
unsigned long long uint64
#define UT_OSTREAM_FLAG_GETTOR(FUNCNAME)
int64 awrite(const bool *buf, int64 cnt=1, bool nl=false)
UT_OStream(std::ostream &os, bool binary)
void setOStream(std::ostream &os)
Manipulation of the underlying std::ostream reference.
UT_OStream & put(char_type ch)
Compatibility methods for std::ostream replacement.
UT_OStream(std::ostream &os, UT_IOS_TYPE bin)
const GLuint GLenum const void * binary
#define UT_OSTREAM_BWRITE(TYPENAME)
pos_type tellp()
Compatibility methods for std::ostream replacement.
bool isAscii() const
Determine if the stream is currently in ASCII or binary mode.
#define UT_OSTREAM_WRITE(TYPENAME)
UT_OStream & flush()
Compatibility methods for std::ostream replacement.
#define UT_OSTREAM_WRITEFLOAT(TYPENAME)
Uninitialized
Tag for suppressing uninitialization.
GLsizei const GLchar *const * string
Usd_Term operator!(Usd_PrimFlags flag)
UT_OStreamAutoBinary(UT_OStream &os, bool bin)
UT_OStreamAutoBinary(UT_OStream &os, UT_IOS_TYPE bin)
GLuint GLuint GLsizei count
bool operator!() const
Compatibility methods for std::ostream replacement.
void write(T &out, bool v)
GLenum GLuint GLsizei const GLchar * buf
GLenum GLint GLint * precision
GLsizei const GLfloat * value
Turn the stream into binary or ASCII while in variable scope.
#define UT_OSTREAM_AWRITE(TYPENAME)
void setstate(std::ios::iostate state)
Compatibility methods for std::ostream replacement.