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.

187 lines
6.2 KiB

  1. /***
  2. *istream.h - definitions/declarations for the istream class
  3. *
  4. * Copyright (c) 1990-1995, 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. ****/
  14. #ifdef __cplusplus
  15. #ifndef _INC_ISTREAM
  16. #define _INC_ISTREAM
  17. #if !defined(_WIN32) && !defined(_MAC)
  18. #error ERROR: Only Mac or Win32 targets supported!
  19. #endif
  20. #ifdef _MSC_VER
  21. // Currently, all MS C compilers for Win32 platforms default to 8 byte
  22. // alignment.
  23. #pragma pack(push,8)
  24. #endif // _MSC_VER
  25. /* Define _CRTIMP */
  26. #ifndef _CRTIMP
  27. #ifdef _NTSDK
  28. /* definition compatible with NT SDK */
  29. #define _CRTIMP
  30. #else /* ndef _NTSDK */
  31. /* current definition */
  32. #ifdef _DLL
  33. #define _CRTIMP __declspec(dllimport)
  34. #else /* ndef _DLL */
  35. #define _CRTIMP
  36. #endif /* _DLL */
  37. #endif /* _NTSDK */
  38. #endif /* _CRTIMP */
  39. #include <ios.h>
  40. #ifdef _MSC_VER
  41. // C4069: "long double != double"
  42. #pragma warning(disable:4069) // disable C4069 warning
  43. // #pragma warning(default:4069) // use this to reenable, if desired
  44. // C4514: "unreferenced inline function has been removed"
  45. #pragma warning(disable:4514) // disable C4514 warning
  46. // #pragma warning(default:4514) // use this to reenable, if desired
  47. #endif // _MSC_VER
  48. typedef long streamoff, streampos;
  49. class _CRTIMP istream : virtual public ios {
  50. public:
  51. istream(streambuf*);
  52. virtual ~istream();
  53. int ipfx(int =0);
  54. void isfx() { unlockbuf(); unlock(); }
  55. inline istream& operator>>(istream& (__cdecl * _f)(istream&));
  56. inline istream& operator>>(ios& (__cdecl * _f)(ios&));
  57. istream& operator>>(char *);
  58. inline istream& operator>>(unsigned char *);
  59. inline istream& operator>>(signed char *);
  60. istream& operator>>(char &);
  61. inline istream& operator>>(unsigned char &);
  62. inline istream& operator>>(signed char &);
  63. istream& operator>>(short &);
  64. istream& operator>>(unsigned short &);
  65. istream& operator>>(int &);
  66. istream& operator>>(unsigned int &);
  67. istream& operator>>(long &);
  68. istream& operator>>(unsigned long &);
  69. istream& operator>>(float &);
  70. istream& operator>>(double &);
  71. istream& operator>>(long double &);
  72. istream& operator>>(streambuf*);
  73. int get();
  74. inline istream& get( char *,int,char ='\n');
  75. inline istream& get(unsigned char *,int,char ='\n');
  76. inline istream& get( signed char *,int,char ='\n');
  77. istream& get(char &);
  78. inline istream& get(unsigned char &);
  79. inline istream& get( signed char &);
  80. istream& get(streambuf&,char ='\n');
  81. inline istream& getline( char *,int,char ='\n');
  82. inline istream& getline(unsigned char *,int,char ='\n');
  83. inline istream& getline( signed char *,int,char ='\n');
  84. inline istream& ignore(int =1,int =EOF);
  85. istream& read(char *,int);
  86. inline istream& read(unsigned char *,int);
  87. inline istream& read(signed char *,int);
  88. int gcount() const { return x_gcount; }
  89. int peek();
  90. istream& putback(char);
  91. int sync();
  92. istream& seekg(streampos);
  93. istream& seekg(streamoff,ios::seek_dir);
  94. streampos tellg();
  95. void eatwhite();
  96. protected:
  97. istream();
  98. istream(const istream&); // treat as private
  99. istream& operator=(streambuf* _isb); // treat as private
  100. istream& operator=(const istream& _is) { return operator=(_is.rdbuf()); }
  101. istream& get(char *, int, int);
  102. int do_ipfx(int);
  103. private:
  104. istream(ios&);
  105. int getint(char *);
  106. int getdouble(char *, int);
  107. int _fGline;
  108. int x_gcount;
  109. };
  110. inline istream& istream::operator>>(istream& (__cdecl * _f)(istream&)) { (*_f)(*this); return *this; }
  111. inline istream& istream::operator>>(ios& (__cdecl * _f)(ios&)) { (*_f)(*this); return *this; }
  112. inline istream& istream::operator>>(unsigned char * _s) { return operator>>((char *)_s); }
  113. inline istream& istream::operator>>( signed char * _s) { return operator>>((char *)_s); }
  114. inline istream& istream::operator>>(unsigned char & _c) { return operator>>((char &) _c); }
  115. inline istream& istream::operator>>( signed char & _c) { return operator>>((char &) _c); }
  116. inline istream& istream::get( char * _b, int _lim, char _delim) { return get( _b, _lim, (int)(unsigned char)_delim); }
  117. inline istream& istream::get(unsigned char * _b, int _lim, char _delim) { return get((char *)_b, _lim, (int)(unsigned char)_delim); }
  118. inline istream& istream::get(signed char * _b, int _lim, char _delim) { return get((char *)_b, _lim, (int)(unsigned char)_delim); }
  119. inline istream& istream::get(unsigned char & _c) { return get((char &)_c); }
  120. inline istream& istream::get( signed char & _c) { return get((char &)_c); }
  121. inline istream& istream::getline( char * _b,int _lim,char _delim) { lock(); _fGline++; get( _b, _lim, (int)(unsigned char)_delim); unlock(); return *this; }
  122. inline istream& istream::getline(unsigned char * _b,int _lim,char _delim) { lock(); _fGline++; get((char *)_b, _lim, (int)(unsigned char)_delim); unlock(); return *this; }
  123. inline istream& istream::getline( signed char * _b,int _lim,char _delim) { lock(); _fGline++; get((char *)_b, _lim, (int)(unsigned char)_delim); unlock(); return *this; }
  124. inline istream& istream::ignore(int _n,int _delim) { lock(); _fGline++; get((char *)0, _n+1, _delim); unlock(); return *this; }
  125. inline istream& istream::read(unsigned char * _ptr, int _n) { return read((char *) _ptr, _n); }
  126. inline istream& istream::read( signed char * _ptr, int _n) { return read((char *) _ptr, _n); }
  127. class _CRTIMP istream_withassign : public istream {
  128. public:
  129. istream_withassign();
  130. istream_withassign(streambuf*);
  131. ~istream_withassign();
  132. istream& operator=(const istream& _is) { return istream::operator=(_is); }
  133. istream& operator=(streambuf* _isb) { return istream::operator=(_isb); }
  134. };
  135. extern _CRTIMP istream_withassign cin;
  136. inline _CRTIMP istream& __cdecl ws(istream& _ins) { _ins.eatwhite(); return _ins; }
  137. _CRTIMP ios& __cdecl dec(ios&);
  138. _CRTIMP ios& __cdecl hex(ios&);
  139. _CRTIMP ios& __cdecl oct(ios&);
  140. #ifdef _MSC_VER
  141. // Restore default packing
  142. #pragma pack(pop)
  143. #endif // _MSC_VER
  144. #endif // _INC_ISTREAM
  145. #endif /* __cplusplus */