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.

54 lines
1.0 KiB

  1. #ifndef _CUSTRING_H_
  2. #define _CUSTRING_H_
  3. // Simple universal string class, where string can be converted
  4. // back and forth between Ansi and Unicode string and buffers
  5. // allocated are destroyed in string class destructor.
  6. class CUSTRING
  7. {
  8. public:
  9. CUSTRING(PCWSTR wszText = NULL);
  10. CUSTRING(PCSTR szText);
  11. ~CUSTRING();
  12. operator PWSTR();
  13. operator PSTR();
  14. inline void GiveString(PCWSTR wszText);
  15. inline void GiveString(PCSTR szText);
  16. inline void AssignString(PCWSTR wszText);
  17. inline void AssignString(PCSTR szText);
  18. protected:
  19. PWSTR wszData;
  20. PSTR szData;
  21. BOOL bUnicodeNew;
  22. BOOL bAnsiNew;
  23. };
  24. inline void CUSTRING::GiveString(PCWSTR wszText)
  25. {
  26. ASSERT(!wszData);
  27. wszData = (PWSTR)wszText;
  28. bUnicodeNew = TRUE;
  29. }
  30. inline void CUSTRING::GiveString(PCSTR szText)
  31. {
  32. ASSERT(!szData);
  33. szData = (PSTR)szText;
  34. bAnsiNew = TRUE;
  35. }
  36. inline void CUSTRING::AssignString(PCWSTR wszText)
  37. {
  38. ASSERT(!wszData);
  39. wszData = (PWSTR)wszText;
  40. }
  41. inline void CUSTRING::AssignString(PCSTR szText)
  42. {
  43. ASSERT(!szData);
  44. szData = (PSTR)szText;
  45. }
  46. #endif // ndef CUSTRING_H