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.

51 lines
861 B

  1. // tstring.h
  2. //
  3. // string<> no longer has compare operators like it supposed to.
  4. //
  5. #pragma once
  6. //
  7. // Use the heap allocator if it's been included
  8. //
  9. #ifdef __ALLOC_H
  10. typedef basic_string<wchar_t, char_traits<wchar_t>,
  11. ::heap_allocator<wchar_t> > whstring;
  12. typedef basic_string<char, char_traits<char>,
  13. ::heap_allocator<char> > hstring;
  14. #else
  15. #define whstring wstring
  16. #define hstring string
  17. #endif
  18. class tstring : public
  19. #ifdef UNICODE
  20. whstring
  21. #else
  22. hstring
  23. #endif
  24. {
  25. public:
  26. tstring(){};
  27. tstring(LPCTSTR sz) :
  28. #ifdef UNICODE
  29. whstring(sz)
  30. #else
  31. hstring(sz)
  32. #endif
  33. {};
  34. operator LPCTSTR()
  35. { return c_str(); }
  36. bool operator<(const tstring& rhs) const
  37. { return (compare(rhs)<0); }
  38. bool operator==(const tstring& rhs)
  39. { return (0 == compare(rhs)); }
  40. TCHAR operator[] (int index)
  41. { return c_str()[index]; }
  42. };