Source code of Windows XP (NT5)
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.

83 lines
2.9 KiB

  1. // AlignedBlob.h -- Simple Aligned Blob (Binary Large OBject)
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 2001. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #if !defined(SLBCSP_ALIGNEDBLOB_H)
  8. #define SLBCSP_ALIGNEDBLOB_H
  9. #include <stddef.h> // for size_t
  10. #include <scuArrayP.h>
  11. #include "Blob.h"
  12. // Copies an Blob into a data buffer that is guaranteed to be
  13. // aligned. The data buffer in Blob's (std::basic_string/string) are
  14. // not guaranteed to be aligned. Therefore interpreting the data buffer
  15. // as a structure and dereferencing a non-byte member could result in
  16. // alignment faults. AlignedBlob creates an aligned data buffer from
  17. // a Blob. Useful for 64-bit architectures. AlignedBlob's are
  18. // fixed length and can not grow. Very primitive. Their intent is
  19. // only to transform a Blob into something that is data aligned
  20. // for dereferencing purposes only.
  21. class AlignedBlob
  22. {
  23. public:
  24. // Types
  25. typedef Blob::value_type ValueType;
  26. typedef Blob::size_type SizeType;
  27. // C'tors/D'tors
  28. explicit
  29. AlignedBlob(Blob const &rblb = Blob());
  30. AlignedBlob(ValueType const *p,
  31. SizeType cLength);
  32. AlignedBlob(AlignedBlob const &rhs);
  33. virtual
  34. ~AlignedBlob() throw();
  35. // Operators
  36. AlignedBlob &
  37. operator=(AlignedBlob const &rhs);
  38. // Operations
  39. // Access
  40. ValueType *
  41. Data() const throw();
  42. SizeType
  43. Length() const throw();
  44. // Predicates
  45. protected:
  46. // Types
  47. // C'tors/D'tors
  48. // Operators
  49. // Operations
  50. // Access
  51. // Predicates
  52. // Variables
  53. private:
  54. // Types
  55. // C'tors/D'tors
  56. // Operators
  57. // Operations
  58. // Access
  59. // Predicates
  60. // Variables
  61. scu::AutoArrayPtr<ValueType> m_aaBlob;
  62. SizeType m_cLength;
  63. };
  64. #endif // SLBCSP_ALIGNEDBLOB_H