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.

249 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. stream.hxx
  5. Abstract:
  6. This module contains the declarations for the STREAM class.
  7. STREAM is an abstract class used to model "devices" that
  8. allow read or write operations, as a stream of data.
  9. ("Device" here means anything that can supply or accept data
  10. through read and write operations. Examples of "devices" are
  11. keyboard, screen, file, pipes, etc.)
  12. A STREAM object can have one of the following access: READ,
  13. WRITE and READ_AND_WRITE.
  14. The STREAM class provides methods to read data from the stream,
  15. write data to the stream, check the stream access, and check if
  16. the end of the stream has occurred.
  17. (The occurrence of the end of stream means that all data in
  18. a stream with READ or READ_AND_WRITE access was consumed, and no
  19. more data can be obtained from the stream.)
  20. Author:
  21. Jaime Sasson (jaimes) 21-Mar-1991
  22. Environment:
  23. ULIB, User Mode
  24. --*/
  25. #if !defined( _STREAM_ )
  26. #define _STREAM_
  27. #include "wstring.hxx"
  28. #include "system.hxx"
  29. DECLARE_CLASS( STREAM );
  30. enum STREAMACCESS {
  31. READ_ACCESS,
  32. WRITE_ACCESS,
  33. READ_AND_WRITE_ACCESS
  34. };
  35. class STREAM : public OBJECT {
  36. public:
  37. friend BOOLEAN SYSTEM::PutStandardStream( DWORD, PSTREAM );
  38. VIRTUAL
  39. ~STREAM(
  40. );
  41. VIRTUAL
  42. BOOLEAN
  43. IsAtEnd(
  44. ) CONST PURE;
  45. VIRTUAL
  46. STREAMACCESS
  47. QueryAccess(
  48. ) CONST PURE;
  49. VIRTUAL
  50. BOOLEAN
  51. Read(
  52. OUT PBYTE Buffer,
  53. IN ULONG BytesToRead,
  54. OUT PULONG BytesRead
  55. ) PURE;
  56. NONVIRTUAL
  57. BOOLEAN
  58. ReadByte(
  59. OUT PBYTE Data
  60. );
  61. VIRTUAL
  62. BOOLEAN
  63. ReadChar(
  64. OUT PWCHAR Char,
  65. IN BOOLEAN Unicode DEFAULT FALSE
  66. ) PURE;
  67. NONVIRTUAL
  68. ULIB_EXPORT
  69. BOOLEAN
  70. ReadLine(
  71. OUT PWSTRING String,
  72. IN BOOLEAN Unicode DEFAULT FALSE
  73. );
  74. NONVIRTUAL
  75. ULIB_EXPORT
  76. BOOLEAN
  77. ReadMbLine(
  78. IN PSTR String,
  79. IN DWORD BufferSize,
  80. INOUT PDWORD StringSize,
  81. IN BOOLEAN ExpandTabs DEFAULT FALSE,
  82. IN DWORD TabExp DEFAULT 8
  83. );
  84. VIRTUAL
  85. BOOLEAN
  86. ReadMbString(
  87. IN PSTR String,
  88. IN DWORD BufferSize,
  89. INOUT PDWORD StringSize,
  90. IN PSTR Delimiters,
  91. IN BOOLEAN ExpandTabs DEFAULT FALSE,
  92. IN DWORD TabExp DEFAULT 8
  93. ) PURE;
  94. NONVIRTUAL
  95. ULIB_EXPORT
  96. BOOLEAN
  97. ReadWLine(
  98. IN PWSTR String,
  99. IN DWORD BufferSize,
  100. INOUT PDWORD StringSize,
  101. IN BOOLEAN ExpandTabs DEFAULT FALSE,
  102. IN DWORD TabExp DEFAULT 8
  103. );
  104. VIRTUAL
  105. BOOLEAN
  106. ReadWString(
  107. IN PWSTR String,
  108. IN DWORD BufferSize,
  109. INOUT PDWORD StringSize,
  110. IN PWSTR Delimiters,
  111. IN BOOLEAN ExpandTabs DEFAULT FALSE,
  112. IN DWORD TabExp DEFAULT 8
  113. ) PURE;
  114. VIRTUAL
  115. BOOLEAN
  116. ReadString(
  117. OUT PWSTRING String,
  118. IN PWSTRING Delimiters,
  119. IN BOOLEAN Unicode DEFAULT FALSE
  120. ) PURE;
  121. VIRTUAL
  122. BOOLEAN
  123. Write(
  124. IN PCBYTE Buffer,
  125. IN ULONG BytesToWrite,
  126. OUT PULONG BytesWritten
  127. );
  128. NONVIRTUAL
  129. ULIB_EXPORT
  130. BOOLEAN
  131. WriteByte(
  132. IN BYTE Data
  133. );
  134. VIRTUAL
  135. BOOLEAN
  136. WriteChar(
  137. IN WCHAR Char
  138. );
  139. VIRTUAL
  140. BOOLEAN
  141. WriteString(
  142. IN PCWSTRING String,
  143. IN CHNUM Position DEFAULT 0,
  144. IN CHNUM Length DEFAULT TO_END,
  145. IN CHNUM Granularity DEFAULT 0
  146. );
  147. VIRTUAL
  148. VOID
  149. DoNotRestoreConsoleMode(
  150. ) {}
  151. protected:
  152. DECLARE_CONSTRUCTOR( STREAM );
  153. NONVIRTUAL
  154. BOOLEAN
  155. Initialize(
  156. );
  157. VIRTUAL
  158. HANDLE
  159. QueryHandle(
  160. ) CONST PURE;
  161. private:
  162. DSTRING _Delimiter;
  163. PSTR _MbDelimiter;
  164. PWSTR _WDelimiter;
  165. };
  166. INLINE
  167. BOOLEAN
  168. STREAM::Initialize(
  169. )
  170. /*++
  171. Routine Description:
  172. Initializes an object of type STREAM.
  173. Arguments:
  174. None.
  175. Return Value:
  176. Returns TRUE if the initialization succeeded, or FALSE otherwise.
  177. --*/
  178. {
  179. _MbDelimiter = "\n";
  180. _WDelimiter = L"\n";
  181. return( _Delimiter.Initialize( "\n" ) );
  182. }
  183. #endif // _STREAM_