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.

149 lines
5.4 KiB

  1. /***
  2. *istream.h - definitions/declarations for the istream class
  3. *
  4. * Copyright (c) 1990-1992, 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. #include <ios.h>
  15. // Force word packing to avoid possible -Zp override
  16. #pragma pack(2)
  17. #pragma warning(disable:4505) // disable unwanted /W4 warning
  18. // #pragma warning(default:4505) // use this to reenable, if necessary
  19. #ifdef M_I86HM
  20. #define _HFAR_ __far
  21. #else
  22. #define _HFAR_
  23. #endif
  24. typedef long streamoff, streampos;
  25. class istream : virtual public ios {
  26. public:
  27. istream(streambuf*);
  28. virtual ~istream();
  29. int ipfx(int =0);
  30. void isfx() { }
  31. inline istream& operator>>(istream& (*_f)(istream&));
  32. inline istream& operator>>(ios& (*_f)(ios&));
  33. istream& operator>>(char _HFAR_ *);
  34. inline istream& operator>>(unsigned char _HFAR_ *);
  35. inline istream& operator>>(signed char _HFAR_ *);
  36. istream& operator>>(char _HFAR_ &);
  37. inline istream& operator>>(unsigned char _HFAR_ &);
  38. inline istream& operator>>(signed char _HFAR_ &);
  39. istream& operator>>(short _HFAR_ &);
  40. istream& operator>>(unsigned short _HFAR_ &);
  41. istream& operator>>(int _HFAR_ &);
  42. istream& operator>>(unsigned int _HFAR_ &);
  43. istream& operator>>(long _HFAR_ &);
  44. istream& operator>>(unsigned long _HFAR_ &);
  45. istream& operator>>(float _HFAR_ &);
  46. istream& operator>>(double _HFAR_ &);
  47. istream& operator>>(long double _HFAR_ &);
  48. istream& operator>>(streambuf*);
  49. int get();
  50. istream& get(char _HFAR_ *,int,char ='\n');
  51. inline istream& get(unsigned char _HFAR_ *,int,char ='\n');
  52. inline istream& get(signed char _HFAR_ *,int,char ='\n');
  53. istream& get(char _HFAR_ &);
  54. inline istream& get(unsigned char _HFAR_ &);
  55. inline istream& get(signed char _HFAR_ &);
  56. istream& get(streambuf&,char ='\n');
  57. inline istream& getline(char _HFAR_ *,int,char ='\n');
  58. inline istream& getline(unsigned char _HFAR_ *,int,char ='\n');
  59. inline istream& getline(signed char _HFAR_ *,int,char ='\n');
  60. inline istream& ignore(int =1,int =EOF);
  61. istream& read(char _HFAR_ *,int);
  62. inline istream& read(unsigned char _HFAR_ *,int);
  63. inline istream& read(signed char _HFAR_ *,int);
  64. int gcount() const { return x_gcount; }
  65. int peek();
  66. istream& putback(char);
  67. int sync();
  68. istream& seekg(streampos);
  69. istream& seekg(streamoff,ios::seek_dir);
  70. streampos tellg();
  71. void eatwhite(); // consider: protect and friend with manipulator ws
  72. protected:
  73. istream();
  74. istream(const istream&); // treat as private
  75. istream& operator=(streambuf* _isb); // treat as private
  76. istream& operator=(const istream& _is) { return operator=(_is.rdbuf()); }
  77. int do_ipfx(int);
  78. private:
  79. istream(ios&);
  80. int getint(char _HFAR_ *);
  81. int getdouble(char _HFAR_ *, int);
  82. int _fGline;
  83. int x_gcount;
  84. };
  85. inline istream& istream::operator>>(istream& (*_f)(istream&)) { (*_f)(*this); return *this; }
  86. inline istream& istream::operator>>(ios& (*_f)(ios&)) { (*_f)(*this); return *this; }
  87. inline istream& istream::operator>>(unsigned char _HFAR_ * _s) { return operator>>((char _HFAR_ *)_s); }
  88. inline istream& istream::operator>>(signed char _HFAR_ * _s) { return operator>>((char _HFAR_ *)_s); }
  89. inline istream& istream::operator>>(unsigned char _HFAR_ & _c) { return operator>>((char _HFAR_ &) _c); }
  90. inline istream& istream::operator>>(signed char _HFAR_ & _c) { return operator>>((char _HFAR_ &) _c); }
  91. inline istream& istream::get(unsigned char _HFAR_ * b, int lim ,char delim) { return get((char _HFAR_ *)b, lim, delim); }
  92. inline istream& istream::get(signed char _HFAR_ * b, int lim, char delim) { return get((char _HFAR_ *)b, lim, delim); }
  93. inline istream& istream::get(unsigned char _HFAR_ & _c) { return get((char _HFAR_ &)_c); }
  94. inline istream& istream::get(signed char _HFAR_ & _c) { return get((char _HFAR_ &)_c); }
  95. inline istream& istream::getline(char _HFAR_ * _b,int _lim,char _delim) { _fGline++; return get(_b, _lim, _delim); }
  96. inline istream& istream::getline(unsigned char _HFAR_ * _b,int _lim,char _delim) { _fGline++; return get((char _HFAR_ *)_b, _lim, _delim); }
  97. inline istream& istream::getline(signed char _HFAR_ * _b,int _lim,char _delim) { _fGline++; return get((char _HFAR_ *)_b, _lim, _delim); }
  98. inline istream& istream::ignore(int _n,int delim) { _fGline++; return get((char _HFAR_ *)0, _n+1, (char)delim); }
  99. inline istream& istream::read(unsigned char _HFAR_ * _ptr, int _n) { return read((char _HFAR_ *) _ptr, _n); }
  100. inline istream& istream::read(signed char _HFAR_ * _ptr, int _n) { return read((char _HFAR_ *) _ptr, _n); }
  101. class istream_withassign : public istream {
  102. public:
  103. istream_withassign();
  104. istream_withassign(streambuf*);
  105. ~istream_withassign();
  106. istream& operator=(const istream& _is) { return istream::operator=(_is); }
  107. istream& operator=(streambuf* _isb) { return istream::operator=(_isb); }
  108. };
  109. #ifndef _WINDLL
  110. extern istream_withassign cin;
  111. #endif
  112. inline istream& ws(istream& _ins) { _ins.eatwhite(); return _ins; }
  113. ios& dec(ios&);
  114. ios& hex(ios&);
  115. ios& oct(ios&);
  116. // Restore default packing
  117. #pragma pack()
  118. #endif