| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_IOS_H |
| 17 |
#define CPPREFERENCE_IOS_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
#include <system_error> |
| 21 |
#endif |
| 22 |
|
| 23 |
namespace std { |
| 24 |
|
| 25 |
typedef int streamoff; |
| 26 |
typedef int streamsize; |
| 27 |
template<class StateT> class fpos; |
| 28 |
|
| 29 |
class ios_base { |
| 30 |
private: |
| 31 |
ios_base(const ios_base& other); |
| 32 |
protected: |
| 33 |
ios_base(); |
| 34 |
public: |
| 35 |
virtual ~ios_base(); |
| 36 |
|
| 37 |
#if CPPREFERENCE_STDVER <2011 |
| 38 |
class failure : public exception { |
| 39 |
public: |
| 40 |
explicit failure(const std::string& message); |
| 41 |
}; |
| 42 |
#else |
| 43 |
class failure : public system_error { |
| 44 |
public: |
| 45 |
explicit failure(const std::string& message, |
| 46 |
const std::error_code& ec = std::io_errc::stream); |
| 47 |
explicit failure(const char* message, |
| 48 |
const std::error_code& ec = std::io_errc::stream); |
| 49 |
}; |
| 50 |
#endif |
| 51 |
|
| 52 |
class Init; |
| 53 |
|
| 54 |
typedef int openmode; // actually impl-defined |
| 55 |
static constexpr openmode app; |
| 56 |
static constexpr openmode binary; |
| 57 |
static constexpr openmode in; |
| 58 |
static constexpr openmode out; |
| 59 |
static constexpr openmode trunc; |
| 60 |
static constexpr openmode ate; |
| 61 |
|
| 62 |
typedef int fmtflags; // actually impl-defined |
| 63 |
static constexpr fmtflags dec; |
| 64 |
static constexpr fmtflags oct; |
| 65 |
static constexpr fmtflags hex; |
| 66 |
static constexpr fmtflags basefield; |
| 67 |
|
| 68 |
static constexpr fmtflags left; |
| 69 |
static constexpr fmtflags right; |
| 70 |
static constexpr fmtflags internal; |
| 71 |
static constexpr fmtflags adjustfield; |
| 72 |
|
| 73 |
static constexpr fmtflags scientific; |
| 74 |
static constexpr fmtflags fixed; |
| 75 |
static constexpr fmtflags floatfield; |
| 76 |
|
| 77 |
static constexpr fmtflags boolalpha; |
| 78 |
static constexpr fmtflags showbase; |
| 79 |
static constexpr fmtflags showpoint; |
| 80 |
static constexpr fmtflags showpos; |
| 81 |
static constexpr fmtflags skipws; |
| 82 |
static constexpr fmtflags unitbuf; |
| 83 |
static constexpr fmtflags uppercase; |
| 84 |
|
| 85 |
typedef int iostate; // actually impl-defined |
| 86 |
static constexpr iostate goodbit; |
| 87 |
static constexpr iostate badbit; |
| 88 |
static constexpr iostate failbit; |
| 89 |
static constexpr iostate eofbit; |
| 90 |
|
| 91 |
typedef int seekdir; // actually impl-defined |
| 92 |
static constexpr seekdir beg; |
| 93 |
static constexpr seekdir end; |
| 94 |
static constexpr seekdir cur; |
| 95 |
|
| 96 |
enum event { |
| 97 |
erase_event, |
| 98 |
imbue_event, |
| 99 |
copyfmt_event |
| 100 |
}; |
| 101 |
|
| 102 |
typedef void (*event_callback)(event type, ios_base& ios, int index); |
| 103 |
|
| 104 |
fmtflags flags() const; |
| 105 |
fmtflags flags(fmtflags flags); |
| 106 |
fmtflags setf(fmtflags flags); |
| 107 |
fmtflags setf(fmtflags flags, fmtflags mask); |
| 108 |
void unsetf(fmtflags flags); |
| 109 |
|
| 110 |
streamsize precision() const; |
| 111 |
streamsize precision(streamsize new_precision); |
| 112 |
streamsize width() const; |
| 113 |
streamsize width(streamsize new_width); |
| 114 |
|
| 115 |
locale imbue(const locale& loc); |
| 116 |
locale getloc() const; |
| 117 |
|
| 118 |
static int xalloc(); |
| 119 |
long& iword(int index); |
| 120 |
void*& pword(int index); |
| 121 |
|
| 122 |
void register_callback(event_callback function, int index); |
| 123 |
static bool sync_with_stdio(bool sync = true); |
| 124 |
}; |
| 125 |
|
| 126 |
template<class CharT, |
| 127 |
class Traits = std::char_traits<CharT>> |
| 128 |
class basic_ios : public ios_base { |
| 129 |
public: |
| 130 |
typedef CharT char_type; |
| 131 |
typedef Traits traits_type; |
| 132 |
typedef typename Traits::int_type int_type; |
| 133 |
typedef typename Traits::pos_type pos_type; |
| 134 |
typedef typename Traits::off_type off_type; |
| 135 |
|
| 136 |
explicit basic_ios(std::basic_streambuf<CharT, Traits>* sb); |
| 137 |
virtual ~basic_ios(); |
| 138 |
|
| 139 |
bool good() const; |
| 140 |
bool eof() const; |
| 141 |
bool fail() const; |
| 142 |
bool bad() const; |
| 143 |
|
| 144 |
bool operator!() const; |
| 145 |
#if CPPREFERENCE_STDVER <2011 |
| 146 |
operator void* () const; |
| 147 |
#else |
| 148 |
explicit operator bool() const; |
| 149 |
#endif |
| 150 |
|
| 151 |
iostate rdstate() const; |
| 152 |
void setstate(iostate state); |
| 153 |
void clear(iostate state = goodbit); |
| 154 |
|
| 155 |
basic_ios& copyfmt(const basic_ios& other); |
| 156 |
|
| 157 |
CharT fill() const; |
| 158 |
CharT fill(CharT ch); |
| 159 |
|
| 160 |
iostate exceptions() const; |
| 161 |
void exceptions(iostate except); |
| 162 |
|
| 163 |
locale imbue(const locale& loc); |
| 164 |
|
| 165 |
char narrow(char_type c, char dfault) const; |
| 166 |
char_type widen(char c) const; |
| 167 |
|
| 168 |
basic_streambuf<CharT, Traits>* rdbuf() const; |
| 169 |
basic_streambuf<CharT, Traits>* rdbuf(std::basic_streambuf<CharT, Traits>* sb); |
| 170 |
|
| 171 |
std::basic_ostream<CharT, Traits>* tie() const; |
| 172 |
std::basic_ostream<CharT, Traits>* tie(std::basic_ostream<CharT, Traits>* str); |
| 173 |
|
| 174 |
char narrow(char_type c, char dfault) const; |
| 175 |
char_type widen(char c) const; |
| 176 |
|
| 177 |
protected: |
| 178 |
basic_ios(); |
| 179 |
void init(std::basic_streambuf<CharT, Traits>* sb); |
| 180 |
void set_rdbuf(std::basic_streambuf<CharT, Traits>* sb); |
| 181 |
|
| 182 |
#if CPPREFERENCE_STDVER>= 2011 |
| 183 |
void move(basic_ios& other); |
| 184 |
void move(basic_ios&& other); |
| 185 |
void swap(basic_ios& other); |
| 186 |
#endif |
| 187 |
private: |
| 188 |
basic_ios(const basic_ios& other); |
| 189 |
}; |
| 190 |
|
| 191 |
typedef basic_ios<char> ios; |
| 192 |
typedef basic_ios<wchar_t> wios; |
| 193 |
|
| 194 |
// manipulators |
| 195 |
ios_base& boolalpha(ios_base& str); |
| 196 |
ios_base& noboolalpha(ios_base& str); |
| 197 |
ios_base& showbase(ios_base& str); |
| 198 |
ios_base& noshowbase(ios_base& str); |
| 199 |
ios_base& showpoint(ios_base& str); |
| 200 |
ios_base& noshowpoint(ios_base& str); |
| 201 |
ios_base& showpos(ios_base& str); |
| 202 |
ios_base& noshowpos(ios_base& str); |
| 203 |
ios_base& skipws(ios_base& str); |
| 204 |
ios_base& noskipws(ios_base& str); |
| 205 |
ios_base& uppercase(ios_base& str); |
| 206 |
ios_base& nouppercase(ios_base& str); |
| 207 |
ios_base& unitbuf(ios_base& str); |
| 208 |
ios_base& nounitbuf(ios_base& str); |
| 209 |
|
| 210 |
ios_base& internal(ios_base& str); |
| 211 |
ios_base& left(ios_base& str); |
| 212 |
ios_base& right(ios_base& str); |
| 213 |
|
| 214 |
ios_base& dec(ios_base& str); |
| 215 |
ios_base& hex(ios_base& str); |
| 216 |
ios_base& oct(ios_base& str); |
| 217 |
|
| 218 |
ios_base& fixed(ios_base& str); |
| 219 |
ios_base& scientific(ios_base& str); |
| 220 |
ios_base& hexfloat(ios_base& str); |
| 221 |
ios_base& defaultfloat(ios_base& str); |
| 222 |
|
| 223 |
#if CPPREFERENCE_STDVER>= 2011 |
| 224 |
enum class io_errc { |
| 225 |
stream |
| 226 |
}; |
| 227 |
|
| 228 |
std::error_code make_error_code(std::io_errc e); |
| 229 |
std::error_condition make_error_condition(std::io_errc e); |
| 230 |
const std::error_category& iostream_category(); |
| 231 |
#endif |
| 232 |
|
| 233 |
} // namespace std |
| 234 |
|
| 235 |
#endif // CPPREFERENCE_IOS_H |