1 // This file is part of the ustl library, an STL implementation.
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
8 // Types used by the streams for option setting.
11 #ifndef UIOS_H_630C16E316F7650E3A02E1C6611B789A
12 #define UIOS_H_630C16E316F7650E3A02E1C6611B789A
20 const char endl
= '\n'; ///< End of line character.
21 const char ends
= '\0'; ///< End of string character.
23 /// Defines types and constants used by all stream classes.
26 /// Used to set parameters for stringstreams
28 boolalpha
= (1 << 0), ///< Boolean values printed as text.
29 dec
= (1 << 1), ///< Decimal number output.
30 fixed
= (1 << 2), ///< Fixed-point float output.
31 hex
= (1 << 3), ///< Hexadecimal number output.
33 left
= (1 << 5), ///< Left alignment.
34 oct
= (1 << 6), ///< Octal number output.
35 right
= (1 << 7), ///< Right alignment.
36 scientific
= (1 << 8), ///< Scientific float format.
37 showbase
= (1 << 9), ///< Add 0x or 0 prefixes on hex and octal numbers.
38 showpoint
= (1 << 10), ///< Print decimal point.
40 skipws
= (1 << 12), ///< Skip whitespace when reading.
42 uppercase
= (1 << 14),
43 adjustfield
= (1 << 15),
44 basefield
= (1 << 16),
45 floatfield
= (1 << 17)
47 /// For file-based streams, specifies fd mode.
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62 /// Seek directions, equivalent to SEEK_SET, SEEK_CUR, and SEEK_END.
68 /// I/O state bitmasks.
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 typedef uint32_t openmode
; ///< Holds openmode_bits.
81 typedef uint32_t iostate
; ///< Holds iostate_bits for a file stream.
82 typedef file_exception failure
; ///< Thrown by fstream on errors.
84 static const char c_DefaultDelimiters
[16]; ///< Default word delimiters for stringstreams.
86 inline ios_base (void) : m_State (goodbit
), m_Exceptions (goodbit
) {}
87 inline iostate
rdstate (void) const { return (m_State
); }
88 inline bool bad (void) const { return (rdstate() & badbit
); }
89 inline bool good (void) const { return (rdstate() == goodbit
); }
90 inline bool fail (void) const { return (rdstate() & (badbit
| failbit
)); }
91 inline bool eof (void) const { return (rdstate() & eofbit
); }
92 inline bool operator! (void) const { return (fail()); }
93 inline void clear (iostate v
= goodbit
) { m_State
= v
; }
94 inline void setstate (iostate v
) { m_State
|= v
; }
95 inline iostate
exceptions (void) const { return (m_Exceptions
); }
96 inline iostate
exceptions (iostate v
) { return (m_Exceptions
= v
); }
98 inline bool set_and_throw (iostate v
) { setstate(v
); return (exceptions() & v
); }
100 uint16_t m_State
; ///< Open state, using ios::iostate_bits.
101 uint16_t m_Exceptions
; ///< Exception flags, using ios::iostate_bits.