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.

76 lines
1.4 KiB

  1. // Blob.cpp -- Blob primitives
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1999. 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(_UNICODE)
  8. #if !defined(UNICODE)
  9. #define UNICODE
  10. #endif //!UNICODE
  11. #endif //_UNICODE
  12. #if defined(UNICODE)
  13. #if !defined(_UNICODE)
  14. #define _UNICODE
  15. #endif //!_UNICODE
  16. #endif //UNICODE
  17. #include "NoWarning.h"
  18. #include "ForceLib.h"
  19. #include <limits>
  20. #include "Blob.h"
  21. using namespace std;
  22. Blob const
  23. AsBlob(std::string const &rrhs)
  24. {
  25. return reinterpret_cast<Blob const &>(rrhs);
  26. }
  27. Blob
  28. AsBlob(std::string &rrhs)
  29. {
  30. return reinterpret_cast<Blob &>(rrhs);
  31. }
  32. string const
  33. AsString(Blob const &rrhs)
  34. {
  35. return reinterpret_cast<string const &>(rrhs);
  36. }
  37. string
  38. AsString(Blob &rrhs)
  39. {
  40. return reinterpret_cast<string &>(rrhs);
  41. }
  42. const char*
  43. AsCCharP(LPCTSTR pczs)
  44. {
  45. return reinterpret_cast<const char*>(pczs);
  46. }
  47. Blob::size_type
  48. LengthFromBits(size_t cBitLength)
  49. {
  50. Blob::size_type cLength =
  51. cBitLength / numeric_limits<Blob::value_type>::digits;
  52. if (0 != (cBitLength % numeric_limits<Blob::value_type>::digits))
  53. ++cLength;
  54. return cLength;
  55. }
  56. size_t
  57. LengthInBits(Blob::size_type cSize)
  58. {
  59. return cSize * numeric_limits<Blob::value_type>::digits;
  60. }