xlocale.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: xlocale.h
  3. // Purpose: interface of wxXLocale
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxXLocale
  9. This class represents a locale object used by so-called xlocale API.
  10. Unlike wxLocale it doesn't provide any non-trivial operations but simply
  11. provides a portable wrapper for POSIX @c locale_t type.
  12. It exists solely to be provided as an argument to various @c wxFoo_l() functions
  13. which are the extensions of the standard locale-dependent functions (hence the
  14. name xlocale). These functions do exactly the same thing as the corresponding
  15. standard @c foo() except that instead of using the global program locale
  16. they use the provided wxXLocale object.
  17. See @ref group_funcmacro_locale for a list of wxXLocale-enabled functions.
  18. Conversely, if a program wanted to output the number in French locale, even if
  19. the current locale is different, it could use wxXLocale(wxLANGUAGE_FRENCH).
  20. @section xlocale_avail Availability
  21. This class is fully implemented only under the platforms where xlocale POSIX
  22. API or equivalent is available. Currently the xlocale API is available under
  23. most of the recent Unix systems (including Linux, various BSD and Mac OS X) and
  24. Microsoft Visual C++ standard library provides a similar API starting from
  25. version 8 (Visual Studio 2005).
  26. If neither POSIX API nor Microsoft proprietary equivalent are available, this
  27. class is still available but works in degraded mode: the only supported locale
  28. is the C one and attempts to create wxXLocale object for any other locale will
  29. fail. You can use the preprocessor macro @c wxHAS_XLOCALE_SUPPORT to test if
  30. full xlocale API is available or only skeleton C locale support is present.
  31. Notice that wxXLocale is new in wxWidgets 2.9.0 and is not compiled in if
  32. @c wxUSE_XLOCALE was set to 0 during the library compilation.
  33. @library{wxbase}
  34. @category{cfg}
  35. @stdobjects
  36. @li ::wxNullXLocale
  37. @see wxLocale
  38. */
  39. class wxXLocale
  40. {
  41. public:
  42. /**
  43. Creates an uninitialized locale object, IsOk() method will return @false.
  44. */
  45. wxXLocale();
  46. /**
  47. Creates the locale object corresponding to the specified language.
  48. */
  49. wxXLocale(wxLanguage lang);
  50. /**
  51. Creates the locale object corresponding to the specified locale string.
  52. The locale string is system-dependent, use constructor taking wxLanguage
  53. for better portability.
  54. */
  55. wxXLocale(const char* loc);
  56. /**
  57. Returns the global object representing the "C" locale.
  58. For an even shorter access to this object a global @c wxCLocale variable
  59. (implemented as a macro) is provided and can be used instead of calling
  60. this method.
  61. */
  62. static wxXLocale& GetCLocale();
  63. /**
  64. Returns @true if this object is initialized, i.e.\ represents a valid locale
  65. or @false otherwise.
  66. */
  67. bool IsOk() const;
  68. /**
  69. Comparison operator.
  70. */
  71. bool operator==(const wxXLocale& loc) const;
  72. };
  73. /**
  74. An empty and invalid wxXLocale object.
  75. */
  76. wxXLocale wxNullXLocale;
  77. // ============================================================================
  78. // Global functions/macros
  79. // ============================================================================
  80. /** @addtogroup group_funcmacro_locale */
  81. //@{
  82. int wxIsalnum_l(wchar_t c, const wxXLocale& loc);
  83. int wxIsalpha_l(wchar_t c, const wxXLocale& loc);
  84. int wxIscntrl_l(wchar_t c, const wxXLocale& loc);
  85. int wxIsdigit_l(wchar_t c, const wxXLocale& loc);
  86. int wxIsgraph_l(wchar_t c, const wxXLocale& loc);
  87. int wxIslower_l(wchar_t c, const wxXLocale& loc);
  88. int wxIsprint_l(wchar_t c, const wxXLocale& loc);
  89. int wxIspunct_l(wchar_t c, const wxXLocale& loc);
  90. int wxIsspace_l(wchar_t c, const wxXLocale& loc);
  91. int wxIsupper_l(wchar_t c, const wxXLocale& loc);
  92. int wxIsxdigit_l(wchar_t c, const wxXLocale& loc);
  93. wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc);
  94. wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc);
  95. double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc);
  96. long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc);
  97. unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc);
  98. //@}