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.

98 lines
2.0 KiB

  1. #pragma once
  2. #define CRT_ALLOC 0
  3. #define COM_ALLOC 1
  4. //-----------------------------------------------------------------------------
  5. // Minimal string class
  6. //-----------------------------------------------------------------------------
  7. class CString
  8. {
  9. public:
  10. enum AllocFlags
  11. {
  12. COM_Allocator = 0,
  13. CRT_Allocator
  14. };
  15. enum HashFlags
  16. {
  17. CaseInsensitive = 0,
  18. CaseSensitive
  19. };
  20. DWORD _dwSig;
  21. HRESULT _hr;
  22. LPWSTR _pwz; // Str ptr.
  23. DWORD _cc; // String length
  24. DWORD _ccBuf; // Buffer length
  25. AllocFlags _eAlloc; // Allocator
  26. // ctor
  27. CString();
  28. // ctor w/ allocator
  29. CString(AllocFlags eAlloc);
  30. // dtor
  31. ~CString();
  32. // Allocations
  33. HRESULT ResizeBuffer(DWORD ccNew);
  34. // Deallocations
  35. VOID FreeBuffer();
  36. // Assume control for a buffer.
  37. HRESULT TakeOwnership(WCHAR* pwz, DWORD cc);
  38. HRESULT TakeOwnership(LPWSTR pwz);
  39. // Release control.
  40. HRESULT ReleaseOwnership();
  41. // Direct copy assign from string.
  42. HRESULT Assign(LPWSTR pwzSource);
  43. // Direct copy assign from CString
  44. HRESULT Assign(CString& sSource);
  45. // Append given wchar string.
  46. HRESULT Append(LPWSTR pwzSource);
  47. // Append given CString
  48. HRESULT Append(CString& sSource);
  49. // Return ith element.
  50. WCHAR& operator [] (DWORD i);
  51. HRESULT LastElement(CString &sSource);
  52. HRESULT RemoveLastElement();
  53. HRESULT Combine(LPWSTR pwzSource, BOOL fUrl);
  54. HRESULT PathCombine(LPWSTR pwzSource);
  55. HRESULT PathCombine(CString &sSource);
  56. HRESULT UrlCombine(LPWSTR pwzSource);
  57. HRESULT UrlCombine(CString &sSource);
  58. HRESULT PathFindFileName(LPWSTR *ppwz);
  59. HRESULT PathFindFileName(CString &sPath);
  60. HRESULT PathPrefixMatch(LPWSTR pwzPrefix);
  61. // / -> \ in string
  62. VOID PathNormalize();\
  63. VOID Get65599Hash(LPDWORD pdwHash, DWORD dwFlags);
  64. };