Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
8.6 KiB

  1. /***
  2. *istream.h - definitions/declarations for the istream class
  3. *
  4. * Copyright (c) 1990-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file defines the classes, values, macros, and functions
  8. * used by the istream class.
  9. * [AT&T C++]
  10. *
  11. * [Public]
  12. *
  13. *Revision History:
  14. * 01-23-92 KRS Ported from 16-bit version.
  15. * 02-23-93 SKS Update copyright to 1993
  16. * 03-23-93 CFW Modified #pragma warnings.
  17. * 05-10-93 CFW Enable operator<<(long double)
  18. * 05-11-93 CFW Add _CRTIMP directive to class definition.
  19. * 09-01-93 GJF Merged Cuda and NT SDK versions.
  20. * 10-13-93 GJF Deleted obsolete COMBOINC check. Enclose #pragma-s
  21. * in #ifdef _MSC_VER
  22. * 04-12-94 SKS Add __cdecl keyword to dec/hex/oct functions and
  23. * operator >>. Add underscores to some parameter names.
  24. * 05-24-94 GJF Added definition of MAXLONGSIZ for internal use.
  25. * 06-06-94 CFW Fix ignore, bad return.
  26. * 08-12-94 GJF Disable warning 4514 instead of 4505.
  27. * 11-03-94 GJF Changed pack pragma to 8 byte alignment.
  28. * 01-26-95 CFW Removed QWIN ifdef.
  29. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  30. * 02-14-95 CFW Clean up Mac merge.
  31. * 05-11-95 CFW Only for use by C++ programs.
  32. * 05-24-95 CFW Support for ignore(.., 0xFF).
  33. * 06-21-95 CFW Add inline support for ignore(.., 0xFF).
  34. * 07-07-95 CFW Fix ambiguous get.
  35. * 07-17-95 CFW Make get(char*,int,int) protected.
  36. * 12-14-95 JWM Add "#pragma once".
  37. * 04-09-96 SKS Change _CRTIMP to _CRTIMP1 for special iostream build
  38. * 04-15-96 JWM Remove _OLD_IOSTREAMS, add '#pragma comment(lib,"cirt")'.
  39. * 04-16-96 JWM '#include useoldio.h' replaces '#pragma comment(...)'.
  40. * 02-24-97 GJF Cleaned out obsolete support for _NTSDK. Also,
  41. * detab-ed.
  42. * 05-17-99 PML Remove all Macintosh support.
  43. *
  44. ****/
  45. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  46. #pragma once
  47. #endif
  48. #ifdef __cplusplus
  49. #ifndef _INC_ISTREAM
  50. #define _INC_ISTREAM
  51. #if !defined(_WIN32)
  52. #error ERROR: Only Win32 target supported!
  53. #endif
  54. #ifndef _CRTBLD
  55. /* This version of the header files is NOT for user programs.
  56. * It is intended for use when building the C runtimes ONLY.
  57. * The version intended for public use will not have this message.
  58. */
  59. #error ERROR: Use of C runtime library internal header file.
  60. #endif /* _CRTBLD */
  61. #ifdef _MSC_VER
  62. // Currently, all MS C compilers for Win32 platforms default to 8 byte
  63. // alignment.
  64. #pragma pack(push,8)
  65. #include <useoldio.h>
  66. #endif // _MSC_VER
  67. /* Define _CRTIMP */
  68. #ifndef _CRTIMP
  69. #ifdef CRTDLL
  70. #define _CRTIMP __declspec(dllexport)
  71. #else /* ndef CRTDLL */
  72. #ifdef _DLL
  73. #define _CRTIMP __declspec(dllimport)
  74. #else /* ndef _DLL */
  75. #define _CRTIMP
  76. #endif /* _DLL */
  77. #endif /* CRTDLL */
  78. #endif /* _CRTIMP */
  79. #ifndef _INTERNAL_IFSTRIP_
  80. /* Define _CRTIMP1 */
  81. #ifndef _CRTIMP1
  82. #ifdef CRTDLL1
  83. #define _CRTIMP1 __declspec(dllexport)
  84. #else /* ndef CRTDLL1 */
  85. #define _CRTIMP1 _CRTIMP
  86. #endif /* CRTDLL1 */
  87. #endif /* _CRTIMP1 */
  88. #endif /* _INTERNAL_IFSTRIP_ */
  89. #include <ios.h>
  90. #ifdef _MSC_VER
  91. // C4069: "long double != double"
  92. #pragma warning(disable:4069) // disable C4069 warning
  93. // #pragma warning(default:4069) // use this to reenable, if desired
  94. // C4514: "unreferenced inline function has been removed"
  95. #pragma warning(disable:4514) // disable C4514 warning
  96. // #pragma warning(default:4514) // use this to reenable, if desired
  97. #endif // _MSC_VER
  98. #ifndef _INTERNAL_IFSTRIP_
  99. #define MAXLONGSIZ 16
  100. #endif /* _INTERNAL_IFSTRIP_ */
  101. typedef long streamoff, streampos;
  102. class _CRTIMP1 istream : virtual public ios {
  103. public:
  104. istream(streambuf*);
  105. virtual ~istream();
  106. int ipfx(int =0);
  107. void isfx() { unlockbuf(); unlock(); }
  108. inline istream& operator>>(istream& (__cdecl * _f)(istream&));
  109. inline istream& operator>>(ios& (__cdecl * _f)(ios&));
  110. istream& operator>>(char *);
  111. inline istream& operator>>(unsigned char *);
  112. inline istream& operator>>(signed char *);
  113. istream& operator>>(char &);
  114. inline istream& operator>>(unsigned char &);
  115. inline istream& operator>>(signed char &);
  116. istream& operator>>(short &);
  117. istream& operator>>(unsigned short &);
  118. istream& operator>>(int &);
  119. istream& operator>>(unsigned int &);
  120. istream& operator>>(long &);
  121. istream& operator>>(unsigned long &);
  122. istream& operator>>(float &);
  123. istream& operator>>(double &);
  124. istream& operator>>(long double &);
  125. istream& operator>>(streambuf*);
  126. int get();
  127. inline istream& get( char *,int,char ='\n');
  128. inline istream& get(unsigned char *,int,char ='\n');
  129. inline istream& get( signed char *,int,char ='\n');
  130. istream& get(char &);
  131. inline istream& get(unsigned char &);
  132. inline istream& get( signed char &);
  133. istream& get(streambuf&,char ='\n');
  134. inline istream& getline( char *,int,char ='\n');
  135. inline istream& getline(unsigned char *,int,char ='\n');
  136. inline istream& getline( signed char *,int,char ='\n');
  137. inline istream& ignore(int =1,int =EOF);
  138. istream& read(char *,int);
  139. inline istream& read(unsigned char *,int);
  140. inline istream& read(signed char *,int);
  141. int gcount() const { return x_gcount; }
  142. int peek();
  143. istream& putback(char);
  144. int sync();
  145. istream& seekg(streampos);
  146. istream& seekg(streamoff,ios::seek_dir);
  147. streampos tellg();
  148. void eatwhite();
  149. protected:
  150. istream();
  151. istream(const istream&); // treat as private
  152. istream& operator=(streambuf* _isb); // treat as private
  153. istream& operator=(const istream& _is) { return operator=(_is.rdbuf()); }
  154. istream& get(char *, int, int);
  155. int do_ipfx(int);
  156. private:
  157. istream(ios&);
  158. int getint(char *);
  159. int getdouble(char *, int);
  160. int _fGline;
  161. int x_gcount;
  162. };
  163. inline istream& istream::operator>>(istream& (__cdecl * _f)(istream&)) { (*_f)(*this); return *this; }
  164. inline istream& istream::operator>>(ios& (__cdecl * _f)(ios&)) { (*_f)(*this); return *this; }
  165. inline istream& istream::operator>>(unsigned char * _s) { return operator>>((char *)_s); }
  166. inline istream& istream::operator>>( signed char * _s) { return operator>>((char *)_s); }
  167. inline istream& istream::operator>>(unsigned char & _c) { return operator>>((char &) _c); }
  168. inline istream& istream::operator>>( signed char & _c) { return operator>>((char &) _c); }
  169. inline istream& istream::get( char * _b, int _lim, char _delim) { return get( _b, _lim, (int)(unsigned char)_delim); }
  170. inline istream& istream::get(unsigned char * _b, int _lim, char _delim) { return get((char *)_b, _lim, (int)(unsigned char)_delim); }
  171. inline istream& istream::get(signed char * _b, int _lim, char _delim) { return get((char *)_b, _lim, (int)(unsigned char)_delim); }
  172. inline istream& istream::get(unsigned char & _c) { return get((char &)_c); }
  173. inline istream& istream::get( signed char & _c) { return get((char &)_c); }
  174. inline istream& istream::getline( char * _b,int _lim,char _delim) { lock(); _fGline++; get( _b, _lim, (int)(unsigned char)_delim); unlock(); return *this; }
  175. inline istream& istream::getline(unsigned char * _b,int _lim,char _delim) { lock(); _fGline++; get((char *)_b, _lim, (int)(unsigned char)_delim); unlock(); return *this; }
  176. inline istream& istream::getline( signed char * _b,int _lim,char _delim) { lock(); _fGline++; get((char *)_b, _lim, (int)(unsigned char)_delim); unlock(); return *this; }
  177. inline istream& istream::ignore(int _n,int _delim) { lock(); _fGline++; get((char *)0, _n+1, _delim); unlock(); return *this; }
  178. inline istream& istream::read(unsigned char * _ptr, int _n) { return read((char *) _ptr, _n); }
  179. inline istream& istream::read( signed char * _ptr, int _n) { return read((char *) _ptr, _n); }
  180. class _CRTIMP1 istream_withassign : public istream {
  181. public:
  182. istream_withassign();
  183. istream_withassign(streambuf*);
  184. ~istream_withassign();
  185. istream& operator=(const istream& _is) { return istream::operator=(_is); }
  186. istream& operator=(streambuf* _isb) { return istream::operator=(_isb); }
  187. };
  188. extern _CRTIMP1 istream_withassign cin;
  189. inline _CRTIMP1 istream& __cdecl ws(istream& _ins) { _ins.eatwhite(); return _ins; }
  190. _CRTIMP1 ios& __cdecl dec(ios&);
  191. _CRTIMP1 ios& __cdecl hex(ios&);
  192. _CRTIMP1 ios& __cdecl oct(ios&);
  193. #ifdef _MSC_VER
  194. // Restore default packing
  195. #pragma pack(pop)
  196. #endif // _MSC_VER
  197. #endif // _INC_ISTREAM
  198. #endif /* __cplusplus */