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.

97 lines
3.8 KiB

  1. #if !defined(_BCL_W32UNICODEFIXEDSTRINGBUFFER_H_INCLUDED_)
  2. #define _BCL_W32UNICODEFIXEDSTRINGBUFFER_H_INCLUDED_
  3. #pragma once
  4. /*++
  5. Copyright (c) 2000 Microsoft Corporation
  6. Module Name:
  7. bcl_w32unicodefixedstringbuffer.h
  8. Abstract:
  9. Author:
  10. Michael Grier (MGrier) 2/6/2002
  11. Revision History:
  12. --*/
  13. #include <windows.h>
  14. #include <bcl_inlinestring.h>
  15. #include <bcl_unicodechartraits.h>
  16. #include <bcl_w32common.h>
  17. #include <bcl_w32baseunicodestringbuffer.h>
  18. namespace BCL
  19. {
  20. template <SIZE_T nInlineChars> class CWin32BaseUnicodeFixedStringBuffer;
  21. template <SIZE_T nInlineChars>
  22. class CWin32BaseUnicodeFixedStringBufferTraits : public CWin32BaseUnicodeStringBufferTraits<CWin32BaseUnicodeFixedStringBuffer<nInlineChars>, CWin32CallDisposition, BOOL>
  23. {
  24. typedef CWin32BaseUnicodeFixedStringBufferTraits<nInlineChars> TThis;
  25. typedef CWin32BaseUnicodeFixedStringBuffer<nInlineChars> TBuffer;
  26. typedef void TAccessor;
  27. friend BCL::CPureString<TThis>;
  28. friend BCL::CInlineString<TThis>;
  29. friend BCL::CUnicodeCharTraits<TBuffer, TCallDisposition>;
  30. friend CWin32BaseUnicodeStringBufferTraits<CWin32BaseUnicodeFixedStringBuffer<nInlineChars>, CWin32CallDisposition, BOOL>;
  31. typedef BCL::CInlineString<TThis> TInlineString;
  32. typedef CWin32BaseUnicodeFixedStringBuffer<nInlineChars> TBuffer;
  33. static inline PWSTR __fastcall GetInlineBufferPtr(const BCL::CBaseString *p) { return static_cast<const TBuffer *>(p)->GetInlineBufferPtr(); }
  34. static inline SIZE_T __fastcall GetInlineBufferCch(const BCL::CBaseString *p) { return nInlineChars; }
  35. static inline TConstantPair __fastcall InlineBufferPair(const BCL::CBaseString *p) { return TConstantPair(TThis::GetInlineBufferPtr(p), TThis::GetInlineBufferCch(p)); }
  36. static inline TMutablePair __fastcall InlineMutableBufferPair(const BCL::CBaseString *p) { return TMutablePair(TThis::GetInlineBufferPtr(p), TThis::GetInlineBufferCch(p)); }
  37. static inline CWin32CallDisposition RoundBufferSize(SIZE_T cch, SIZE_T &rcchGranted) { BCL_MAYFAIL_PROLOG BCL_PARAMETER_CHECK(cch > nInlineChars); rcchGranted = 0; return CWin32CallDisposition::BufferOverflow(); BCL_MAYFAIL_EPILOG_INTERNAL }
  38. // We never have a non-inline buffer, so these shouldn't ever get called.
  39. static inline CWin32CallDisposition __fastcall ReallocateBuffer(BCL::CBaseString *p, SIZE_T cch)
  40. {
  41. BCL_ASSERT(false);
  42. return CWin32CallDisposition::InternalError_RuntimeCheck();
  43. }
  44. static inline void __fastcall DeallocateBuffer(PCWSTR psz)
  45. {
  46. BCL_ASSERT(false);
  47. }
  48. }; // class CWin32BaseUnicodeFixedStringBufferTraits
  49. template <SIZE_T nInlineChars>
  50. class CWin32BaseUnicodeFixedStringBuffer : private BCL::CInlineString<CWin32BaseUnicodeFixedStringBufferTraits<nInlineChars> >, private CWin32BaseUnicodeStringBufferAddIn
  51. {
  52. public:
  53. typedef CWin32BaseUnicodeFixedStringBuffer<nInlineChars> TThis;
  54. typedef CWin32BaseUnicodeFixedStringBufferTraits<nInlineChars> TTraits;
  55. inline CWin32BaseUnicodeFixedStringBuffer() : CWin32BaseUnicodeStringBufferAddIn(m_rgchInlineBuffer, nInlineChars) { }
  56. inline ~CWin32BaseUnicodeFixedStringBuffer() { } // no dynamic buffer; nothing to do.
  57. operator PCWSTR() const { return this->GetStringPtr(); }
  58. #include <bcl_stringapi.h>
  59. private:
  60. inline PWSTR GetInlineBufferPtr() const { return const_cast<PWSTR>(m_rgchInlineBuffer); }
  61. WCHAR m_rgchInlineBuffer[nInlineChars]; // Plus one to make instantiation with nInlineChars=0 work
  62. friend CWin32BaseUnicodeStringBufferTraits<TThis, CWin32CallDisposition, BOOL>;
  63. friend CWin32BaseUnicodeFixedStringBufferTraits<nInlineChars>;
  64. friend BCL::CUnicodeCharTraits<TThis, TCallDisposition>;
  65. }; // class CWin32BaseUnicodeFixedStringBuffer
  66. }; // namespace BCL
  67. #endif // !defined(_BCL_W32UNICODEFIXEDSTRINGBUFFER_H_INCLUDED_)