Leaked source code of windows server 2003
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.

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