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.

170 lines
5.7 KiB

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