5 #include <libutl/Stream.h> 6 #include <libutl/Vector.h> 18 typedef BufferedStream& (*bsmanip0)(BufferedStream& stream);
51 bool streamOwner =
true,
52 size_t iBufSize =
KB(16),
53 size_t oBufSize =
KB(16))
56 setStream(stream, streamOwner, iBufSize, oBufSize);
65 virtual bool isInput()
const;
66 virtual void setInput(
bool input);
67 virtual bool isOutput()
const;
68 virtual void setOutput(
bool output);
69 virtual bool eof()
const;
70 virtual void setEOF(
bool eof);
71 virtual bool error()
const;
72 virtual void setError(
bool error);
96 void setStream(
Stream* stream,
97 bool streamOwner =
true,
98 size_t iBufSize =
KB(16),
99 size_t oBufSize =
KB(16));
119 setInput((mode &
io_rd) != 0);
120 setOutput((mode &
io_wr) != 0);
121 if (p_setBufs) setBufs();
131 if (_iBufPos == _iBufLim) underflow();
132 b = _iBuf[_iBufPos++];
154 virtual size_t read(
byte_t* array,
size_t maxBytes,
size_t minBytes =
size_t_max);
162 _iBuf[--_iBufPos] = b;
179 return newline(
false);
188 if (forceFlush || isLineBuffered())
flush();
198 _oBuf[_oBufPos++] = b;
199 if (_oBufPos == _oBuf.size()) overflow();
223 virtual void write(
const byte_t* array,
size_t num);
232 return (_iBufPos < _iBufLim);
256 void setBufs(
size_t iBufSize =
KB(16),
size_t oBufSize =
KB(16));
262 void setInputBuf(
size_t size =
KB(16));
268 void setOutputBuf(
size_t size =
KB(16));
279 static_cast<Stream&
>(
self) << ptr;
284 static_cast<Stream&
>(
self) << str;
289 static_cast<Stream&
>(
self) << c;
294 static_cast<Stream&
>(
self) >> c;
299 static_cast<Stream&
>(
self) << b;
304 static_cast<Stream&
>(
self) >> b;
309 static_cast<Stream&
>(
self) << n;
314 static_cast<Stream&
>(
self) >> n;
319 static_cast<Stream&
>(
self) << n;
324 static_cast<Stream&
>(
self) >> n;
329 static_cast<Stream&
>(
self) << n;
334 static_cast<Stream&
>(
self) >> n;
339 static_cast<Stream&
>(
self) << n;
344 static_cast<Stream&
>(
self) >> n;
349 static_cast<Stream&
>(
self) << n;
354 static_cast<Stream&
>(
self) >> n;
359 static_cast<Stream&
>(
self) << n;
364 static_cast<Stream&
>(
self) >> n;
367 #if UTL_SIZEOF_LONG == 4 370 static_cast<Stream&
>(
self) << n;
375 static_cast<Stream&
>(
self) >> n;
380 static_cast<Stream&
>(
self) << n;
385 static_cast<Stream&
>(
self) >> n;
391 static_cast<Stream&
>(
self) << n;
396 static_cast<Stream&
>(
self) >> n;
401 virtual void clear();
409 virtual void underflow();
418 virtual void overflow();
422 size_t _iBufPos, _iBufLim;
470 return stream.
flush();
void unget(char c)
Unget a char.
virtual BufferedStream & flush(uint_t mode=io_wr)
Flush the stream (if it is buffered).
utl::BufferedStream & flush(utl::BufferedStream &stream)
Flush the stream's output.
void deInit()
De-initialize UTL++.
utl::BufferedStream & endlf(utl::BufferedStream &stream)
Output a newline to the stream and flush its output.
BufferedStream & put(byte_t b)
Write the given byte.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Stream * getStream()
Get the stream.
unsigned char byte_t
Unsigned character.
BufferedStream & newline(bool forceFlush)
Write a newline.
BufferedStream(Stream *stream, bool streamOwner=true, size_t iBufSize=KB(16), size_t oBufSize=KB(16))
Constructor.
const Stream * getStream() const
Get the stream.
bool hasInput() const
Has unread input?
const size_t size_t_max
Maximum size_t value.
long int64_t
Signed 64-bit integer.
utl::BufferedStream & operator<<(utl::BufferedStream &lhs, const utl::Object &rhs)
Output an object's string representation to a stream (with Object::toString()).
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
BufferedStream & put(int c)
Write the given character.
unsigned long uint64_t
Unsigned 64-bit integer.
bool isLineBuffered() const
Determine whether the stream is line-buffered.
unsigned int uint_t
Unsigned integer.
void setMode(uint_t mode, bool p_setBufs=true)
Set the mode.
unsigned short ushort_t
Unsigned short integer.
BufferedStream & put(char c)
Write the given character.
utl::BufferedStream & endl(utl::BufferedStream &stream)
Output a newline to the stream.
unsigned long ulong_t
Unsigned long integer.
constexpr size_t KB(size_t n)
Convert size in kilobytes to size in bytes.
void unget(byte_t b)
Un-get a byte.
Root of UTL++ class hierarchy.
virtual BufferedStream & newline()
Write a newline.
void setLineBuffered(bool lineBuffered)
Set the line-buffered flag.
utl::BufferedStream & operator>>(utl::BufferedStream &lhs, utl::String &rhs)
Read a string from the given input stream.
void init()
Initialize UTL++.
#define ASSERTD
Do an assertion in DEBUG mode only.