|
|
|
| 1 |
|
// ios standard header |
| 2 |
|
#pragma once |
| 3 |
|
#ifndef _IOS_ |
| 4 |
|
#define _IOS_ |
| 5 |
|
#ifndef RC_INVOKED |
| 6 |
|
#include <xlocnum> |
| 7 |
|
|
| 8 |
|
#ifdef _MSC_VER |
| 9 |
|
#pragma pack(push,_CRT_PACKING) |
| 10 |
|
#pragma warning(push,3) |
| 11 |
|
#endif /* _MSC_VER */ |
| 12 |
|
|
| 13 |
|
_STD_BEGIN |
| 14 |
|
|
| 15 |
|
// TEMPLATE CLASS basic_ios |
| 16 |
|
template<class _Elem, |
| 17 |
|
class _Traits> |
| 18 |
|
class basic_ios |
| 19 |
|
: public ios_base |
| 20 |
|
{ // base class for basic_istream/basic_ostream |
| 21 |
|
public: |
| 22 |
|
typedef basic_ios<_Elem, _Traits> _Myt; |
| 23 |
|
typedef basic_ostream<_Elem, _Traits> _Myos; |
| 24 |
|
typedef basic_streambuf<_Elem, _Traits> _Mysb; |
| 25 |
|
typedef ctype<_Elem> _Ctype; |
| 26 |
|
typedef _Elem char_type; |
| 27 |
|
typedef _Traits traits_type; |
| 28 |
|
typedef typename _Traits::int_type int_type; |
| 29 |
|
typedef typename _Traits::pos_type pos_type; |
| 30 |
|
typedef typename _Traits::off_type off_type; |
| 31 |
|
|
| 32 |
|
explicit __CLR_OR_THIS_CALL basic_ios(_Mysb *_Strbuf) |
| 33 |
|
{ // construct from stream buffer pointer |
| 34 |
|
init(_Strbuf); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
virtual __CLR_OR_THIS_CALL ~basic_ios() |
| 38 |
|
{ // destroy the object |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
void __CLR_OR_THIS_CALL clear(iostate _State = goodbit, bool _Reraise = false) |
| 42 |
|
{ // set state, possibly reraise exception |
| 43 |
|
ios_base::clear((iostate)(_Mystrbuf == 0 |
| 44 |
|
? (int)_State | (int)badbit : (int)_State), _Reraise); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
void __CLR_OR_THIS_CALL clear(io_state _State) |
| 48 |
|
{ // set state to _State |
| 49 |
|
clear((iostate)_State); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
void __CLR_OR_THIS_CALL setstate(iostate _State, bool _Reraise = false) |
| 53 |
|
{ // merge _State into state, possible reraise exception |
| 54 |
|
if (_State != goodbit) |
| 55 |
|
clear((iostate)((int)rdstate() | (int)_State), _Reraise); |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
void __CLR_OR_THIS_CALL setstate(io_state _State) |
| 59 |
|
{ // merge _State into state |
| 60 |
|
setstate((iostate)_State); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
_Myt& __CLR_OR_THIS_CALL copyfmt(const _Myt& _Right) |
| 64 |
|
{ // copy format parameters |
| 65 |
|
_Tiestr = _Right.tie(); |
| 66 |
|
_Fillch = _Right.fill(); |
| 67 |
|
ios_base::copyfmt(_Right); |
| 68 |
|
return (*this); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
_Myos *__CLR_OR_THIS_CALL tie() const |
| 72 |
|
{ // return tie pointer |
| 73 |
|
return (_Tiestr); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
_Myos *__CLR_OR_THIS_CALL tie(_Myos *_Newtie) |
| 77 |
|
{ // set tie pointer |
| 78 |
|
_Myos *_Oldtie = _Tiestr; |
| 79 |
|
_Tiestr = _Newtie; |
| 80 |
|
return (_Oldtie); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
_Mysb *__CLR_OR_THIS_CALL rdbuf() const |
| 84 |
|
{ // return stream buffer pointer |
| 85 |
|
return (_Mystrbuf); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
_Mysb *__CLR_OR_THIS_CALL rdbuf(_Mysb *_Strbuf) |
| 89 |
|
{ // set stream buffer pointer |
| 90 |
|
_Mysb *_Oldstrbuf = _Mystrbuf; |
| 91 |
|
_Mystrbuf = _Strbuf; |
| 92 |
|
clear(); |
| 93 |
|
return (_Oldstrbuf); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
locale __CLR_OR_THIS_CALL imbue(const locale& _Loc) |
| 97 |
|
{ // set locale to argument |
| 98 |
|
locale _Oldlocale = ios_base::imbue(_Loc); |
| 99 |
|
if (rdbuf() != 0) |
| 100 |
|
rdbuf()->pubimbue(_Loc); |
| 101 |
|
return (_Oldlocale); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
_Elem __CLR_OR_THIS_CALL fill() const |
| 105 |
|
{ // return fill character |
| 106 |
|
return (_Fillch); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
_Elem __CLR_OR_THIS_CALL fill(_Elem _Newfill) |
| 110 |
|
{ // set fill character |
| 111 |
|
_Elem _Oldfill = _Fillch; |
| 112 |
|
_Fillch = _Newfill; |
| 113 |
|
return (_Oldfill); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
char __CLR_OR_THIS_CALL narrow(_Elem _Ch, char _Dflt = '\0') const |
| 117 |
|
{ // convert _Ch to byte using imbued locale |
| 118 |
|
const _Ctype& _Ctype_fac = _USE(getloc(), _Ctype); |
| 119 |
|
return (_Ctype_fac.narrow(_Ch, _Dflt)); |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
_Elem __CLR_OR_THIS_CALL widen(char _Byte) const |
| 123 |
|
{ // convert _Byte to character using imbued locale |
| 124 |
|
const _Ctype& _Ctype_fac = _USE(getloc(), _Ctype); |
| 125 |
|
return (_Ctype_fac.widen(_Byte)); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
protected: |
| 129 |
|
void __CLR_OR_THIS_CALL init(_Mysb *_Strbuf = 0, |
| 130 |
|
bool _Isstd = false) |
| 131 |
|
{ // initialize with stream buffer pointer |
| 132 |
|
_Init(); // initialize ios_base |
| 133 |
|
_Mystrbuf = _Strbuf; |
| 134 |
|
_Tiestr = 0; |
| 135 |
|
_Fillch = widen(' '); |
| 136 |
|
|
| 137 |
|
if (_Mystrbuf == 0) |
| 138 |
|
setstate(badbit); |
| 139 |
|
|
| 140 |
|
if (_Isstd) |
| 141 |
|
_Addstd(this); // special handling for standard streams |
| 142 |
|
else |
| 143 |
|
_Stdstr = 0; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
__CLR_OR_THIS_CALL basic_ios() |
| 147 |
|
{ // default constructor, do nothing |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
private: |
| 151 |
|
__CLR_OR_THIS_CALL basic_ios(const _Myt&); // not defined |
| 152 |
|
_Myt& __CLR_OR_THIS_CALL operator=(const _Myt&); // not defined |
| 153 |
|
|
| 154 |
|
_Mysb *_Mystrbuf; // pointer to stream buffer |
| 155 |
|
_Myos *_Tiestr; // pointer to tied output stream |
| 156 |
|
_Elem _Fillch; // the fill character |
| 157 |
|
}; |
| 158 |
|
|
| 159 |
|
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) |
| 160 |
|
|
| 161 |
|
template class _CRTIMP2_PURE basic_ios<char, |
| 162 |
|
char_traits<char> >; |
| 163 |
|
template class _CRTIMP2_PURE basic_ios<wchar_t, |
| 164 |
|
char_traits<wchar_t> >; |
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
#endif /* _DLL_CPPLIB */ |
| 169 |
|
|
| 170 |
|
// MANIPULATORS |
| 171 |
|
inline ios_base& __CLRCALL_OR_CDECL boolalpha(ios_base& _Iosbase) |
| 172 |
|
{ // set boolalpha |
| 173 |
|
_Iosbase.setf(ios_base::boolalpha); |
| 174 |
|
return (_Iosbase); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
inline ios_base& __CLRCALL_OR_CDECL dec(ios_base& _Iosbase) |
| 178 |
|
{ // set basefield to dec |
| 179 |
|
_Iosbase.setf(ios_base::dec, ios_base::basefield); |
| 180 |
|
return (_Iosbase); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
inline ios_base& __CLRCALL_OR_CDECL fixed(ios_base& _Iosbase) |
| 184 |
|
{ // set floatfield to fixed |
| 185 |
|
_Iosbase.setf(ios_base::fixed, ios_base::floatfield); |
| 186 |
|
return (_Iosbase); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
inline ios_base& __CLRCALL_OR_CDECL hex(ios_base& _Iosbase) |
| 190 |
|
{ // set basefield to hex |
| 191 |
|
_Iosbase.setf(ios_base::hex, ios_base::basefield); |
| 192 |
|
return (_Iosbase); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
namespace tr1 { // added with TR1 |
| 196 |
|
inline std::ios_base& __CLRCALL_OR_CDECL hexfloat(std::ios_base& _Iosbase) |
| 197 |
|
{ // set floatfield to hexfloat |
| 198 |
|
_Iosbase.setf(std::ios_base::hexfloat, std::ios_base::floatfield); |
| 199 |
|
return (_Iosbase); |
| 200 |
|
} |
| 201 |
|
} // namespace tr1 |
| 202 |
|
using tr1::hexfloat; |
| 203 |
|
|
| 204 |
|
inline ios_base& __CLRCALL_OR_CDECL internal(ios_base& _Iosbase) |
| 205 |
|
{ // set adjustfield to internal |
| 206 |
|
_Iosbase.setf(ios_base::internal, ios_base::adjustfield); |
| 207 |
|
return (_Iosbase); |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
inline ios_base& __CLRCALL_OR_CDECL left(ios_base& _Iosbase) |
| 211 |
|
{ // set adjustfield to left |
| 212 |
|
_Iosbase.setf(ios_base::left, ios_base::adjustfield); |
| 213 |
|
return (_Iosbase); |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
inline ios_base& __CLRCALL_OR_CDECL noboolalpha(ios_base& _Iosbase) |
| 217 |
|
{ // clear boolalpha |
| 218 |
|
_Iosbase.unsetf(ios_base::boolalpha); |
| 219 |
|
return (_Iosbase); |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
inline ios_base& __CLRCALL_OR_CDECL noshowbase(ios_base& _Iosbase) |
| 223 |
|
{ // clear showbase |
| 224 |
|
_Iosbase.unsetf(ios_base::showbase); |
| 225 |
|
return (_Iosbase); |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
inline ios_base& __CLRCALL_OR_CDECL noshowpoint(ios_base& _Iosbase) |
| 229 |
|
{ // clear showpoint |
| 230 |
|
_Iosbase.unsetf(ios_base::showpoint); |
| 241 |
|
{ // clear skipws |
| 242 |
|
_Iosbase.unsetf(ios_base::skipws); |
| 243 |
|
return (_Iosbase); |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
inline ios_base& __CLRCALL_OR_CDECL nounitbuf(ios_base& _Iosbase) |
| 247 |
|
{ // clear unitbuf |
| 248 |
|
_Iosbase.unsetf(ios_base::unitbuf); |
| 249 |
|
return (_Iosbase); |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
inline ios_base& __CLRCALL_OR_CDECL nouppercase(ios_base& _Iosbase) |
| 253 |
|
{ // clear uppercase |
| 254 |
|
_Iosbase.unsetf(ios_base::uppercase); |
| 255 |
|
return (_Iosbase); |
| 256 |
|
} |
| 257 |
|
|
| 258 |
|
inline ios_base& __CLRCALL_OR_CDECL oct(ios_base& _Iosbase) |
| 259 |
|
{ // set oct in basefield |
| 260 |
|
_Iosbase.setf(ios_base::oct, ios_base::basefield); |
| 261 |
|
return (_Iosbase); |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
inline ios_base& __CLRCALL_OR_CDECL right(ios_base& _Iosbase) |
| 265 |
|
{ // set right in adjustfield |
| 266 |
|
_Iosbase.setf(ios_base::right, ios_base::adjustfield); |
| 267 |
|
return (_Iosbase); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
inline ios_base& __CLRCALL_OR_CDECL scientific(ios_base& _Iosbase) |
| 271 |
|
{ // set scientific in floatfield |
| 272 |
|
_Iosbase.setf(ios_base::scientific, ios_base::floatfield); |
| 273 |
|
return (_Iosbase); |
| 274 |
|
} |
| 275 |
|
|
| 276 |
|
inline ios_base& __CLRCALL_OR_CDECL showbase(ios_base& _Iosbase) |
| 277 |
|
{ // set showbase |
| 278 |
|
_Iosbase.setf(ios_base::showbase); |
| 279 |
|
return (_Iosbase); |
| 280 |
|
} |
| 281 |
|
|
| 282 |
|
inline ios_base& __CLRCALL_OR_CDECL showpoint(ios_base& _Iosbase) |
| 283 |
|
{ // set showpoint |
| 284 |
|
_Iosbase.setf(ios_base::showpoint); |
| 285 |
|
return (_Iosbase); |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
inline ios_base& __CLRCALL_OR_CDECL showpos(ios_base& _Iosbase) |
| 289 |
|
{ // set showpos |
| 290 |
|
_Iosbase.setf(ios_base::showpos); |
| 291 |
|
return (_Iosbase); |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
inline ios_base& __CLRCALL_OR_CDECL skipws(ios_base& _Iosbase) |
| 295 |
|
{ // set skipws |
| 296 |
|
_Iosbase.setf(ios_base::skipws); |
| 297 |
|
return (_Iosbase); |
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
inline ios_base& __CLRCALL_OR_CDECL unitbuf(ios_base& _Iosbase) |
| 301 |
|
{ // set unitbuf |
| 302 |
|
_Iosbase.setf(ios_base::unitbuf); |
| 303 |
|
return (_Iosbase); |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
inline ios_base& __CLRCALL_OR_CDECL uppercase(ios_base& _Iosbase) |
| 307 |
|
{ // set uppercase |
| 308 |
|
_Iosbase.setf(ios_base::uppercase); |
| 309 |
|
return (_Iosbase); |
| 310 |
|
} |
| 311 |
|
_STD_END |
| 312 |
|
|
| 313 |
|
#ifdef _MSC_VER |
| 314 |
|
#pragma warning(pop) |
| 315 |
|
#pragma pack(pop) |
| 316 |
|
#endif /* _MSC_VER */ |
| 317 |
|
|
| 318 |
|
#endif /* RC_INVOKED */ |
| 319 |
|
#endif /* _IOS_ */ |
| 320 |
|
|
| 321 |
|
/* |
| 322 |
|
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 323 |
|
* Consult your license regarding permissions and restrictions. |
| 324 |
|
V5.03:0009 */ |
| 325 |
|
|
|
|
|