12 #ifndef __UT_OSTREAM_H_INCLUDED__
13 #define __UT_OSTREAM_H_INCLUDED__
26 #if defined(MBSD) || (!defined(AMD64) && !defined(ARM64) && !defined(WIN32))
27 #define UT_NEED_LONG_OSTREAM_INSERTER
88 bool operator!() const;
95 void setstate(std::ios::iostate state)
96 { myOS->setstate(state); }
110 #ifdef UT_NEED_LONG_OSTREAM_INSERTER
152 template <
typename DEST_TYPE>
154 template <
typename DEST_TYPE>
166 bool write(
const UT_String &str,
bool nl=
false);
188 template <
typename DEST_TYPE>
190 template <
typename DEST_TYPE>
236 bool awrite(
const UT_String &str,
bool nl=
false);
238 bool awrite(
const std::string &str,
bool nl=
false);
274 , myOldIsBinary(os.isBinary())
280 , myOldIsBinary(os.isBinary())
282 myOS.myIsBinary = bin;
287 myOS.myIsBinary = myOldIsBinary;
305 , myOldPrecision(os.
precision(new_precision))
311 (
void) myStream.precision(myOldPrecision);
350 myOS->write(str, (std::streamsize)count);
367 myOS->seekp(offset, std::ios_base::beg);
370 myOS->seekp(offset, std::ios_base::cur);
382 return myOS->tellp();
386 #define UT_OSTREAM_ACCESSOR(FUNCNAME) \
387 inline int UT_OStream::FUNCNAME() const \
389 return myOS->FUNCNAME(); \
391 inline int UT_OStream::FUNCNAME(int value) \
393 return myOS->FUNCNAME(value); \
398 #undef UT_OSTREAM_ACCESSOR
401 #define UT_OSTREAM_INSERTER(T) \
402 inline UT_OStream & \
403 operator<<(UT_OStream &os, T value) \
420 #ifdef UT_NEED_LONG_OSTREAM_INSERTER
424 #undef UT_OSTREAM_INSERTER
428 UT_OStream::operator bool()
const
430 return !myOS->fail();
440 #define UT_OSTREAM_FLAG_GETTOR(FUNCNAME) \
441 inline bool UT_OStream::FUNCNAME() const { return myOS->FUNCNAME(); }
447 #undef UT_OSTREAM_FLAG_GETTOR
450 #define UT_OSTREAM_WRITE(TYPENAME) \
452 UT_OStream::write(const TYPENAME *buf, int64 cnt, bool nl) \
454 return myIsBinary ? bwrite(buf, cnt) : awrite(buf, cnt, nl); \
464 #undef UT_OSTREAM_WRITE
478 return myIsBinary ?
bwrite(std_str) :
awrite(std_str, nl);
481 #define UT_OSTREAM_BWRITE(TYPENAME) \
483 UT_OStream::bwrite(const TYPENAME *buf, int64 cnt) \
485 return UTwrite(*myOS, buf, cnt).bad() ? 0 : cnt; \
497 #undef UT_OSTREAM_BWRITE
501 return UTwrite(*myOS, (
char *)buf, cnt).bad() ? 0 : cnt;
505 #define UT_OSTREAM_AWRITE(TYPENAME) \
507 UT_OStream::awrite(const TYPENAME *buf, int64 cnt, bool nl) \
512 for (int64 i = 1; i < cnt; i++) \
513 *myOS << ' ' << buf[i]; \
514 *myOS << (nl ? '\n' : ' '); \
515 return myOS->bad() ? 0 : cnt; \
529 #undef UT_OSTREAM_AWRITE
535 *myOS <<
int32(buf[0] ? 1 : 0);
536 for (
int64 i = 1; i < cnt; i++)
537 *myOS <<
' ' <<
int32(buf[i] ? 1 : 0);
538 *myOS << (nl ?
'\n' :
' ');
539 return myOS->bad() ? 0 : cnt;
543 #define UT_OSTREAM_WRITEFLOAT(TYPENAME) \
544 template <typename DEST_TYPE> \
546 UT_OStream::write(const TYPENAME *buf, int64 cnt, bool nl) \
548 return myIsBinary ? bwrite<DEST_TYPE>(buf, cnt) : awrite(buf, cnt, nl); \
550 template <typename DEST_TYPE> \
552 UT_OStream::bwrite(const TYPENAME *buf, int64 cnt) \
554 return UTwrite<DEST_TYPE>(*myOS, buf, cnt).bad() ? 0 : cnt; \
559 #undef UT_OSTREAM_WRITEFLOAT
562 #endif // __UT_OSTREAM_H_INCLUDED__
GLenum GLuint GLenum GLsizei const GLchar * buf
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)
UT_OStream & write(const char_type *str, int64 count)
UT_AutoPrecision(UT_OStream &os, int new_precision)
GLsizei const GLchar *const * string
const GLuint GLenum const void * binary
std::ostream & getOStream()
#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)
UT_OStream & put(char_type ch)
UT_OStream(std::ostream &os, UT_IOS_TYPE bin)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
#define UT_OSTREAM_BWRITE(TYPENAME)
#define SYS_NO_DISCARD_RESULT
#define UT_OSTREAM_WRITE(TYPENAME)
#define UT_OSTREAM_WRITEFLOAT(TYPENAME)
Uninitialized
Tag for suppressing uninitialization.
GLenum GLint GLint * precision
UT_OStreamAutoBinary(UT_OStream &os, bool bin)
UT_OStreamAutoBinary(UT_OStream &os, UT_IOS_TYPE bin)
Turn the stream into binary or ASCII while in variable scope.
#define UT_OSTREAM_AWRITE(TYPENAME)