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.

217 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. bufstrm.hxx
  5. Abstract:
  6. This module contains the declaration for the BUFFER_STREAM class.
  7. The BUFFER_STREAM is an abstract class derived from STREAM, that
  8. provides a buffer for read operations in STREAM.
  9. Buffer for read operations is needed in order to read
  10. STRINGs from streams.
  11. Buffer for write operation is not currently implemented. It should
  12. be implemented if we notice that write operations are slow.
  13. Author:
  14. Jaime Sasson (jaimes) 12-Apr-1991
  15. Environment:
  16. ULIB, User Mode
  17. --*/
  18. #if !defined( _BUFFER_STREAM_ )
  19. #define _BUFFER_STREAM_
  20. #include "stream.hxx"
  21. #include "wstring.hxx"
  22. DECLARE_CLASS( STREAM );
  23. class BUFFER_STREAM : public STREAM {
  24. public:
  25. VIRTUAL
  26. ~BUFFER_STREAM(
  27. );
  28. VIRTUAL
  29. BOOLEAN
  30. IsAtEnd(
  31. ) CONST;
  32. VIRTUAL
  33. STREAMACCESS
  34. QueryAccess(
  35. ) CONST PURE;
  36. VIRTUAL
  37. VOID
  38. SetStreamTypeANSI(
  39. );
  40. VIRTUAL
  41. BOOLEAN
  42. DetermineStreamType(
  43. IN OUT PBYTE *Buffer,
  44. IN ULONG BufferSize
  45. );
  46. VIRTUAL
  47. BOOLEAN
  48. Read(
  49. OUT PBYTE Buffer,
  50. IN ULONG BytesToRead,
  51. OUT PULONG BytesRead
  52. );
  53. VIRTUAL
  54. BOOLEAN
  55. ReadChar(
  56. OUT PWCHAR Char,
  57. IN BOOLEAN Unicode DEFAULT FALSE
  58. );
  59. VIRTUAL
  60. BOOLEAN
  61. ReadMbString(
  62. IN PSTR String,
  63. IN DWORD BufferSize,
  64. INOUT PDWORD StringSize,
  65. IN PSTR Delimiters,
  66. IN BOOLEAN ExpandTabs DEFAULT FALSE,
  67. IN DWORD TabExp DEFAULT 8
  68. );
  69. VIRTUAL
  70. BOOLEAN
  71. ReadWString(
  72. IN PWSTR String,
  73. IN DWORD BufferSize,
  74. INOUT PDWORD StringSize,
  75. IN PWSTR Delimiters,
  76. IN BOOLEAN ExpandTabs DEFAULT FALSE,
  77. IN DWORD TabExp DEFAULT 8
  78. );
  79. VIRTUAL
  80. BOOLEAN
  81. ReadString(
  82. OUT PWSTRING String,
  83. IN PWSTRING Delimiters,
  84. IN BOOLEAN Unicode DEFAULT FALSE
  85. );
  86. protected:
  87. DECLARE_CONSTRUCTOR( BUFFER_STREAM );
  88. NONVIRTUAL
  89. BOOLEAN
  90. Initialize(
  91. IN ULONG BufferSize
  92. );
  93. NONVIRTUAL
  94. VOID
  95. Construct(
  96. );
  97. VIRTUAL
  98. BOOLEAN
  99. AdvanceBufferPointer(
  100. IN ULONG NumberOfBytes
  101. );
  102. VIRTUAL
  103. BOOLEAN
  104. EndOfFile(
  105. ) CONST PURE;
  106. VIRTUAL
  107. BOOLEAN
  108. FillBuffer(
  109. IN PBYTE Buffer,
  110. IN ULONG BufferSize,
  111. OUT PULONG BytesRead
  112. ) PURE;
  113. NONVIRTUAL
  114. ULONG
  115. FlushBuffer(
  116. );
  117. VIRTUAL
  118. PCBYTE
  119. GetBuffer(
  120. PULONG BytesInBuffer
  121. );
  122. NONVIRTUAL
  123. ULONG
  124. QueryBytesInBuffer(
  125. ) CONST;
  126. VIRTUAL
  127. HANDLE
  128. QueryHandle(
  129. ) CONST PURE;
  130. private:
  131. PBYTE _Buffer;
  132. ULONG _BufferSize;
  133. PBYTE _CurrentByte;
  134. ULONG _BytesInBuffer;
  135. INT _BufferStreamType;
  136. };
  137. INLINE
  138. ULONG
  139. BUFFER_STREAM::QueryBytesInBuffer(
  140. ) CONST
  141. /*++
  142. Routine Description:
  143. Returns the number of bytes in the buffer.
  144. Arguments:
  145. None.
  146. Return Value:
  147. ULONG - Number of bytes in the buffer.
  148. --*/
  149. {
  150. return( _BytesInBuffer );
  151. }
  152. #endif // _BUFFER_STREAM_