5 #include <libutl/Exception.h> 76 virtual void close() = 0;
84 return getFlag(flg_owner);
91 setFlag(flg_owner, owner);
113 if (isInput()) res |=
io_rd;
114 if (isOutput()) res |=
io_wr;
119 const String& getName()
const;
122 const String* getNamePtr()
const;
125 void setName(
const String& name);
128 void setName(
String* name);
131 virtual bool isBOL()
const;
134 virtual void setBOL(
bool p_bol);
137 virtual bool isInput()
const;
140 virtual void setInput(
bool input);
143 virtual bool isOutput()
const;
146 virtual void setOutput(
bool output);
152 return (isInput() && isOutput());
169 setInput((mode &
io_rd) != 0);
170 setOutput((mode &
io_wr) != 0);
223 virtual bool eof()
const;
226 virtual void setEOF(
bool p_eof);
229 virtual bool error()
const;
232 virtual void setError(
bool p_error);
288 if (_bitMask == 0x80)
get(_bitByte);
289 bool res = ((_bitByte & _bitMask) != 0);
291 if (_bitMask == 0) _bitMask = 0x80;
304 uint32_t res = 0, mask = 1 << (numBits - 1);
307 if (getBit()) res |= mask;
323 virtual size_t read(
byte_t* array,
size_t maxBytes,
size_t minBytes =
size_t_max) = 0;
358 Stream& put(
const char* str);
361 Stream& put(
const char* str,
size_t len);
367 if (b) _bitByte |= _bitMask;
382 while (_bitMask != 0x80) putBit(
false);
397 putBit((n & mask) != 0);
421 void writeSpaces(
size_t num);
428 virtual void write(
const byte_t* array,
size_t num) = 0;
503 #if UTL_SIZEOF_LONG == 4 518 static void utl_init();
521 virtual void clear();
529 if (!isBOL())
return;
544 write(spaces, indent);
551 void throwStreamEOFex();
554 void throwStreamErrorEx();
564 void readToken(
char* buf,
size_t size);
572 void readUntilWS(
char* buf,
size_t size);
586 static byte_t spaces[256];
611 return stream.
put(
'\n');
624 return stream.
flush();
636 return stream.
flush();
virtual Stream & flush(uint_t mode=io_wr)
Flush the stream (if it is buffered).
void setIndent(uint_t indent)
Set the indentation level.
uint_t getMode() const
Get the current mode.
void deInit()
De-initialize UTL++.
void indentIfBOL()
If begin-of-line flag is true, clear the flag and indent.
Stream & put(byte_t b)
Write the given character.
bool isOwner() const
Get the owner flag.
utl::Stream & operator<<(utl::Stream &lhs, const utl::Object &rhs)
Output an object's string representation to a stream (with Object::toString()).
void setBase(uint_t base)
Set the base, for writing integer values.
utl::Stream & operator>>(utl::Stream &lhs, utl::String &rhs)
Read a string from the given input stream.
size_t getInputCount() const
Get the count of input bytes.
size_t getOutputCount() const
Get the count of output bytes.
unsigned char byte_t
Unsigned character.
Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags.
const size_t size_t_max
Maximum size_t value.
long int64_t
Signed 64-bit integer.
bool isRDWR() const
Determine whether the stream is an input/output stream.
unsigned int uint32_t
Unsigned 32-bit integer.
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
utl::Stream & flush(utl::Stream &stream)
Flush the stream's output.
void indent(uint_t num=4)
Increase indentation by the given number of spaces.
utl::Stream & endl(utl::Stream &stream)
Output a newline to the stream.
unsigned long uint64_t
Unsigned 64-bit integer.
Stream & operator<<(smanip0 manip)
Execute a manipulator (e.g.
void _indentIfBOL()
Write _indent spaces at beginning of line.
bool getBit()
Get a single bit.
virtual Stream & newline()
Write a newline.
uint32_t getBits(uint_t numBits)
Get multiple bits.
#define UTL_CLASS_DECL_ABC(DC, BC)
Declaration of standard UTL++ functionality for an abstract base class (ABC).
unsigned int uint_t
Unsigned integer.
utl::Stream & endlf(utl::Stream &stream)
Output a newline to the stream and flush its output.
Stream & put(char c)
Write the given character.
void unindent(uint_t num=4)
Decrease indentation by the given number of spaces.
unsigned short uint16_t
Unsigned 16-bit integer.
unsigned long ulong_t
Unsigned long integer.
signed int int32_t
Signed 32-bit integer.
constexpr size_t KB(size_t n)
Convert size in kilobytes to size in bytes.
Stream & put(int c)
Write the given character.
signed short int16_t
Signed 16-bit integer.
Stream & putBits()
Write all outstanding bits.
void setMode(uint_t mode)
Set the mode.
Root of UTL++ class hierarchy.
Stream & putLine(const char *str)
Write the given string, followed by a newline.
Stream & putBits(uint32_t n, uint_t numBits)
Write multiple bits.
void setOwner(bool owner)
Set the owner flag.
uint_t getIndent() const
Get the indentation level.
void init()
Initialize UTL++.
#define ASSERTD
Do an assertion in DEBUG mode only.
Stream & putBit(bool b)
Write the given bit.