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
2.6 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. compstr.h
  5. Abstract:
  6. This file defines the CCompStrFactory Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #ifndef _COMPSTR_H_
  12. #define _COMPSTR_H_
  13. #include "cime.h"
  14. #include "template.h"
  15. #include "ctxtcomp.h"
  16. class CCompStrFactory : public IMCCLock<COMPOSITIONSTRING_AIMM12>
  17. {
  18. public:
  19. CCompStrFactory(HIMCC hCompStr) : IMCCLock<COMPOSITIONSTRING_AIMM12>(hCompStr)
  20. {
  21. m_pEndOfData = NULL;
  22. }
  23. HIMCC GetHandle()
  24. {
  25. return m_himcc;
  26. }
  27. HRESULT CreateCompositionString(CWCompString* CompStr,
  28. CWCompAttribute* CompAttr,
  29. CWCompClause* CompClause,
  30. CWCompTfGuidAtom* CompGuid,
  31. CWCompString* CompReadStr,
  32. CWCompAttribute* CompReadAttr,
  33. CWCompClause* CompReadClause,
  34. CWCompString* ResultStr,
  35. CWCompClause* ResultClause,
  36. CWCompString* ResultReadStr,
  37. CWCompClause* ResultReadClause
  38. );
  39. HRESULT CreateCompositionString(CWInterimString* InterimStr);
  40. template<class CONTEXT_SRC, class ARG_TYPE>
  41. HRESULT WriteData(CONTEXT_SRC& context_src,
  42. DWORD* context_dest_len,
  43. DWORD* context_dest_off
  44. )
  45. {
  46. DWORD dwLen = (DWORD)context_src.GetSize();
  47. DWORD dwRemainBufferSize = GetRemainBufferSize();
  48. if (dwLen > dwRemainBufferSize)
  49. return E_OUTOFMEMORY;
  50. *context_dest_len = dwLen;
  51. *context_dest_off = (DWORD)(m_pEndOfData - (BYTE*)m_pcomp);
  52. context_src.ReadCompData((ARG_TYPE*)m_pEndOfData, dwRemainBufferSize);
  53. m_pEndOfData += Align(dwLen * sizeof(ARG_TYPE));
  54. return S_OK;
  55. }
  56. private:
  57. HRESULT _CreateCompositionString(DWORD dwCompSize);
  58. DWORD GetRemainBufferSize()
  59. {
  60. if (m_pEndOfData == NULL)
  61. return 0;
  62. return (DWORD)(m_pcomp->CompStr.dwSize > (DWORD)(m_pEndOfData - (BYTE*)m_pcomp) ? m_pcomp->CompStr.dwSize - (m_pEndOfData - (BYTE*)m_pcomp) : 0);
  63. }
  64. size_t Align(size_t a)
  65. {
  66. return (size_t) ((a + (sizeof(PVOID)-1)) & ~(sizeof(PVOID)-1));
  67. }
  68. BYTE* m_pEndOfData;
  69. };
  70. #endif // _COMPSTR_H_