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.

91 lines
2.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1994 **/
  4. /**********************************************************************/
  5. /*
  6. cbin.hxx
  7. This module contains a light weight binary buffer class
  8. FILE HISTORY:
  9. 17-May-1996 MichTh Created from string.hxx
  10. */
  11. #ifndef _CBIN_HXX_
  12. #define _CBIN_HXX_
  13. class CBIN;
  14. class CBIN : public BUFFER
  15. {
  16. public:
  17. dllexp CBIN()
  18. {
  19. }
  20. dllexp CBIN( DWORD cbLen, const PVOID pbInit );
  21. dllexp CBIN( const CBIN & cbin );
  22. dllexp BOOL Append( DWORD cbLen, const PVOID pbInit );
  23. dllexp BOOL Append( const CBIN & cbin );
  24. dllexp BOOL Copy( DWORD cbLen, const PVOID pbInit );
  25. dllexp BOOL Copy( const CBIN & cbin );
  26. dllexp BOOL Resize( UINT cbNewReqestedSize );
  27. //
  28. // Returns the number of bytes in the buffer
  29. //
  30. dllexp UINT QueryCB( VOID ) const
  31. { return _cbLen; }
  32. dllexp VOID SetCB( UINT cbLen )
  33. { _cbLen = cbLen; }
  34. dllexp PVOID QueryBuf( VOID ) const
  35. { return QueryPtr(); }
  36. dllexp BOOL IsValid( VOID ) const
  37. { return _fValid; }
  38. //
  39. // Checks and returns TRUE if this string has no valid data else FALSE
  40. //
  41. dllexp BOOL IsEmpty( VOID) const
  42. { return ( QueryCB() == 0); }
  43. //
  44. // Makes a clone of the current buffer in the CBIN pointer passed in.
  45. //
  46. dllexp BOOL
  47. Clone( OUT CBIN * pstrClone) const
  48. {
  49. if ( pstrClone == NULL) {
  50. SetLastError( ERROR_INVALID_PARAMETER);
  51. return ( FALSE);
  52. } else {
  53. return ( pstrClone->Copy( *this));
  54. }
  55. } // CBIN::Clone()
  56. private:
  57. //
  58. // Returned when our buffer is empty
  59. //
  60. DWORD _cbLen;
  61. BOOL _fValid;
  62. VOID AuxInit( DWORD cbLen, PVOID pbInit);
  63. BOOL AuxAppend( PVOID pbInit, UINT cbBuf, BOOL fAddSlop = TRUE );
  64. };
  65. #endif // !_CBIN_HXX_
  66.