playstring.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef _PLAYSTRING_H
  2. #define _PLAYSTRING_H
  3. #include <bfc/common.h>
  4. #include <bfc/string/StringW.h>
  5. class Playstring
  6. {
  7. public:
  8. Playstring(const wchar_t *val=NULL);
  9. Playstring(const Playstring &ps);
  10. ~Playstring();
  11. const wchar_t *getValue() const { return val; }
  12. operator const wchar_t *() const { return getValue(); }
  13. void setValue(const wchar_t *newval);
  14. // copy
  15. Playstring& operator =(const Playstring &ps);
  16. protected:
  17. void _setValue(const wchar_t *newval, int tablenum);
  18. private:
  19. const wchar_t *val;
  20. };
  21. class PlaystringComparator {
  22. public:
  23. // comparator for sorting
  24. static int compareItem(Playstring *p1, Playstring* p2) {
  25. return wcscmp(p1->getValue(), p2->getValue());
  26. }
  27. };
  28. template <int tablenum=0>
  29. class PlaystringT : public Playstring {
  30. public:
  31. PlaystringT(const wchar_t *newval) {
  32. val = NULL; setValue(newval);
  33. }
  34. PlaystringT(const Playstring &ps) {
  35. val = NULL; setValue(ps.getValue());
  36. }
  37. void setValue(const wchar_t *newval) { _setValue(newval, tablenum); }
  38. };
  39. #endif