X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6e4ae332ac7d85be3592640ffef56a60924cc1c9..cbeda384e51acb82e13994cb67ac1714669cae10:/include/wx/xlocale.h diff --git a/include/wx/xlocale.h b/include/wx/xlocale.h index 58069d63b4..bf8f8daf07 100644 --- a/include/wx/xlocale.h +++ b/include/wx/xlocale.h @@ -18,8 +18,8 @@ using decimal point &c. TODO: Currently only the character classification and transformation - functions are implemented, we also need at least - - numbers: atof_l(), strtod_l() &c + functions and number <-> string functions, are implemented, + we also need at least - formatted IO: scanf_l(), printf_l() &c - time: strftime_l(), strptime_l() */ @@ -37,13 +37,14 @@ // The platform-specific locale type // If wxXLocale_t is not defined, then only "C" locale support is provided #ifdef wxHAS_XLOCALE_SUPPORT - #if wxCHECK_VISUALC_VERSION(8) + #if wxCHECK_VISUALC_VERSION(8) && !defined(__WXWINCE__) typedef _locale_t wxXLocale_t; #define wxXLOCALE_IDENT(name) _ ## name #elif defined(HAVE_LOCALE_T) #include #include #include + #include #if wxUSE_UNICODE #include @@ -96,6 +97,9 @@ public: // Get the type wxXLocale_t Get() const { return m_locale; } + bool operator== (const wxXLocale& loc) const + { return m_locale == loc.m_locale; } + private: // Special ctor for the "C" locale, it's only used internally as the user // code is supposed to use GetCLocale() @@ -116,7 +120,7 @@ private: // doesn't give us any means to copy a _locale_t object so we reduce the // functionality to least common denominator here -- it shouldn't be a // problem as copying the locale objects shouldn't be often needed - DECLARE_NO_COPY_CLASS(wxXLocale) + wxDECLARE_NO_COPY_CLASS(wxXLocale); }; #else // !wxHAS_XLOCALE_SUPPORT @@ -169,7 +173,7 @@ private: // although it's not a problem to copy the objects of this class, we use // this macro in this implementation for consistency with the xlocale-based // one which can't be copied when using MSVC locale API - DECLARE_NO_COPY_CLASS(wxXLocale) + wxDECLARE_NO_COPY_CLASS(wxXLocale); }; #endif // wxHAS_XLOCALE_SUPPORT/!wxHAS_XLOCALE_SUPPORT @@ -177,7 +181,7 @@ private: // A shorter synonym for the most commonly used locale object #define wxCLocale (wxXLocale::GetCLocale()) - +extern WXDLLIMPEXP_DATA_BASE(wxXLocale) wxNullXLocale; // Wrappers for various functions: #ifdef wxHAS_XLOCALE_SUPPORT @@ -198,33 +202,52 @@ private: #define wxCRT_Toupper_lA wxXLOCALE_IDENT(toupper_l) inline int wxIsalnum_l(char c, const wxXLocale& loc) - { return wxCRT_Isalnum_lA(c, loc.Get()); } + { return wxCRT_Isalnum_lA(static_cast(c), loc.Get()); } inline int wxIsalpha_l(char c, const wxXLocale& loc) - { return wxCRT_Isalpha_lA(c, loc.Get()); } + { return wxCRT_Isalpha_lA(static_cast(c), loc.Get()); } inline int wxIscntrl_l(char c, const wxXLocale& loc) - { return wxCRT_Iscntrl_lA(c, loc.Get()); } + { return wxCRT_Iscntrl_lA(static_cast(c), loc.Get()); } inline int wxIsdigit_l(char c, const wxXLocale& loc) - { return wxCRT_Isdigit_lA(c, loc.Get()); } + { return wxCRT_Isdigit_lA(static_cast(c), loc.Get()); } inline int wxIsgraph_l(char c, const wxXLocale& loc) - { return wxCRT_Isgraph_lA(c, loc.Get()); } + { return wxCRT_Isgraph_lA(static_cast(c), loc.Get()); } inline int wxIslower_l(char c, const wxXLocale& loc) - { return wxCRT_Islower_lA(c, loc.Get()); } + { return wxCRT_Islower_lA(static_cast(c), loc.Get()); } inline int wxIsprint_l(char c, const wxXLocale& loc) - { return wxCRT_Isprint_lA(c, loc.Get()); } + { return wxCRT_Isprint_lA(static_cast(c), loc.Get()); } inline int wxIspunct_l(char c, const wxXLocale& loc) - { return wxCRT_Ispunct_lA(c, loc.Get()); } + { return wxCRT_Ispunct_lA(static_cast(c), loc.Get()); } inline int wxIsspace_l(char c, const wxXLocale& loc) - { return wxCRT_Isspace_lA(c, loc.Get()); } + { return wxCRT_Isspace_lA(static_cast(c), loc.Get()); } inline int wxIsupper_l(char c, const wxXLocale& loc) - { return wxCRT_Isupper_lA(c, loc.Get()); } + { return wxCRT_Isupper_lA(static_cast(c), loc.Get()); } inline int wxIsxdigit_l(char c, const wxXLocale& loc) - { return wxCRT_Isxdigit_lA(c, loc.Get()); } - inline char wxTolower_l(char c, const wxXLocale& loc) - { return wxCRT_Tolower_lA(c, loc.Get()); } - inline char wxToupper_l(char c, const wxXLocale& loc) - { return wxCRT_Toupper_lA(c, loc.Get()); } + { return wxCRT_Isxdigit_lA(static_cast(c), loc.Get()); } + inline int wxTolower_l(char c, const wxXLocale& loc) + { return wxCRT_Tolower_lA(static_cast(c), loc.Get()); } + inline int wxToupper_l(char c, const wxXLocale& loc) + { return wxCRT_Toupper_lA(static_cast(c), loc.Get()); } + + + // stdlib functions for numeric <-> string conversion + // NOTE: GNU libc does not have ato[fil]_l functions; + // MSVC++8 does not have _strto[u]ll_l functions; + // thus we take the minimal set of functions provided in both environments: + + #define wxCRT_Strtod_lA wxXLOCALE_IDENT(strtod_l) + #define wxCRT_Strtol_lA wxXLOCALE_IDENT(strtol_l) + #define wxCRT_Strtoul_lA wxXLOCALE_IDENT(strtoul_l) + + inline double wxStrtod_lA(const char *c, char **endptr, const wxXLocale& loc) + { return wxCRT_Strtod_lA(c, endptr, loc.Get()); } + inline long wxStrtol_lA(const char *c, char **endptr, int base, const wxXLocale& loc) + { return wxCRT_Strtol_lA(c, endptr, base, loc.Get()); } + inline unsigned long wxStrtoul_lA(const char *c, char **endptr, int base, const wxXLocale& loc) + { return wxCRT_Strtoul_lA(c, endptr, base, loc.Get()); } #if wxUSE_UNICODE + + // ctype functions #define wxCRT_Isalnum_lW wxXLOCALE_IDENT(iswalnum_l) #define wxCRT_Isalpha_lW wxXLOCALE_IDENT(iswalpha_l) #define wxCRT_Iscntrl_lW wxXLOCALE_IDENT(iswcntrl_l) @@ -266,9 +289,22 @@ private: inline wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Toupper_lW(c, loc.Get()); } + + // stdlib functions for numeric <-> string conversion + // (see notes above about missing functions) + #define wxCRT_Strtod_lW wxXLOCALE_IDENT(wcstod_l) + #define wxCRT_Strtol_lW wxXLOCALE_IDENT(wcstol_l) + #define wxCRT_Strtoul_lW wxXLOCALE_IDENT(wcstoul_l) + + inline double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc) + { return wxCRT_Strtod_lW(c, endptr, loc.Get()); } + inline long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) + { return wxCRT_Strtol_lW(c, endptr, base, loc.Get()); } + inline unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) + { return wxCRT_Strtoul_lW(c, endptr, base, loc.Get()); } + #endif // wxUSE_UNICDE (ctype functions) #else // !wxHAS_XLOCALE_SUPPORT - // ctype functions int WXDLLIMPEXP_BASE wxIsalnum_l(const wxUniChar& c, const wxXLocale& loc); int WXDLLIMPEXP_BASE wxIsalpha_l(const wxUniChar& c, const wxXLocale& loc); @@ -281,12 +317,19 @@ private: int WXDLLIMPEXP_BASE wxIsspace_l(const wxUniChar& c, const wxXLocale& loc); int WXDLLIMPEXP_BASE wxIsupper_l(const wxUniChar& c, const wxXLocale& loc); int WXDLLIMPEXP_BASE wxIsxdigit_l(const wxUniChar& c, const wxXLocale& loc); - wxUniChar WXDLLIMPEXP_BASE wxTolower_l(const wxUniChar& c, const wxXLocale& loc); - wxUniChar WXDLLIMPEXP_BASE wxToupper_l(const wxUniChar& c, const wxXLocale& loc); + int WXDLLIMPEXP_BASE wxTolower_l(const wxUniChar& c, const wxXLocale& loc); + int WXDLLIMPEXP_BASE wxToupper_l(const wxUniChar& c, const wxXLocale& loc); + // stdlib functions + double WXDLLIMPEXP_BASE wxStrtod_l(const wchar_t* str, wchar_t **endptr, const wxXLocale& loc); + double WXDLLIMPEXP_BASE wxStrtod_l(const char* str, char **endptr, const wxXLocale& loc); + long WXDLLIMPEXP_BASE wxStrtol_l(const wchar_t* str, wchar_t **endptr, int base, const wxXLocale& loc); + long WXDLLIMPEXP_BASE wxStrtol_l(const char* str, char **endptr, int base, const wxXLocale& loc); + unsigned long WXDLLIMPEXP_BASE wxStrtoul_l(const wchar_t* str, wchar_t **endptr, int base, const wxXLocale& loc); + unsigned long WXDLLIMPEXP_BASE wxStrtoul_l(const char* str, char **endptr, int base, const wxXLocale& loc); #endif // wxHAS_XLOCALE_SUPPORT/!wxHAS_XLOCALE_SUPPORT - + #endif // wxUSE_XLOCALE #endif // _WX_XLOCALE_H_