336 void writeString(
const String &str);
350 bool readChar(
char &ch);
360 void unreadChar(
char ch);
365 void skipWhitespace();
377 String _encoding{
"UTF-8"};
383 int _integerBase = 10;
384 int _realNumberPrecision = 6;
410 s.setIntegerBase(16);
416 s.setIntegerBase(10);
Generic memory buffer descriptor with alignment and memory space support.
Definition buffer.h:85
Abstract base class for all I/O devices.
Definition iodevice.h:29
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Formatted text I/O with encoding awareness.
Definition textstream.h:54
TextStream & operator<<(bool val)
Writes "true" or "false".
void setFieldWidth(int width)
Sets the minimum field width for formatted output.
Definition textstream.h:189
void resetStatus()
Resets the stream status to Ok.
Definition textstream.h:134
String encoding() const
Returns the current encoding name.
Definition textstream.h:174
RealNumberNotation
Floating-point notation styles.
Definition textstream.h:71
@ SmartNotation
Use fixed or scientific as appropriate (default).
Definition textstream.h:72
@ Fixed
Always use fixed-point notation.
Definition textstream.h:73
@ Scientific
Always use scientific notation.
Definition textstream.h:74
TextStream & operator>>(int64_t &val)
Reads an int64_t from text.
TextStream(Buffer *buffer)
Constructs a TextStream backed by a Buffer.
void setRealNumberNotation(RealNumberNotation notation)
Sets the floating-point notation style.
Definition textstream.h:252
RealNumberNotation realNumberNotation() const
Returns the current real number notation.
Definition textstream.h:258
int fieldWidth() const
Returns the current field width.
Definition textstream.h:195
String read(size_t maxLength)
Reads up to maxLength characters.
TextStream & operator<<(char val)
Writes a single character.
TextStream & operator<<(double val)
Writes a double as formatted text.
int realNumberPrecision() const
Returns the current real number precision.
Definition textstream.h:246
TextStream & operator>>(double &val)
Reads a double from text.
TextStream & operator<<(TextStream &(*manip)(TextStream &))
Writes a manipulator function.
TextStream & operator<<(const String &val)
Writes a String.
void setIntegerBase(int base)
Sets the integer base for formatted output.
Definition textstream.h:228
FieldAlignment
Field alignment for padded output.
Definition textstream.h:64
@ Center
Center-aligned (pad both sides).
Definition textstream.h:67
@ Right
Right-aligned (pad on left, default).
Definition textstream.h:66
@ Left
Left-aligned (pad on right).
Definition textstream.h:65
String readAll()
Reads all remaining text.
TextStream(IODevice *device)
Constructs a TextStream on an IODevice.
void flush()
Flushes any buffered output to the underlying device.
TextStream & operator<<(int val)
Writes an int as formatted decimal text.
TextStream & operator>>(int &val)
Reads an int from text.
TextStream & operator<<(uint64_t val)
Writes a uint64_t as formatted text.
TextStream & operator<<(unsigned int val)
Writes an unsigned int as formatted decimal text.
TextStream & operator<<(int64_t val)
Writes an int64_t as formatted text.
IODevice * device() const
Returns the underlying IODevice.
Definition textstream.h:155
void setPadChar(char c)
Sets the padding character used for field width.
Definition textstream.h:213
Status status() const
Returns the current stream status.
Definition textstream.h:129
void setEncoding(const String &encoding)
Sets the text encoding for read/write operations.
bool atEnd() const
Returns true if at the end of the stream.
int integerBase() const
Returns the current integer base.
Definition textstream.h:234
FieldAlignment fieldAlignment() const
Returns the current field alignment.
Definition textstream.h:207
TextStream & operator<<(float val)
Writes a float as formatted text.
TextStream & operator<<(const Variant &val)
Writes a Variant using its toString() representation.
TextStream & operator>>(String &val)
Reads a whitespace-delimited token into a String.
TextStream(FILE *file)
Constructs a TextStream wrapping a C stdio FILE.
TextStream & operator>>(char &val)
Reads a single character.
String readLine()
Reads one line of text, consuming the trailing newline.
char padChar() const
Returns the current pad character.
Definition textstream.h:219
Status
Stream status codes.
Definition textstream.h:57
@ ReadPastEnd
Attempted to read beyond available data.
Definition textstream.h:59
@ WriteFailed
A write operation failed.
Definition textstream.h:60
@ Ok
No error.
Definition textstream.h:58
void setFieldAlignment(FieldAlignment align)
Sets the field alignment.
Definition textstream.h:201
TextStream(String *string)
Constructs a TextStream backed by a String.
TextStream & operator<<(const char *val)
Writes a C string.
void setRealNumberPrecision(int precision)
Sets the number of decimal places for float/double output.
Definition textstream.h:240
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
TextStream & endl(TextStream &s)
Writes a newline and flushes the stream.
Definition textstream.h:396
TextStream & right(TextStream &s)
Sets field alignment to Right.
Definition textstream.h:451
TextStream & oct(TextStream &s)
Sets integer base to 8 (octal).
Definition textstream.h:421
TextStream & fixed(TextStream &s)
Sets real number notation to Fixed.
Definition textstream.h:433
TextStream & left(TextStream &s)
Sets field alignment to Left.
Definition textstream.h:445
TextStream & center(TextStream &s)
Sets field alignment to Center.
Definition textstream.h:457
TextStream & scientific(TextStream &s)
Sets real number notation to Scientific.
Definition textstream.h:439
TextStream & hex(TextStream &s)
Sets integer base to 16 (hexadecimal).
Definition textstream.h:409
TextStream & dec(TextStream &s)
Sets integer base to 10 (decimal).
Definition textstream.h:415
TextStream & bin(TextStream &s)
Sets integer base to 2 (binary).
Definition textstream.h:427
TextStream & flush(TextStream &s)
Flushes the stream.
Definition textstream.h:403