2008-08-10 20:28:20 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// Name: wx/ustring.h
|
|
|
|
// Purpose: 32-bit string (UCS-4)
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Copyright: (c) Robert Roebling
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
#ifndef _WX_USTRING_H_
|
|
|
|
#define _WX_USTRING_H_
|
2008-07-29 11:01:16 +00:00
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
2008-07-31 12:35:46 +00:00
|
|
|
#include <string>
|
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
typedef wxWCharBuffer wxU16CharBuffer;
|
2009-03-27 15:33:55 +00:00
|
|
|
typedef wxScopedWCharBuffer wxScopedU16CharBuffer;
|
2008-07-29 11:01:16 +00:00
|
|
|
#else
|
2008-08-10 20:28:20 +00:00
|
|
|
typedef wxCharTypeBuffer<wxChar16> wxU16CharBuffer;
|
2009-03-27 15:33:55 +00:00
|
|
|
typedef wxScopedCharTypeBuffer<wxChar16> wxScopedU16CharBuffer;
|
2008-07-29 11:01:16 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-10 20:28:20 +00:00
|
|
|
#if SIZEOF_WCHAR_T == 4
|
2008-07-29 11:01:16 +00:00
|
|
|
typedef wxWCharBuffer wxU32CharBuffer;
|
2009-03-27 15:33:55 +00:00
|
|
|
typedef wxScopedWCharBuffer wxScopedU32CharBuffer;
|
2008-08-10 20:28:20 +00:00
|
|
|
#else
|
|
|
|
typedef wxCharTypeBuffer<wxChar32> wxU32CharBuffer;
|
2009-03-27 15:33:55 +00:00
|
|
|
typedef wxScopedCharTypeBuffer<wxChar32> wxScopedU32CharBuffer;
|
2008-07-29 11:01:16 +00:00
|
|
|
#endif
|
|
|
|
|
2009-06-07 12:27:07 +00:00
|
|
|
#ifdef __VISUALC__
|
|
|
|
// "non dll-interface class 'std::basic_string<wxChar32>' used as base
|
|
|
|
// interface for dll-interface class 'wxString'" -- this is OK in our case
|
|
|
|
// (and warning is unavoidable anyhow)
|
2009-06-12 03:37:47 +00:00
|
|
|
#pragma warning(push)
|
2009-06-07 12:27:07 +00:00
|
|
|
#pragma warning(disable:4275)
|
|
|
|
#endif
|
2008-08-10 20:28:20 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxUString: public std::basic_string<wxChar32>
|
|
|
|
{
|
2008-08-25 00:36:00 +00:00
|
|
|
public:
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString() { }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString( const wxChar32 *str ) { assign(str); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString( const wxScopedU32CharBuffer &buf ) { assign(buf); }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString( const char *str ) { assign(str); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString( const wxScopedCharBuffer &buf ) { assign(buf); }
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString( const char *str, const wxMBConv &conv ) { assign(str,conv); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString( const wxScopedCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); }
|
2008-07-29 11:01:16 +00:00
|
|
|
|
|
|
|
wxUString( const wxChar16 *str ) { assign(str); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString( const wxScopedU16CharBuffer &buf ) { assign(buf); }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString( const wxCStrData *cstr ) { assign(cstr); }
|
|
|
|
wxUString( const wxString &str ) { assign(str); }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString( char ch ) { assign(ch); }
|
|
|
|
wxUString( wxChar16 ch ) { assign(ch); }
|
|
|
|
wxUString( wxChar32 ch ) { assign(ch); }
|
|
|
|
wxUString( wxUniChar ch ) { assign(ch); }
|
|
|
|
wxUString( wxUniCharRef ch ) { assign(ch); }
|
|
|
|
wxUString( size_type n, char ch ) { assign(n,ch); }
|
|
|
|
wxUString( size_type n, wxChar16 ch ) { assign(n,ch); }
|
|
|
|
wxUString( size_type n, wxChar32 ch ) { assign(n,ch); }
|
|
|
|
wxUString( size_type n, wxUniChar ch ) { assign(n,ch); }
|
|
|
|
wxUString( size_type n, wxUniCharRef ch ) { assign(n,ch); }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// static construction
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
static wxUString FromAscii( const char *str, size_type n )
|
|
|
|
{
|
|
|
|
wxUString ret;
|
|
|
|
ret.assignFromAscii( str, n );
|
|
|
|
return ret;
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
static wxUString FromAscii( const char *str )
|
|
|
|
{
|
|
|
|
wxUString ret;
|
|
|
|
ret.assignFromAscii( str );
|
|
|
|
return ret;
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
static wxUString FromUTF8( const char *str, size_type n )
|
|
|
|
{
|
|
|
|
wxUString ret;
|
|
|
|
ret.assignFromUTF8( str, n );
|
|
|
|
return ret;
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
static wxUString FromUTF8( const char *str )
|
|
|
|
{
|
|
|
|
wxUString ret;
|
|
|
|
ret.assignFromUTF8( str );
|
|
|
|
return ret;
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
static wxUString FromUTF16( const wxChar16 *str, size_type n )
|
|
|
|
{
|
|
|
|
wxUString ret;
|
|
|
|
ret.assignFromUTF16( str, n );
|
|
|
|
return ret;
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
static wxUString FromUTF16( const wxChar16 *str )
|
|
|
|
{
|
|
|
|
wxUString ret;
|
|
|
|
ret.assignFromUTF16( str );
|
|
|
|
return ret;
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// assign from encoding
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assignFromAscii( const char *str );
|
|
|
|
wxUString &assignFromAscii( const char *str, size_type n );
|
|
|
|
wxUString &assignFromUTF8( const char *str );
|
|
|
|
wxUString &assignFromUTF8( const char *str, size_type n );
|
|
|
|
wxUString &assignFromUTF16( const wxChar16* str );
|
|
|
|
wxUString &assignFromUTF16( const wxChar16* str, size_type n );
|
|
|
|
wxUString &assignFromCString( const char* str );
|
|
|
|
wxUString &assignFromCString( const char* str, const wxMBConv &conv );
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// conversions
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxScopedCharBuffer utf8_str() const;
|
|
|
|
wxScopedU16CharBuffer utf16_str() const;
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
#if SIZEOF_WCHAR_T == 2
|
2009-03-27 15:33:55 +00:00
|
|
|
wxScopedWCharBuffer wc_str() const
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return utf16_str();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
wchar_t *wc_str() const
|
|
|
|
{
|
|
|
|
return (wchar_t*) c_str();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
operator wxString() const
|
|
|
|
{
|
|
|
|
#if wxUSE_UNICODE_UTF8
|
|
|
|
return wxString::FromUTF8( utf8_str() );
|
|
|
|
#else
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
return wxString( utf16_str() );
|
|
|
|
#else
|
|
|
|
return wxString( c_str() );
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if wxUSE_UNICODE_UTF8
|
2009-03-27 15:33:55 +00:00
|
|
|
wxScopedCharBuffer wx_str()
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return utf8_str();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
2009-03-27 15:33:55 +00:00
|
|
|
wxScopedWCharBuffer wx_str()
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return utf16_str();
|
|
|
|
}
|
|
|
|
#else
|
2008-08-01 07:16:49 +00:00
|
|
|
const wchar_t* wx_str()
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return c_str();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// assign
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &assign( const wxChar32* str )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->assign( str );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &assign( const wxChar32* str, size_type n )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->assign( str, n );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &assign( const wxUString &str )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->assign( str );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &assign( const wxUString &str, size_type pos, size_type n )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->assign( str, pos, n );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2014-05-15 22:32:17 +00:00
|
|
|
wxUString &assign( wxChar32 ch )
|
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->assign( (size_type) 1, ch );
|
|
|
|
}
|
2010-10-24 23:06:11 +00:00
|
|
|
|
2014-05-15 22:32:17 +00:00
|
|
|
wxUString &assign( size_type n, wxChar32 ch )
|
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->assign( n, ch );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &assign( const wxScopedU32CharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return assign( buf.data() );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( const char *str )
|
|
|
|
{
|
|
|
|
return assignFromCString( str );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &assign( const wxScopedCharBuffer &buf )
|
2008-08-25 00:36:00 +00:00
|
|
|
{
|
2008-07-29 11:01:16 +00:00
|
|
|
return assignFromCString( buf.data() );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( const char *str, const wxMBConv &conv )
|
2008-08-25 00:36:00 +00:00
|
|
|
{
|
2008-07-29 11:01:16 +00:00
|
|
|
return assignFromCString( str, conv );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &assign( const wxScopedCharBuffer &buf, const wxMBConv &conv )
|
2008-08-25 00:36:00 +00:00
|
|
|
{
|
2008-07-29 11:01:16 +00:00
|
|
|
return assignFromCString( buf.data(), conv );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( const wxChar16 *str )
|
|
|
|
{
|
|
|
|
return assignFromUTF16( str );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &assign( const wxScopedU16CharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return assignFromUTF16( buf.data() );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( const wxCStrData *cstr )
|
|
|
|
{
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
return assignFromUTF16( cstr->AsWChar() );
|
|
|
|
#else
|
|
|
|
return assign( cstr->AsWChar() );
|
|
|
|
#endif
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( const wxString &str )
|
|
|
|
{
|
|
|
|
#if wxUSE_UNICODE_UTF8
|
|
|
|
return assignFromUTF8( str.wx_str() );
|
|
|
|
#else
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
return assignFromUTF16( str.wc_str() );
|
|
|
|
#else
|
2008-08-25 00:36:00 +00:00
|
|
|
return assign( str.wc_str() );
|
2008-07-29 11:01:16 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( char ch )
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
buf[0] = ch;
|
|
|
|
buf[1] = 0;
|
|
|
|
return assignFromCString( buf );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( size_type n, char ch )
|
2008-08-25 00:36:00 +00:00
|
|
|
{
|
2008-07-29 11:01:16 +00:00
|
|
|
wxCharBuffer buffer(n);
|
|
|
|
char *p = buffer.data();
|
|
|
|
size_type i;
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
*p = ch;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
return assignFromCString( buffer.data() );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( wxChar16 ch )
|
|
|
|
{
|
|
|
|
wxChar16 buf[2];
|
|
|
|
buf[0] = ch;
|
|
|
|
buf[1] = 0;
|
|
|
|
return assignFromUTF16( buf );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( size_type n, wxChar16 ch )
|
|
|
|
{
|
|
|
|
wxU16CharBuffer buffer(n);
|
|
|
|
wxChar16 *p = buffer.data();
|
|
|
|
size_type i;
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
*p = ch;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
return assignFromUTF16( buffer.data() );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( wxUniChar ch )
|
|
|
|
{
|
2008-11-12 14:29:44 +00:00
|
|
|
return assign( (wxChar32) ch.GetValue() );
|
2008-07-29 11:01:16 +00:00
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( size_type n, wxUniChar ch )
|
|
|
|
{
|
2008-11-12 14:29:44 +00:00
|
|
|
return assign( n, (wxChar32) ch.GetValue() );
|
2008-07-29 11:01:16 +00:00
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( wxUniCharRef ch )
|
|
|
|
{
|
2008-11-12 14:29:44 +00:00
|
|
|
return assign( (wxChar32) ch.GetValue() );
|
2008-07-29 11:01:16 +00:00
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &assign( size_type n, wxUniCharRef ch )
|
|
|
|
{
|
2008-11-12 14:29:44 +00:00
|
|
|
return assign( n, (wxChar32) ch.GetValue() );
|
2008-07-29 11:01:16 +00:00
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// append [STL overload]
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &append( const wxUString &s )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->append( s );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &append( const wxUString &s, size_type pos, size_type n )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->append( s, pos, n );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &append( const wxChar32* s )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->append( s );
|
|
|
|
}
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &append( const wxChar32* s, size_type n )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->append( s, n );
|
|
|
|
}
|
|
|
|
|
2014-05-15 22:32:17 +00:00
|
|
|
wxUString &append( size_type n, wxChar32 c )
|
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->append( n, c );
|
|
|
|
}
|
2008-07-29 11:01:16 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &append( wxChar32 c )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->append( 1, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
// append [wx overload]
|
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &append( const wxScopedU16CharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return append( buf.data() );
|
|
|
|
}
|
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &append( const wxScopedU32CharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return append( buf.data() );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxUString &append( const char *str )
|
|
|
|
{
|
|
|
|
return append( wxUString( str ) );
|
|
|
|
}
|
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &append( const wxScopedCharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return append( wxUString( buf ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxUString &append( const wxChar16 *str )
|
|
|
|
{
|
|
|
|
return append( wxUString( str ) );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &append( const wxString &str )
|
|
|
|
{
|
|
|
|
return append( wxUString( str ) );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &append( const wxCStrData *cstr )
|
|
|
|
{
|
|
|
|
return append( wxUString( cstr ) );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &append( char ch )
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
buf[0] = ch;
|
|
|
|
buf[1] = 0;
|
|
|
|
return append( buf );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &append( wxChar16 ch )
|
|
|
|
{
|
|
|
|
wxChar16 buf[2];
|
|
|
|
buf[0] = ch;
|
|
|
|
buf[1] = 0;
|
|
|
|
return append( buf );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &append( wxUniChar ch )
|
|
|
|
{
|
|
|
|
return append( (size_type) 1, (wxChar32) ch.GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxUString &append( wxUniCharRef ch )
|
|
|
|
{
|
|
|
|
return append( (size_type) 1, (wxChar32) ch.GetValue() );
|
|
|
|
}
|
|
|
|
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// insert [STL overloads]
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &insert( size_type pos, const wxUString &s )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->insert( pos, s );
|
|
|
|
}
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &insert( size_type pos, const wxUString &s, size_type pos1, size_type n )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->insert( pos, s, pos1, n );
|
|
|
|
}
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &insert( size_type pos, const wxChar32 *s )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->insert( pos, s );
|
|
|
|
}
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &insert( size_type pos, const wxChar32 *s, size_type n )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->insert( pos, s, n );
|
|
|
|
}
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString &insert( size_type pos, size_type n, wxChar32 c )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return (wxUString &) base->insert( pos, n, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// insert [STL overloads]
|
|
|
|
|
|
|
|
wxUString &insert( size_type n, const char *s )
|
|
|
|
{
|
|
|
|
return insert( n, wxUString( s ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxUString &insert( size_type n, const wxChar16 *s )
|
|
|
|
{
|
|
|
|
return insert( n, wxUString( s ) );
|
|
|
|
}
|
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &insert( size_type n, const wxScopedCharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return insert( n, wxUString( buf ) );
|
|
|
|
}
|
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &insert( size_type n, const wxScopedU16CharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return insert( n, wxUString( buf ) );
|
|
|
|
}
|
|
|
|
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString &insert( size_type n, const wxScopedU32CharBuffer &buf )
|
2008-07-29 11:01:16 +00:00
|
|
|
{
|
|
|
|
return insert( n, buf.data() );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxUString &insert( size_type n, const wxString &s )
|
|
|
|
{
|
|
|
|
return insert( n, wxUString( s ) );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &insert( size_type n, const wxCStrData *cstr )
|
|
|
|
{
|
|
|
|
return insert( n, wxUString( cstr ) );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &insert( size_type n, char ch )
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
buf[0] = ch;
|
|
|
|
buf[1] = 0;
|
|
|
|
return insert( n, buf );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUString &insert( size_type n, wchar_t ch )
|
|
|
|
{
|
|
|
|
wchar_t buf[2];
|
|
|
|
buf[0] = ch;
|
|
|
|
buf[1] = 0;
|
|
|
|
return insert( n, buf );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// insert iterator
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
iterator insert( iterator it, wxChar32 ch )
|
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
return base->insert( it, ch );
|
|
|
|
}
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
void insert(iterator it, const_iterator first, const_iterator last)
|
|
|
|
{
|
|
|
|
std::basic_string<wxChar32> *base = this;
|
|
|
|
base->insert( it, first, last );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// operator =
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxString& s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxCStrData* s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const char *s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxChar16 *s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxChar32 *s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString& operator=(const wxScopedCharBuffer &s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString& operator=(const wxScopedU16CharBuffer &s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString& operator=(const wxScopedU32CharBuffer &s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const char ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxChar16 ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxChar32 ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxUniChar ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator=(const wxUniCharRef ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return assign( ch ); }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
// operator +=
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxUString& s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxString& s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxCStrData* s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const char *s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxChar16 *s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxChar32 *s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString& operator+=(const wxScopedCharBuffer &s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString& operator+=(const wxScopedU16CharBuffer &s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUString& operator+=(const wxScopedU32CharBuffer &s)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( s ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const char ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxChar16 ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxChar32 ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxUniChar ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( ch ); }
|
2008-11-12 14:29:44 +00:00
|
|
|
wxUString& operator+=(const wxUniCharRef ch)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return append( ch ); }
|
2008-08-25 00:36:00 +00:00
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
};
|
|
|
|
|
2009-06-07 12:27:07 +00:00
|
|
|
#ifdef __VISUALC__
|
2009-06-12 03:37:47 +00:00
|
|
|
#pragma warning(pop)
|
2009-06-07 12:27:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-29 11:01:16 +00:00
|
|
|
inline wxUString operator+(const wxUString &s1, const wxUString &s2)
|
|
|
|
{ wxUString ret( s1 ); ret.append( s2 ); return ret; }
|
|
|
|
inline wxUString operator+(const wxUString &s1, const char *s2)
|
|
|
|
{ return s1 + wxUString(s2); }
|
|
|
|
inline wxUString operator+(const wxUString &s1, const wxString &s2)
|
|
|
|
{ return s1 + wxUString(s2); }
|
|
|
|
inline wxUString operator+(const wxUString &s1, const wxCStrData *s2)
|
|
|
|
{ return s1 + wxUString(s2); }
|
|
|
|
inline wxUString operator+(const wxUString &s1, const wxChar16* s2)
|
|
|
|
{ return s1 + wxUString(s2); }
|
|
|
|
inline wxUString operator+(const wxUString &s1, const wxChar32 *s2)
|
|
|
|
{ return s1 + wxUString(s2); }
|
2009-03-27 15:33:55 +00:00
|
|
|
inline wxUString operator+(const wxUString &s1, const wxScopedCharBuffer &s2)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return s1 + wxUString(s2); }
|
2009-03-27 15:33:55 +00:00
|
|
|
inline wxUString operator+(const wxUString &s1, const wxScopedU16CharBuffer &s2)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return s1 + wxUString(s2); }
|
2009-03-27 15:33:55 +00:00
|
|
|
inline wxUString operator+(const wxUString &s1, const wxScopedU32CharBuffer &s2)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return s1 + wxUString(s2); }
|
|
|
|
inline wxUString operator+(const wxUString &s1, char s2)
|
|
|
|
{ return s1 + wxUString(s2); }
|
|
|
|
inline wxUString operator+(const wxUString &s1, wxChar32 s2)
|
|
|
|
{ wxUString ret( s1 ); ret.append( s2 ); return ret; }
|
|
|
|
inline wxUString operator+(const wxUString &s1, wxChar16 s2)
|
|
|
|
{ wxUString ret( s1 ); ret.append( (wxChar32) s2 ); return ret; }
|
|
|
|
inline wxUString operator+(const wxUString &s1, wxUniChar s2)
|
|
|
|
{ wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; }
|
|
|
|
inline wxUString operator+(const wxUString &s1, wxUniCharRef s2)
|
|
|
|
{ wxUString ret( s1 ); ret.append( (wxChar32) s2.GetValue() ); return ret; }
|
|
|
|
|
|
|
|
inline wxUString operator+(const char *s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(const wxString &s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(const wxCStrData *s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(const wxChar16* s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(const wxChar32 *s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
2009-03-27 15:33:55 +00:00
|
|
|
inline wxUString operator+(const wxScopedCharBuffer &s1, const wxUString &s2)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return wxUString(s1) + s2; }
|
2009-03-27 15:33:55 +00:00
|
|
|
inline wxUString operator+(const wxScopedU16CharBuffer &s1, const wxUString &s2)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return wxUString(s1) + s2; }
|
2009-03-27 15:33:55 +00:00
|
|
|
inline wxUString operator+(const wxScopedU32CharBuffer &s1, const wxUString &s2)
|
2008-07-29 11:01:16 +00:00
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(char s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(wxChar32 s1, const wxUString &s2 )
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(wxChar16 s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(wxUniChar s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
inline wxUString operator+(wxUniCharRef s1, const wxUString &s2)
|
|
|
|
{ return wxUString(s1) + s2; }
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator==(const wxUString& s1, const wxUString& s2)
|
|
|
|
{ return s1.compare( s2 ) == 0; }
|
|
|
|
inline bool operator!=(const wxUString& s1, const wxUString& s2)
|
|
|
|
{ return s1.compare( s2 ) != 0; }
|
|
|
|
inline bool operator< (const wxUString& s1, const wxUString& s2)
|
2008-08-19 16:28:21 +00:00
|
|
|
{ return s1.compare( s2 ) < 0; }
|
2008-07-29 11:01:16 +00:00
|
|
|
inline bool operator> (const wxUString& s1, const wxUString& s2)
|
|
|
|
{ return s1.compare( s2 ) > 0; }
|
|
|
|
inline bool operator<=(const wxUString& s1, const wxUString& s2)
|
|
|
|
{ return s1.compare( s2 ) <= 0; }
|
|
|
|
inline bool operator>=(const wxUString& s1, const wxUString& s2)
|
|
|
|
{ return s1.compare( s2 ) >= 0; }
|
|
|
|
|
|
|
|
#define wxUSTRING_COMP_OPERATORS( T ) \
|
|
|
|
inline bool operator==(const wxUString& s1, T s2) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) == 0; } \
|
|
|
|
inline bool operator!=(const wxUString& s1, T s2) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) != 0; } \
|
|
|
|
inline bool operator< (const wxUString& s1, T s2) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) < 0; } \
|
|
|
|
inline bool operator> (const wxUString& s1, T s2) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) > 0; } \
|
|
|
|
inline bool operator<=(const wxUString& s1, T s2) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) <= 0; } \
|
|
|
|
inline bool operator>=(const wxUString& s1, T s2) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) >= 0; } \
|
|
|
|
\
|
|
|
|
inline bool operator==(T s2, const wxUString& s1) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) == 0; } \
|
|
|
|
inline bool operator!=(T s2, const wxUString& s1) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) != 0; } \
|
|
|
|
inline bool operator< (T s2, const wxUString& s1) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) > 0; } \
|
|
|
|
inline bool operator> (T s2, const wxUString& s1) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) < 0; } \
|
|
|
|
inline bool operator<=(T s2, const wxUString& s1) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) >= 0; } \
|
|
|
|
inline bool operator>=(T s2, const wxUString& s1) \
|
|
|
|
{ return s1.compare( wxUString(s2) ) <= 0; }
|
|
|
|
|
|
|
|
wxUSTRING_COMP_OPERATORS( const wxString & )
|
|
|
|
wxUSTRING_COMP_OPERATORS( const char * )
|
|
|
|
wxUSTRING_COMP_OPERATORS( const wxChar16 * )
|
|
|
|
wxUSTRING_COMP_OPERATORS( const wxChar32 * )
|
2009-03-27 15:33:55 +00:00
|
|
|
wxUSTRING_COMP_OPERATORS( const wxScopedCharBuffer & )
|
|
|
|
wxUSTRING_COMP_OPERATORS( const wxScopedU16CharBuffer & )
|
|
|
|
wxUSTRING_COMP_OPERATORS( const wxScopedU32CharBuffer & )
|
2008-07-29 11:01:16 +00:00
|
|
|
wxUSTRING_COMP_OPERATORS( const wxCStrData * )
|
|
|
|
|
2008-11-12 14:29:44 +00:00
|
|
|
#endif // _WX_USTRING_H_
|