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.

78 lines
1.8 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // outbuf.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class OutputBuffer.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 08/04/1998 Original version.
  16. // 07/09/1999 Add OutputBuffer::empty
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef _OUTBUF_H_
  20. #define _OUTBUF_H_
  21. #if _MSC_VER >= 1000
  22. #pragma once
  23. #endif
  24. #include <nocopy.h>
  25. ///////////////////////////////////////////////////////////////////////////////
  26. //
  27. // CLASS
  28. //
  29. // OutputBuffer
  30. //
  31. // DESCRIPTION
  32. //
  33. // Implements a dynamically resized buffer suitable for formatting output.
  34. //
  35. ///////////////////////////////////////////////////////////////////////////////
  36. class OutputBuffer
  37. : NonCopyable
  38. {
  39. public:
  40. OutputBuffer() throw ();
  41. ~OutputBuffer() throw ();
  42. // Append an octet string.
  43. void append(const BYTE* buf, DWORD buflen);
  44. // Append a null-terminated ANSI string.
  45. void append(PCSTR sz);
  46. // Append a single ANSI character.
  47. void append(CHAR ch);
  48. bool empty() const throw ()
  49. { return next == start; }
  50. // Returns a pointer to the embedded buffer.
  51. PBYTE getBuffer() const throw ()
  52. { return start; }
  53. // Returns the number of bytes currently stored in the buffer.
  54. DWORD getLength() const throw ()
  55. { return (DWORD)(next - start); }
  56. // Reserves 'nbyte' bytes in the buffer and returns a pointer to the
  57. // reserved bytes.
  58. PBYTE reserve(DWORD nbyte);
  59. protected:
  60. // Resizes the buffer and updates cursor to point into the new buffer.
  61. void resize(PBYTE& cursor);
  62. PBYTE start, next, end;
  63. BYTE scratch[0x400];
  64. };
  65. #endif // _OUTBUF_H_