1
0

string_unicode.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _PFC_STRING_UNICODE_H_
  2. #define _PFC_STRING_UNICODE_H_
  3. #include "string.h"
  4. class string_w : public string_base<WCHAR>
  5. {
  6. public:
  7. string_w() {}
  8. string_w(HWND w) {s_GetWindowText(w);}
  9. string_w(const WCHAR * z) {set_string(z);}
  10. void add_string_a(const char * c);
  11. void set_string_a(const char * c);
  12. string_w(const char * z) {set_string_a(z);}
  13. string_w(const string_w & z) {set_string(z);}
  14. string_w(const string_a & z) {set_string_a(z);}
  15. void add_string_utf8(const char * z);
  16. void set_string_utf8(const char * z);
  17. void s_GetWindowText(HWND w);
  18. inline void from_window(HWND w) {s_GetWindowText(w);}
  19. void s_SetWindowText(HWND w);
  20. const WCHAR * operator=(const WCHAR * s) {set_string(s);return get_ptr();}
  21. const WCHAR * operator+=(const WCHAR * s) {add_string(s);return get_ptr();}
  22. const WCHAR * operator=(const char * s) {set_string_a(s);return get_ptr();}
  23. const WCHAR * operator+=(const char * s) {add_string_a(s);return get_ptr();}
  24. const WCHAR * operator=(string_w & s) {set_string(s);return get_ptr();}
  25. const WCHAR * operator+=(string_w & s) {add_string(s);return get_ptr();}
  26. inline void s_GetDlgItemText(HWND w,int id) {s_GetWindowText(GetDlgItem(w,id));}
  27. inline void s_SetDlgItemText(HWND w,int id) {s_SetWindowText(GetDlgItem(w,id));}
  28. bool reg_read(HKEY hk,const WCHAR * name);
  29. void reg_write(HKEY hk,const WCHAR * name);
  30. static bool test_os();
  31. };
  32. class string_reg : public string_w
  33. {
  34. public:
  35. string_reg(HKEY hk,const WCHAR * name) {reg_read(hk,name);}
  36. string_reg(HKEY hk,const char * name) {reg_read(hk,string_w(name));}
  37. };
  38. class string_printf_w : public string_w
  39. {
  40. public:
  41. string_printf_w(const WCHAR * fmt,...);
  42. };
  43. class string_utf8 : public string_a
  44. {
  45. private:
  46. void convert(const WCHAR * foo);
  47. public:
  48. string_utf8(const WCHAR * foo) {convert(foo);}
  49. string_utf8(const char * foo) {convert(string_w(foo));}
  50. };
  51. #endif //_PFC_STRING_UNICODE_H_