private.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/stc/private.h
  3. // Purpose: Private declarations for wxSTC
  4. // Author: Robin Dunn
  5. // Created: 2007-07-15
  6. // Copyright: (c) 2000 by Total Control Software
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_STC_PRIVATE_H_
  10. #define _WX_STC_PRIVATE_H_
  11. #include "wx/defs.h"
  12. #include "wx/string.h"
  13. //----------------------------------------------------------------------
  14. // Utility functions used within wxSTC
  15. #if wxUSE_UNICODE
  16. extern wxString stc2wx(const char* str);
  17. extern wxString stc2wx(const char* str, size_t len);
  18. extern wxCharBuffer wx2stc(const wxString& str);
  19. // This function takes both wxString and wxCharBuffer because it uses either
  20. // one or the other of them depending on the build mode. In Unicode it uses the
  21. // length of the already converted buffer to avoid doing the conversion again
  22. // just to compute the length.
  23. inline size_t wx2stclen(const wxString& WXUNUSED(str), const wxCharBuffer& buf)
  24. {
  25. return buf.length() - 1;
  26. }
  27. #else // not UNICODE
  28. inline wxString stc2wx(const char* str) {
  29. return wxString(str);
  30. }
  31. inline wxString stc2wx(const char* str, size_t len) {
  32. return wxString(str, len);
  33. }
  34. inline const char* wx2stc(const wxString& str) {
  35. return str.mbc_str();
  36. }
  37. // As explained above, the buffer argument is only used in Unicode build.
  38. inline size_t wx2stclen(const wxString& str, const char* WXUNUSED(buf))
  39. {
  40. return str.length();
  41. }
  42. #endif // UNICODE
  43. #endif // _WX_STC_PRIVATE_H_