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.

98 lines
2.1 KiB

  1. /***
  2. * istream1.cpp - non-core definitions for istream & istream_withassign classes
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Definitions of non-core member functions for istream and
  8. * istream_withassign classes.
  9. * [AT&T C++]
  10. *
  11. *Revision History:
  12. * 09-23-91 KRS Created. Split off from istream.cxx for granularity.
  13. * 10-07-91 KRS Increment x_gcount in get(sb).
  14. * 10-24-91 KRS Fix istream_withassign::operator=() functions.
  15. * 11-20-91 KRS Make operator= inline.
  16. * 03-30-92 KRS Add multithread locking.
  17. * 06-14-95 CFW Comment cleanup.
  18. *
  19. *******************************************************************************/
  20. #include <cruntime.h>
  21. #include <internal.h>
  22. #include <stdlib.h>
  23. #include <iostream.h>
  24. #pragma hdrstop
  25. istream& istream::operator>>(streambuf* _sbuf)
  26. {
  27. int c;
  28. if (ipfx(0))
  29. {
  30. while ((c=bp->sbumpc())!=EOF)
  31. {
  32. if (_sbuf->sputc(c)==EOF)
  33. {
  34. state |= ios::failbit;
  35. }
  36. }
  37. isfx();
  38. }
  39. return *this;
  40. }
  41. // unformatted input functions
  42. istream& istream::get( streambuf& sbuf, char delim)
  43. {
  44. int c;
  45. if (ipfx(1)) // resets x_gcount
  46. {
  47. while ((c = bp->sgetc())!=delim)
  48. {
  49. if (c==EOF) // stop if EOF encountered
  50. {
  51. state |= ios::eofbit;
  52. break;
  53. }
  54. bp->stossc(); // advance get pointer
  55. x_gcount++; // and increment count
  56. if (sbuf.sputc(c)==EOF)
  57. state |= ios::failbit;
  58. }
  59. isfx();
  60. }
  61. return *this;
  62. }
  63. istream& istream::seekg(streampos _strmp)
  64. {
  65. lockbuf();
  66. if (bp->seekpos(_strmp, ios::in)==EOF)
  67. {
  68. clear(state | failbit);
  69. }
  70. unlockbuf();
  71. return(*this);
  72. }
  73. istream& istream::seekg(streamoff _strmf, seek_dir _sd)
  74. {
  75. lockbuf();
  76. if (bp->seekoff(_strmf, _sd, ios::in)==EOF)
  77. clear(state | failbit);
  78. unlockbuf();
  79. return(*this);
  80. }
  81. streampos istream::tellg()
  82. {
  83. streampos retval;
  84. lockbuf();
  85. if ((retval=bp->seekoff(streamoff(0), ios::cur, ios::in))==EOF)
  86. clear(state | failbit);
  87. unlockbuf();
  88. return(retval);
  89. }