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.

56 lines
1.1 KiB

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