split wxchar.h into several smaller headers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
232
include/wx/chartype.h
Normal file
232
include/wx/chartype.h
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
/*
|
||||||
|
* Name: wx/chartype.h
|
||||||
|
* Purpose: Declarations of wxChar and related types
|
||||||
|
* Author: Joel Farley, Ove K<>ven
|
||||||
|
* Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
|
||||||
|
* Created: 1998/06/12
|
||||||
|
* RCS-ID: $Id$
|
||||||
|
* Copyright: (c) 1998-2006 wxWidgets dev team
|
||||||
|
* Licence: wxWindows licence
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
|
||||||
|
|
||||||
|
#ifndef _WX_WXCHARTYPE_H_
|
||||||
|
#define _WX_WXCHARTYPE_H_
|
||||||
|
|
||||||
|
/* defs.h indirectly includes this file, so don't include it here */
|
||||||
|
#include "wx/platform.h"
|
||||||
|
|
||||||
|
/* check whether we have wchar_t and which size it is if we do */
|
||||||
|
#if !defined(wxUSE_WCHAR_T)
|
||||||
|
#if defined(__UNIX__)
|
||||||
|
#if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
|
||||||
|
#define wxUSE_WCHAR_T 1
|
||||||
|
#else
|
||||||
|
#define wxUSE_WCHAR_T 0
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUWIN32__) && !defined(__MINGW32__)
|
||||||
|
#define wxUSE_WCHAR_T 0
|
||||||
|
#elif defined(__WATCOMC__)
|
||||||
|
#define wxUSE_WCHAR_T 0
|
||||||
|
#elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
|
||||||
|
#define wxUSE_WCHAR_T 0
|
||||||
|
#else
|
||||||
|
/* add additional compiler checks if this fails */
|
||||||
|
#define wxUSE_WCHAR_T 1
|
||||||
|
#endif
|
||||||
|
#endif /* !defined(wxUSE_WCHAR_T) */
|
||||||
|
|
||||||
|
/* Unicode support requires wchar_t */
|
||||||
|
#if wxUSE_UNICODE && !wxUSE_WCHAR_T
|
||||||
|
#error "wchar_t must be available in Unicode build"
|
||||||
|
#endif /* Unicode */
|
||||||
|
|
||||||
|
/*
|
||||||
|
non Unix compilers which do have wchar.h (but not tchar.h which is included
|
||||||
|
below and which includes wchar.h anyhow).
|
||||||
|
|
||||||
|
Actually MinGW has tchar.h, but it does not include wchar.h
|
||||||
|
*/
|
||||||
|
#if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
|
||||||
|
#ifndef HAVE_WCHAR_H
|
||||||
|
#define HAVE_WCHAR_H
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(__MWERKS__) && !defined(__MACH__)
|
||||||
|
#ifndef HAVE_WCSLEN
|
||||||
|
#define HAVE_WCSLEN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_WCHAR_T
|
||||||
|
#ifdef HAVE_WCHAR_H
|
||||||
|
/* the current (as of Nov 2002) version of cygwin has a bug in its */
|
||||||
|
/* wchar.h -- there is no extern "C" around the declarations in it */
|
||||||
|
/* and this results in linking errors later; also, at least on some */
|
||||||
|
/* Cygwin versions, wchar.h requires sys/types.h */
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
#include <sys/types.h>
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#endif /* Cygwin */
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#if defined(__CYGWIN__) && defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* Cygwin and C++ */
|
||||||
|
|
||||||
|
#elif defined(HAVE_WCSTR_H)
|
||||||
|
/* old compilers have relevant declarations here */
|
||||||
|
#include <wcstr.h>
|
||||||
|
#elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
|
||||||
|
/* include stdlib.h for wchar_t */
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif /* HAVE_WCHAR_H */
|
||||||
|
|
||||||
|
#ifdef HAVE_WIDEC_H
|
||||||
|
#include <widec.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__GNUC__) || defined(__DARWIN__)
|
||||||
|
#define wxWINT_T_IS_TYPEDEF
|
||||||
|
#endif
|
||||||
|
#endif /* wxUSE_WCHAR_T */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
|
||||||
|
/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and */
|
||||||
|
/* have the function mapping _tfoo() -> foo() or wfoo() */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* VC++ and BC++ starting with 5.2 have TCHAR support */
|
||||||
|
#ifdef __VISUALC__
|
||||||
|
#define wxHAVE_TCHAR_SUPPORT
|
||||||
|
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
|
||||||
|
#define wxHAVE_TCHAR_SUPPORT
|
||||||
|
#include <ctype.h>
|
||||||
|
#elif defined(__WATCOMC__)
|
||||||
|
#define wxHAVE_TCHAR_SUPPORT
|
||||||
|
#elif defined(__DMC__)
|
||||||
|
#define wxHAVE_TCHAR_SUPPORT
|
||||||
|
#elif defined(__WXPALMOS__)
|
||||||
|
#include <stddef.h>
|
||||||
|
#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
|
||||||
|
#define wxHAVE_TCHAR_SUPPORT
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
|
||||||
|
/* VZ: the old VisualAge definitions were completely wrong and had no */
|
||||||
|
/* chance at all to work in Unicode build anyhow so let's pretend */
|
||||||
|
/* that VisualAge does _not_ support TCHAR for the moment (as */
|
||||||
|
/* indicated by "0 &&" above) until someone really has time to delve */
|
||||||
|
/* into Unicode issues under OS/2 */
|
||||||
|
|
||||||
|
/* VisualAge 4.0+ supports TCHAR */
|
||||||
|
#define wxHAVE_TCHAR_SUPPORT
|
||||||
|
#endif /* compilers with (good) TCHAR support */
|
||||||
|
|
||||||
|
#ifdef wxHAVE_TCHAR_SUPPORT
|
||||||
|
/* get TCHAR definition if we've got it */
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
/* we surely do have wchar_t if we have TCHAR */
|
||||||
|
#ifndef wxUSE_WCHAR_T
|
||||||
|
#define wxUSE_WCHAR_T 1
|
||||||
|
#endif /* !defined(wxUSE_WCHAR_T) */
|
||||||
|
#endif /* wxHAVE_TCHAR_SUPPORT */
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
/* define wxChar type */
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* TODO: define wxCharInt to be equal to either int or wint_t? */
|
||||||
|
|
||||||
|
#if !wxUSE_UNICODE
|
||||||
|
typedef char wxChar;
|
||||||
|
typedef signed char wxSChar;
|
||||||
|
typedef unsigned char wxUChar;
|
||||||
|
#else /* Unicode */
|
||||||
|
/* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
|
||||||
|
/* signed/unsigned version of it which (a) makes sense to me (unlike */
|
||||||
|
/* char wchar_t is always unsigned) and (b) was how the previous */
|
||||||
|
/* definitions worked so keep it like this */
|
||||||
|
|
||||||
|
/* Sun's SunPro compiler supports the wchar_t type and wide character */
|
||||||
|
/* functions, but does not define __WCHAR_TYPE__. Define it here to */
|
||||||
|
/* allow unicode enabled builds. */
|
||||||
|
#if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
|
||||||
|
#define __WCHAR_TYPE__ wxchar_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
|
||||||
|
/* comment below */
|
||||||
|
#if !defined(__WCHAR_TYPE__) || \
|
||||||
|
(!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
|
||||||
|
/* standard case */
|
||||||
|
typedef wchar_t wxChar;
|
||||||
|
typedef wchar_t wxSChar;
|
||||||
|
typedef wchar_t wxUChar;
|
||||||
|
#else /* __WCHAR_TYPE__ and gcc < 2.96 */
|
||||||
|
/* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. */
|
||||||
|
/* However, this doesn't work with new GCC 3.x compilers because */
|
||||||
|
/* wchar_t is C++'s builtin type in the new standard. OTOH, old */
|
||||||
|
/* compilers (GCC 2.x) won't accept new definition of */
|
||||||
|
/* wx{S,U}CharType, so we have to define wxChar */
|
||||||
|
/* conditionally depending on detected compiler & compiler */
|
||||||
|
/* version. */
|
||||||
|
|
||||||
|
/* with old definition of wxChar. */
|
||||||
|
#define wchar_t __WCHAR_TYPE__
|
||||||
|
typedef __WCHAR_TYPE__ wxChar;
|
||||||
|
typedef __WCHAR_TYPE__ wxSChar;
|
||||||
|
typedef __WCHAR_TYPE__ wxUChar;
|
||||||
|
#endif /* __WCHAR_TYPE__ */
|
||||||
|
#endif /* ASCII/Unicode */
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
/* define _T() and related macros */
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* BSD systems define _T() to be something different in ctype.h, override it */
|
||||||
|
#if defined(__FreeBSD__) || defined(__DARWIN__)
|
||||||
|
#include <ctype.h>
|
||||||
|
#undef _T
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* could already be defined by tchar.h (it's quasi standard) */
|
||||||
|
#ifndef _T
|
||||||
|
#if !wxUSE_UNICODE
|
||||||
|
#define _T(x) x
|
||||||
|
#else /* Unicode */
|
||||||
|
/* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
|
||||||
|
#define _T(x) wxCONCAT_HELPER(L, x)
|
||||||
|
#endif /* ASCII/Unicode */
|
||||||
|
#endif /* !defined(_T) */
|
||||||
|
|
||||||
|
/* although global macros with such names are normally bad, we want to have */
|
||||||
|
/* another name for _T() which should be used to avoid confusion between */
|
||||||
|
/* _T() and _() in wxWidgets sources */
|
||||||
|
#define wxT(x) _T(x)
|
||||||
|
|
||||||
|
/* a helper macro allowing to make another macro Unicode-friendly, see below */
|
||||||
|
#define wxAPPLY_T(x) _T(x)
|
||||||
|
|
||||||
|
/* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
|
||||||
|
#ifndef __TFILE__
|
||||||
|
#define __TFILE__ wxAPPLY_T(__FILE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __TDATE__
|
||||||
|
#define __TDATE__ wxAPPLY_T(__DATE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __TTIME__
|
||||||
|
#define __TTIME__ wxAPPLY_T(__TIME__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _WX_WXCHARTYPE_H_ */
|
||||||
|
|
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
|
|
||||||
class WXDLLEXPORT wxDataFormat;
|
class WXDLLEXPORT wxDataFormat;
|
||||||
class WXDLLEXPORT wxDataObject;
|
class WXDLLEXPORT wxDataObject;
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <limits.h> /* for CHAR_BIT used below */
|
#include <limits.h> /* for CHAR_BIT used below */
|
||||||
|
|
||||||
#include "wx/wxchar.h" /* for __TFILE__ and wxChar */
|
#include "wx/chartype.h" /* for __TFILE__ and wxChar */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
/* Defines controlling the debugging macros */
|
/* Defines controlling the debugging macros */
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#define _WX_INIT_H_
|
#define _WX_INIT_H_
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxEntry helper functions which allow to have more fine grained control
|
// wxEntry helper functions which allow to have more fine grained control
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
#include "wx/strvararg.h"
|
#include "wx/strvararg.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#ifndef _WX_OLEUUID_H
|
#ifndef _WX_OLEUUID_H
|
||||||
#define _WX_OLEUUID_H
|
#define _WX_OLEUUID_H
|
||||||
|
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// UUID (Universally Unique IDentifier) definition
|
// UUID (Universally Unique IDentifier) definition
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
|
|
||||||
#if !wxUSE_UNICODE_MSLU
|
#if !wxUSE_UNICODE_MSLU
|
||||||
inline bool wxUsingUnicowsDll() { return false; }
|
inline bool wxUsingUnicowsDll() { return false; }
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#define _WX_STOCKITEM_H_
|
#define _WX_STOCKITEM_H_
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/accel.h"
|
#include "wx/accel.h"
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#define _WX_STRCONV_H_
|
#define _WX_STRCONV_H_
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
#include "wx/buffer.h"
|
#include "wx/buffer.h"
|
||||||
|
|
||||||
#ifdef __DIGITALMARS__
|
#ifdef __DIGITALMARS__
|
||||||
|
@@ -51,7 +51,8 @@
|
|||||||
#include <StringMgr.h>
|
#include <StringMgr.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/wxchar.h" // for wxChar
|
#include "wx/wxchar.h" // for wxChar, wxStrlen() etc.
|
||||||
|
#include "wx/unichar.h"
|
||||||
#include "wx/strvararg.h"
|
#include "wx/strvararg.h"
|
||||||
#include "wx/buffer.h" // for wxCharBuffer
|
#include "wx/buffer.h" // for wxCharBuffer
|
||||||
#include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes
|
#include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes
|
||||||
@@ -98,7 +99,7 @@ extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxEmptyString;
|
|||||||
// strlen() and portable strcasecmp()
|
// strlen() and portable strcasecmp()
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Use wxXXX() functions from wxchar.h instead! These functions are for
|
// Use wxXXX() functions from wxcrt.h instead! These functions are for
|
||||||
// backwards compatibility only.
|
// backwards compatibility only.
|
||||||
|
|
||||||
// checks whether the passed in pointer is NULL and if the string is empty
|
// checks whether the passed in pointer is NULL and if the string is empty
|
||||||
|
@@ -16,13 +16,7 @@
|
|||||||
#error "OpenWatcom version >= 1.4 is required to compile this code"
|
#error "OpenWatcom version >= 1.4 is required to compile this code"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// include wchar_t definition if needed:
|
#include "wx/chartype.h"
|
||||||
#if defined(__WATCOMC__)
|
|
||||||
#include <inttypes.h>
|
|
||||||
#elif defined(__VISUALC__)
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxCStrData;
|
class WXDLLIMPEXP_BASE wxCStrData;
|
||||||
class WXDLLIMPEXP_BASE wxString;
|
class WXDLLIMPEXP_BASE wxString;
|
||||||
@@ -95,7 +89,7 @@ struct wxArgNormalizer
|
|||||||
|
|
||||||
// special cases for converting strings:
|
// special cases for converting strings:
|
||||||
|
|
||||||
// FIXME-UTF8: move this to wxchartype.h!
|
// FIXME-UTF8: move this to chartype.h!
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
/* for now, all Unicode builds are wchar_t* based: */
|
/* for now, all Unicode builds are wchar_t* based: */
|
||||||
#define wxUSE_UNICODE_WCHAR 1
|
#define wxUSE_UNICODE_WCHAR 1
|
||||||
@@ -103,7 +97,7 @@ struct wxArgNormalizer
|
|||||||
#define wxUSE_UNICODE_WCHAR 0
|
#define wxUSE_UNICODE_WCHAR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME-UTF8: include wx/wxchartype.h and use wxChar after headers split
|
// FIXME-UTF8: include wx/chartype.h and use wxChar after headers split
|
||||||
// FIXME-UTF8: this will be char* in UTF-8 build and wchar_t* on Windows
|
// FIXME-UTF8: this will be char* in UTF-8 build and wchar_t* on Windows
|
||||||
#if wxUSE_UNICODE_WCHAR
|
#if wxUSE_UNICODE_WCHAR
|
||||||
typedef wchar_t wxArgNativeCharType;
|
typedef wchar_t wxArgNativeCharType;
|
||||||
|
354
include/wx/unichar.h
Normal file
354
include/wx/unichar.h
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/unichar.h
|
||||||
|
// Purpose: wxUniChar and wxUniCharRef classes
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Created: 2007-03-19
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2007 REA Elektronik GmbH
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_UNICHAR_H_
|
||||||
|
#define _WX_UNICHAR_H_
|
||||||
|
|
||||||
|
#include "wx/chartype.h"
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_BASE wxUniCharRef;
|
||||||
|
|
||||||
|
// This class represents single Unicode character. It can be converted to
|
||||||
|
// and from char or wchar_t and implements commonly used character operations.
|
||||||
|
class WXDLLIMPEXP_BASE wxUniChar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// NB: this is not wchar_t on purpose, it needs to represent the entire
|
||||||
|
// Unicode code points range and wchar_t may be too small for that
|
||||||
|
// (e.g. on Win32 where wchar_t* is encoded in UTF-16)
|
||||||
|
typedef unsigned int unicode_type;
|
||||||
|
|
||||||
|
wxUniChar() : m_value(0) {}
|
||||||
|
|
||||||
|
// Create the character from 8bit character value encoded in the current
|
||||||
|
// locale's charset.
|
||||||
|
wxUniChar(char c) { m_value = From8bit(c); }
|
||||||
|
|
||||||
|
// Create the character from a wchar_t character value.
|
||||||
|
wxUniChar(wchar_t c) { m_value = c; }
|
||||||
|
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
// Create the character from a wint_t character value.
|
||||||
|
wxUniChar(wint_t c) { m_value = c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxUniChar(int c) { m_value = c; }
|
||||||
|
|
||||||
|
wxUniChar(const wxUniCharRef& c);
|
||||||
|
|
||||||
|
// Returns Unicode code point value of the character
|
||||||
|
unicode_type GetValue() const { return m_value; }
|
||||||
|
|
||||||
|
// Casts to char and wchar_t types:
|
||||||
|
operator char() const { return To8bit(m_value); }
|
||||||
|
operator wchar_t() const { return m_value; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
operator wint_t() const { return m_value; }
|
||||||
|
#endif
|
||||||
|
operator int() const { return m_value; }
|
||||||
|
|
||||||
|
// We need this operator for the "*p" part of expressions like "for (
|
||||||
|
// const_iterator p = begin() + nStart; *p; ++p )". In this case,
|
||||||
|
// compilation would fail without it because the conversion to bool would
|
||||||
|
// be ambiguous (there are all these int types conversions...). (And adding
|
||||||
|
// operator unspecified_bool_type() would only makes the ambiguity worse.)
|
||||||
|
operator bool() const { return m_value != 0; }
|
||||||
|
bool operator!() const { return !((bool)*this); }
|
||||||
|
#if (defined(__VISUALC__) && __VISUALC__ < 1400) || \
|
||||||
|
defined(__DIGITALMARS__) || defined(__BORLANDC__)
|
||||||
|
// We need this for VC++ < 8 or DigitalMars and expressions like
|
||||||
|
// "str[0] && *p":
|
||||||
|
bool operator&&(bool v) const { return (bool)*this && v; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Assignment operators:
|
||||||
|
wxUniChar& operator=(const wxUniChar& c) { m_value = c.m_value; return *this; }
|
||||||
|
wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; }
|
||||||
|
wxUniChar& operator=(wchar_t c) { m_value = c; return *this; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
wxUniChar& operator=(wint_t c) { m_value = c; return *this; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Comparision operators:
|
||||||
|
bool operator==(const wxUniChar& c) const { return m_value == c.m_value; }
|
||||||
|
bool operator==(char c) const { return m_value == From8bit(c); }
|
||||||
|
bool operator==(wchar_t c) const { return m_value == (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator==(wint_t c) const { return m_value == (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator!=(const wxUniChar& c) const { return m_value != c.m_value; }
|
||||||
|
bool operator!=(char c) const { return m_value != From8bit(c); }
|
||||||
|
bool operator!=(wchar_t c) const { return m_value != (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator!=(wint_t c) const { return m_value != (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator>(const wxUniChar& c) const { return m_value > c.m_value; }
|
||||||
|
bool operator>(char c) const { return m_value > (unicode_type)c; }
|
||||||
|
bool operator>(wchar_t c) const { return m_value > (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator>(wint_t c) const { return m_value > (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator<(const wxUniChar& c) const { return m_value < c.m_value; }
|
||||||
|
bool operator<(char c) const { return m_value < From8bit(c); }
|
||||||
|
bool operator<(wchar_t c) const { return m_value < (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator<(wint_t c) const { return m_value < (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator>=(const wxUniChar& c) const { return m_value >= c.m_value; }
|
||||||
|
bool operator>=(char c) const { return m_value >= From8bit(c); }
|
||||||
|
bool operator>=(wchar_t c) const { return m_value >= (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator>=(wint_t c) const { return m_value >= (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator<=(const wxUniChar& c) const { return m_value <= c.m_value; }
|
||||||
|
bool operator<=(char c) const { return m_value <= From8bit(c); }
|
||||||
|
bool operator<=(wchar_t c) const { return m_value <= (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator<=(wint_t c) const { return m_value <= (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int operator-(const wxUniChar& c) const { return m_value - c.m_value; }
|
||||||
|
int operator-(char c) const { return m_value - From8bit(c); }
|
||||||
|
int operator-(wchar_t c) const { return m_value - (unicode_type)c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
int operator-(wint_t c) const { return m_value - (unicode_type)c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
static unicode_type From8bit(char c);
|
||||||
|
static char To8bit(unicode_type c);
|
||||||
|
|
||||||
|
private:
|
||||||
|
unicode_type m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Writeable reference to a character in wxString.
|
||||||
|
//
|
||||||
|
// This class can be used in the same way wxChar is used, except that changing
|
||||||
|
// its value updates the underlying string object.
|
||||||
|
class WXDLLIMPEXP_BASE wxUniCharRef
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// create the reference
|
||||||
|
// FIXME-UTF8: the interface will need changes for UTF-8 build
|
||||||
|
wxUniCharRef(wxChar *pos) : m_pos(pos) {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
// NB: we have to make this public, because we don't have wxString
|
||||||
|
// declaration available here and so can't declare wxString::iterator
|
||||||
|
// as friend; so at least don't use a ctor but a static function
|
||||||
|
// that must be used explicitly (this is more than using 'explicit'
|
||||||
|
// keyword on ctor!):
|
||||||
|
//
|
||||||
|
// FIXME-UTF8: the interface will need changes for UTF-8 build
|
||||||
|
static wxUniCharRef CreateForString(wxChar *pos)
|
||||||
|
{ return wxUniCharRef(pos); }
|
||||||
|
|
||||||
|
wxUniChar::unicode_type GetValue() const { return UniChar().GetValue(); }
|
||||||
|
|
||||||
|
// Assignment operators:
|
||||||
|
wxUniCharRef& operator=(const wxUniCharRef& c)
|
||||||
|
{
|
||||||
|
*m_pos = *c.m_pos;
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxUniCharRef& operator=(const wxUniChar& c)
|
||||||
|
{
|
||||||
|
*m_pos = c;
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); }
|
||||||
|
wxUniCharRef& operator=(wchar_t c) { return *this = wxUniChar(c); }
|
||||||
|
|
||||||
|
// Casts to wxUniChar type:
|
||||||
|
operator char() const { return UniChar(); }
|
||||||
|
operator wchar_t() const { return UniChar(); }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
operator wint_t() const { return UniChar(); }
|
||||||
|
#endif
|
||||||
|
operator int() const { return UniChar(); }
|
||||||
|
|
||||||
|
// see wxUniChar::operator bool etc. for explanation
|
||||||
|
operator bool() const { return (bool)UniChar(); }
|
||||||
|
bool operator!() const { return !UniChar(); }
|
||||||
|
#if (defined(__VISUALC__) && __VISUALC__ < 1400) || \
|
||||||
|
defined(__DIGITALMARS__) || defined(__BORLANDC__)
|
||||||
|
bool operator&&(bool v) const { return UniChar() && v; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Comparision operators:
|
||||||
|
bool operator==(const wxUniCharRef& c) const { return m_pos == c.m_pos; }
|
||||||
|
bool operator==(const wxUniChar& c) const { return UniChar() == c; }
|
||||||
|
bool operator==(char c) const { return UniChar() == c; }
|
||||||
|
bool operator==(wchar_t c) const { return UniChar() == c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator==(wint_t c) const { return UniChar() == c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator!=(const wxUniCharRef& c) const { return m_pos != c.m_pos; }
|
||||||
|
bool operator!=(const wxUniChar& c) const { return UniChar() != c; }
|
||||||
|
bool operator!=(char c) const { return UniChar() != c; }
|
||||||
|
bool operator!=(wchar_t c) const { return UniChar() != c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator!=(wint_t c) const { return UniChar() != c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator>(const wxUniCharRef& c) const { return UniChar() > c.UniChar(); }
|
||||||
|
bool operator>(const wxUniChar& c) const { return UniChar() > c; }
|
||||||
|
bool operator>(char c) const { return UniChar() > c; }
|
||||||
|
bool operator>(wchar_t c) const { return UniChar() > c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator>(wint_t c) const { return UniChar() > c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator<(const wxUniCharRef& c) const { return UniChar() < c.UniChar(); }
|
||||||
|
bool operator<(const wxUniChar& c) const { return UniChar() < c; }
|
||||||
|
bool operator<(char c) const { return UniChar() < c; }
|
||||||
|
bool operator<(wchar_t c) const { return UniChar() < c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator<(wint_t c) const { return UniChar() < c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator>=(const wxUniCharRef& c) const { return UniChar() >= c.UniChar(); }
|
||||||
|
bool operator>=(const wxUniChar& c) const { return UniChar() >= c; }
|
||||||
|
bool operator>=(char c) const { return UniChar() >= c; }
|
||||||
|
bool operator>=(wchar_t c) const { return UniChar() >= c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator>=(wint_t c) const { return UniChar() >= c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool operator<=(const wxUniCharRef& c) const { return UniChar() <= c.UniChar(); }
|
||||||
|
bool operator<=(const wxUniChar& c) const { return UniChar() <= c; }
|
||||||
|
bool operator<=(char c) const { return UniChar() <= c; }
|
||||||
|
bool operator<=(wchar_t c) const { return UniChar() <= c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
bool operator<=(wint_t c) const { return UniChar() <= c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// for expressions like c-'A':
|
||||||
|
int operator-(const wxUniCharRef& c) const { return UniChar() - c.UniChar(); }
|
||||||
|
int operator-(const wxUniChar& c) const { return UniChar() - c; }
|
||||||
|
int operator-(char c) const { return UniChar() - c; }
|
||||||
|
int operator-(wchar_t c) const { return UniChar() - c; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
int operator-(wint_t c) const { return UniChar() - c; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxUniChar UniChar() const { return *m_pos; }
|
||||||
|
friend class WXDLLIMPEXP_BASE wxUniChar;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// pointer to the character in string
|
||||||
|
wxChar *m_pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline wxUniChar::wxUniChar(const wxUniCharRef& c)
|
||||||
|
{
|
||||||
|
m_value = c.UniChar().m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comparision operators for the case when wxUniChar(Ref) is the second operand:
|
||||||
|
inline bool operator==(char c1, const wxUniChar& c2) { return c2 == c1; }
|
||||||
|
inline bool operator==(wchar_t c1, const wxUniChar& c2) { return c2 == c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator==(wint_t c1, const wxUniChar& c2) { return c2 == c1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline bool operator!=(char c1, const wxUniChar& c2) { return c2 != c1; }
|
||||||
|
inline bool operator!=(wchar_t c1, const wxUniChar& c2) { return c2 != c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator!=(wint_t c1, const wxUniChar& c2) { return c2 != c1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline bool operator>(char c1, const wxUniChar& c2) { return c2 < c1; }
|
||||||
|
inline bool operator>(wchar_t c1, const wxUniChar& c2) { return c2 < c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator>(wint_t c1, const wxUniChar& c2) { return c2 < c1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline bool operator<(char c1, const wxUniChar& c2) { return c2 > c1; }
|
||||||
|
inline bool operator<(wchar_t c1, const wxUniChar& c2) { return c2 > c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator<(wint_t c1, const wxUniChar& c2) { return c2 > c1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline bool operator>=(char c1, const wxUniChar& c2) { return c2 <= c1; }
|
||||||
|
inline bool operator>=(wchar_t c1, const wxUniChar& c2) { return c2 <= c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator>=(wint_t c1, const wxUniChar& c2) { return c2 <= c1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline bool operator<=(char c1, const wxUniChar& c2) { return c2 >= c1; }
|
||||||
|
inline bool operator<=(wchar_t c1, const wxUniChar& c2) { return c2 >= c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator<=(wint_t c1, const wxUniChar& c2) { return c2 >= c1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator==(char c1, const wxUniCharRef& c2) { return c2 == c1; }
|
||||||
|
inline bool operator==(wchar_t c1, const wxUniCharRef& c2) { return c2 == c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator==(wint_t c1, const wxUniCharRef& c2) { return c2 == c1; }
|
||||||
|
#endif
|
||||||
|
inline bool operator==(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 == c1; }
|
||||||
|
|
||||||
|
inline bool operator!=(char c1, const wxUniCharRef& c2) { return c2 != c1; }
|
||||||
|
inline bool operator!=(wchar_t c1, const wxUniCharRef& c2) { return c2 != c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator!=(wint_t c1, const wxUniCharRef& c2) { return c2 != c1; }
|
||||||
|
#endif
|
||||||
|
inline bool operator!=(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 != c1; }
|
||||||
|
|
||||||
|
inline bool operator>(char c1, const wxUniCharRef& c2) { return c2 < c1; }
|
||||||
|
inline bool operator>(wchar_t c1, const wxUniCharRef& c2) { return c2 < c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator>(wint_t c1, const wxUniCharRef& c2) { return c2 < c1; }
|
||||||
|
#endif
|
||||||
|
inline bool operator>(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 < c1; }
|
||||||
|
|
||||||
|
inline bool operator<(char c1, const wxUniCharRef& c2) { return c2 > c1; }
|
||||||
|
inline bool operator<(wchar_t c1, const wxUniCharRef& c2) { return c2 > c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator<(wint_t c1, const wxUniCharRef& c2) { return c2 > c1; }
|
||||||
|
#endif
|
||||||
|
inline bool operator<(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 > c1; }
|
||||||
|
|
||||||
|
inline bool operator>=(char c1, const wxUniCharRef& c2) { return c2 <= c1; }
|
||||||
|
inline bool operator>=(wchar_t c1, const wxUniCharRef& c2) { return c2 <= c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator>=(wint_t c1, const wxUniCharRef& c2) { return c2 <= c1; }
|
||||||
|
#endif
|
||||||
|
inline bool operator>=(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 <= c1; }
|
||||||
|
|
||||||
|
inline bool operator<=(char c1, const wxUniCharRef& c2) { return c2 >= c1; }
|
||||||
|
inline bool operator<=(wchar_t c1, const wxUniCharRef& c2) { return c2 >= c1; }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline bool operator<=(wint_t c1, const wxUniCharRef& c2) { return c2 >= c1; }
|
||||||
|
#endif
|
||||||
|
inline bool operator<=(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 >= c1; }
|
||||||
|
|
||||||
|
// for expressions like c-'A':
|
||||||
|
inline int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
inline int operator-(wchar_t c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
#ifndef wxWINT_T_IS_TYPEDEF
|
||||||
|
inline int operator-(wint_t c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
#endif
|
||||||
|
inline int operator-(const wxUniChar& c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
|
||||||
|
#endif /* _WX_UNICHAR_H_ */
|
@@ -30,6 +30,7 @@
|
|||||||
#include "wx/math.h"
|
#include "wx/math.h"
|
||||||
#include "wx/stopwatch.h"
|
#include "wx/stopwatch.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
|
#include "wx/wxcrt.h"
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
|
||||||
|
1716
include/wx/wxchar.h
1716
include/wx/wxchar.h
File diff suppressed because it is too large
Load Diff
1174
include/wx/wxcrt.h
Normal file
1174
include/wx/wxcrt.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -36,9 +36,9 @@
|
|||||||
|
|
||||||
#ifdef WX_PRECOMP
|
#ifdef WX_PRECOMP
|
||||||
|
|
||||||
// include "wx/wxchar.h" first to ensure that UNICODE macro is correctly set
|
// include "wx/chartype.h" first to ensure that UNICODE macro is correctly set
|
||||||
// _before_ including <windows.h>
|
// _before_ including <windows.h>
|
||||||
#include "wx/wxchar.h"
|
#include "wx/chartype.h"
|
||||||
|
|
||||||
// include standard Windows headers
|
// include standard Windows headers
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
|
Reference in New Issue
Block a user