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.

93 lines
1.8 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation 1999
  3. Module Name:
  4. buffers
  5. Abstract:
  6. This header file describes the class for a high-efficency buffer management
  7. tool.
  8. Author:
  9. Doug Barlow (dbarlow) 9/2/1999
  10. Remarks:
  11. ?Remarks?
  12. Notes:
  13. ?Notes?
  14. --*/
  15. #ifndef _BUFFERS_H_
  16. #define _BUFFERS_H_
  17. #ifdef __cplusplus
  18. class CBufferReference;
  19. //
  20. //==============================================================================
  21. //
  22. // CBuffer
  23. //
  24. class CBuffer
  25. {
  26. public:
  27. // Constructors & Destructor
  28. CBuffer(void);
  29. CBuffer(ULONG cbLength);
  30. CBuffer(LPCBYTE pbData, ULONG cbLength);
  31. virtual ~CBuffer();
  32. // Methods
  33. void Empty(void);
  34. void Set(LPCBYTE pbData, ULONG cbLength);
  35. void Copy(LPCBYTE pbData, ULONG cbLength);
  36. void Append(LPCBYTE pbData, ULONG cbLength);
  37. LPBYTE Extend(ULONG cbLength);
  38. ULONG Space(void) const;
  39. LPBYTE Space(ULONG cbLength);
  40. ULONG Length(void) const;
  41. LPCBYTE Length(ULONG cbLength);
  42. LPCBYTE Value(ULONG nOffset = 0) const;
  43. LPBYTE Access(ULONG nOffset = 0) const;
  44. BOOL IsEmpty(void) const
  45. { return 0 == Length(); };
  46. // Operators
  47. operator LPCBYTE()
  48. { return Value(); };
  49. operator LPBYTE()
  50. { return Access(); };
  51. BYTE operator [](ULONG nOffset)
  52. { return *Value(nOffset); };
  53. CBuffer &operator =(const CBuffer &bf)
  54. { Set(bf.m_pbfr);
  55. m_cbDataLength = bf.m_cbDataLength;
  56. return *this; };
  57. CBuffer &operator +=(const CBuffer &bf)
  58. { Append(bf.Value(), bf.Length());
  59. return *this; };
  60. protected:
  61. // Properties
  62. CBufferReference *m_pbfr;
  63. ULONG m_cbDataLength;
  64. // Methods
  65. void Init(void);
  66. void Set(CBufferReference *pbfr);
  67. };
  68. #endif //__cplusplus
  69. #endif // _BUFFERS_H_