first phase of transition to unified Unicode build:

1. changed c_str() to return wxCStrData (implicitly convertible to wxChar*)
2. added template type-safe wrappers for vararg functions
3. added wxUniChar class representing single Unicode character
4. changed wxString::operator[] and wxString::iterator to return wxUniChar


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2007-03-17 10:26:10 +00:00
parent cd632a8617
commit c9f7896861
80 changed files with 2229 additions and 435 deletions

View File

@ -311,6 +311,7 @@ ALL_BASE_HEADERS = \
wx/strconv.h \
wx/stream.h \
wx/string.h \
wx/strvararg.h \
wx/sysopt.h \
wx/tarstrm.h \
wx/textbuf.h \
@ -445,6 +446,7 @@ ALL_PORTS_BASE_HEADERS = \
wx/strconv.h \
wx/stream.h \
wx/string.h \
wx/strvararg.h \
wx/sysopt.h \
wx/tarstrm.h \
wx/textbuf.h \
@ -579,6 +581,7 @@ ALL_BASE_SOURCES = \
src/common/strconv.cpp \
src/common/stream.cpp \
src/common/string.cpp \
src/common/strvararg.cpp \
src/common/sysopt.cpp \
src/common/tarstrm.cpp \
src/common/textbuf.cpp \
@ -734,6 +737,7 @@ MONODLL_OBJECTS = \
monodll_strconv.o \
monodll_stream.o \
monodll_string.o \
monodll_strvararg.o \
monodll_sysopt.o \
monodll_tarstrm.o \
monodll_textbuf.o \
@ -833,6 +837,7 @@ MONOLIB_OBJECTS = \
monolib_strconv.o \
monolib_stream.o \
monolib_string.o \
monolib_strvararg.o \
monolib_sysopt.o \
monolib_tarstrm.o \
monolib_textbuf.o \
@ -934,6 +939,7 @@ BASEDLL_OBJECTS = \
basedll_strconv.o \
basedll_stream.o \
basedll_string.o \
basedll_strvararg.o \
basedll_sysopt.o \
basedll_tarstrm.o \
basedll_textbuf.o \
@ -1018,6 +1024,7 @@ BASELIB_OBJECTS = \
baselib_strconv.o \
baselib_stream.o \
baselib_string.o \
baselib_strvararg.o \
baselib_sysopt.o \
baselib_tarstrm.o \
baselib_textbuf.o \
@ -12733,6 +12740,9 @@ monodll_stream.o: $(srcdir)/src/common/stream.cpp $(MONODLL_ODEP)
monodll_string.o: $(srcdir)/src/common/string.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/string.cpp
monodll_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
monodll_sysopt.o: $(srcdir)/src/common/sysopt.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/sysopt.cpp
@ -16873,6 +16883,9 @@ monolib_stream.o: $(srcdir)/src/common/stream.cpp $(MONOLIB_ODEP)
monolib_string.o: $(srcdir)/src/common/string.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/string.cpp
monolib_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
monolib_sysopt.o: $(srcdir)/src/common/sysopt.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/sysopt.cpp
@ -21016,6 +21029,9 @@ basedll_stream.o: $(srcdir)/src/common/stream.cpp $(BASEDLL_ODEP)
basedll_string.o: $(srcdir)/src/common/string.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/string.cpp
basedll_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
basedll_sysopt.o: $(srcdir)/src/common/sysopt.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/sysopt.cpp
@ -21604,6 +21620,9 @@ baselib_stream.o: $(srcdir)/src/common/stream.cpp $(BASELIB_ODEP)
baselib_string.o: $(srcdir)/src/common/string.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/string.cpp
baselib_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
baselib_sysopt.o: $(srcdir)/src/common/sysopt.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/sysopt.cpp

View File

@ -340,6 +340,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/common/strconv.cpp
src/common/stream.cpp
src/common/string.cpp
src/common/strvararg.cpp
src/common/sysopt.cpp
src/common/tarstrm.cpp
src/common/textbuf.cpp
@ -450,6 +451,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/strconv.h
wx/stream.h
wx/string.h
wx/strvararg.h
wx/sysopt.h
wx/tarstrm.h
wx/textbuf.h

View File

@ -253,6 +253,7 @@ MONODLL_OBJECTS = \
$(OBJS)\monodll_strconv.obj \
$(OBJS)\monodll_stream.obj \
$(OBJS)\monodll_string.obj \
$(OBJS)\monodll_strvararg.obj \
$(OBJS)\monodll_sysopt.obj \
$(OBJS)\monodll_tarstrm.obj \
$(OBJS)\monodll_textbuf.obj \
@ -373,6 +374,7 @@ MONOLIB_OBJECTS = \
$(OBJS)\monolib_strconv.obj \
$(OBJS)\monolib_stream.obj \
$(OBJS)\monolib_string.obj \
$(OBJS)\monolib_strvararg.obj \
$(OBJS)\monolib_sysopt.obj \
$(OBJS)\monolib_tarstrm.obj \
$(OBJS)\monolib_textbuf.obj \
@ -494,6 +496,7 @@ BASEDLL_OBJECTS = \
$(OBJS)\basedll_strconv.obj \
$(OBJS)\basedll_stream.obj \
$(OBJS)\basedll_string.obj \
$(OBJS)\basedll_strvararg.obj \
$(OBJS)\basedll_sysopt.obj \
$(OBJS)\basedll_tarstrm.obj \
$(OBJS)\basedll_textbuf.obj \
@ -599,6 +602,7 @@ BASELIB_OBJECTS = \
$(OBJS)\baselib_strconv.obj \
$(OBJS)\baselib_stream.obj \
$(OBJS)\baselib_string.obj \
$(OBJS)\baselib_strvararg.obj \
$(OBJS)\baselib_sysopt.obj \
$(OBJS)\baselib_tarstrm.obj \
$(OBJS)\baselib_textbuf.obj \
@ -4713,6 +4717,9 @@ $(OBJS)\monodll_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\monodll_string.obj: ..\..\src\common\string.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
$(OBJS)\monodll_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
$(OBJS)\monodll_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
@ -6725,6 +6732,9 @@ $(OBJS)\monolib_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\monolib_string.obj: ..\..\src\common\string.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
$(OBJS)\monolib_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
$(OBJS)\monolib_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
@ -8740,6 +8750,9 @@ $(OBJS)\basedll_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\basedll_string.obj: ..\..\src\common\string.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
$(OBJS)\basedll_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
$(OBJS)\basedll_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
@ -9007,6 +9020,9 @@ $(OBJS)\baselib_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\baselib_string.obj: ..\..\src\common\string.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
$(OBJS)\baselib_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
$(OBJS)\baselib_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**

View File

@ -239,6 +239,7 @@ MONODLL_OBJECTS = \
$(OBJS)\monodll_strconv.o \
$(OBJS)\monodll_stream.o \
$(OBJS)\monodll_string.o \
$(OBJS)\monodll_strvararg.o \
$(OBJS)\monodll_sysopt.o \
$(OBJS)\monodll_tarstrm.o \
$(OBJS)\monodll_textbuf.o \
@ -359,6 +360,7 @@ MONOLIB_OBJECTS = \
$(OBJS)\monolib_strconv.o \
$(OBJS)\monolib_stream.o \
$(OBJS)\monolib_string.o \
$(OBJS)\monolib_strvararg.o \
$(OBJS)\monolib_sysopt.o \
$(OBJS)\monolib_tarstrm.o \
$(OBJS)\monolib_textbuf.o \
@ -481,6 +483,7 @@ BASEDLL_OBJECTS = \
$(OBJS)\basedll_strconv.o \
$(OBJS)\basedll_stream.o \
$(OBJS)\basedll_string.o \
$(OBJS)\basedll_strvararg.o \
$(OBJS)\basedll_sysopt.o \
$(OBJS)\basedll_tarstrm.o \
$(OBJS)\basedll_textbuf.o \
@ -586,6 +589,7 @@ BASELIB_OBJECTS = \
$(OBJS)\baselib_strconv.o \
$(OBJS)\baselib_stream.o \
$(OBJS)\baselib_string.o \
$(OBJS)\baselib_strvararg.o \
$(OBJS)\baselib_sysopt.o \
$(OBJS)\baselib_tarstrm.o \
$(OBJS)\baselib_textbuf.o \
@ -4842,6 +4846,9 @@ $(OBJS)\monodll_stream.o: ../../src/common/stream.cpp
$(OBJS)\monodll_string.o: ../../src/common/string.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_strvararg.o: ../../src/common/strvararg.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_sysopt.o: ../../src/common/sysopt.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
@ -6954,6 +6961,9 @@ $(OBJS)\monolib_stream.o: ../../src/common/stream.cpp
$(OBJS)\monolib_string.o: ../../src/common/string.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_strvararg.o: ../../src/common/strvararg.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_sysopt.o: ../../src/common/sysopt.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
@ -9069,6 +9079,9 @@ $(OBJS)\basedll_stream.o: ../../src/common/stream.cpp
$(OBJS)\basedll_string.o: ../../src/common/string.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\basedll_strvararg.o: ../../src/common/strvararg.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\basedll_sysopt.o: ../../src/common/sysopt.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
@ -9336,6 +9349,9 @@ $(OBJS)\baselib_stream.o: ../../src/common/stream.cpp
$(OBJS)\baselib_string.o: ../../src/common/string.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\baselib_strvararg.o: ../../src/common/strvararg.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\baselib_sysopt.o: ../../src/common/sysopt.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<

View File

@ -254,6 +254,7 @@ MONODLL_OBJECTS = \
$(OBJS)\monodll_strconv.obj \
$(OBJS)\monodll_stream.obj \
$(OBJS)\monodll_string.obj \
$(OBJS)\monodll_strvararg.obj \
$(OBJS)\monodll_sysopt.obj \
$(OBJS)\monodll_tarstrm.obj \
$(OBJS)\monodll_textbuf.obj \
@ -379,6 +380,7 @@ MONOLIB_OBJECTS = \
$(OBJS)\monolib_strconv.obj \
$(OBJS)\monolib_stream.obj \
$(OBJS)\monolib_string.obj \
$(OBJS)\monolib_strvararg.obj \
$(OBJS)\monolib_sysopt.obj \
$(OBJS)\monolib_tarstrm.obj \
$(OBJS)\monolib_textbuf.obj \
@ -506,6 +508,7 @@ BASEDLL_OBJECTS = \
$(OBJS)\basedll_strconv.obj \
$(OBJS)\basedll_stream.obj \
$(OBJS)\basedll_string.obj \
$(OBJS)\basedll_strvararg.obj \
$(OBJS)\basedll_sysopt.obj \
$(OBJS)\basedll_tarstrm.obj \
$(OBJS)\basedll_textbuf.obj \
@ -617,6 +620,7 @@ BASELIB_OBJECTS = \
$(OBJS)\baselib_strconv.obj \
$(OBJS)\baselib_stream.obj \
$(OBJS)\baselib_string.obj \
$(OBJS)\baselib_strvararg.obj \
$(OBJS)\baselib_sysopt.obj \
$(OBJS)\baselib_tarstrm.obj \
$(OBJS)\baselib_textbuf.obj \
@ -4206,7 +4210,7 @@ clean:
-if exist $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib del $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib
cd ..\..\samples
$(MAKE) -f makefile.vc $(MAKEARGS) clean
cd "$(MAKEDIR)"
cd $(MAKEDIR)
setup_h: $(SETUPHDIR)\wx ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h $(SETUPHDIR)\wx\setup.h $(SETUPHDIR)\wx\msw\rcdefs.h
@ -4480,7 +4484,7 @@ $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXD
sub_samples:
cd ..\..\samples
$(MAKE) -f makefile.vc $(MAKEARGS) all
cd "$(MAKEDIR)"
cd $(MAKEDIR)
$(LIBDIRNAME):
if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
@ -5046,6 +5050,9 @@ $(OBJS)\monodll_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\monodll_string.obj: ..\..\src\common\string.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
$(OBJS)\monodll_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
$(OBJS)\monodll_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
@ -7058,6 +7065,9 @@ $(OBJS)\monolib_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\monolib_string.obj: ..\..\src\common\string.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
$(OBJS)\monolib_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
$(OBJS)\monolib_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
@ -9073,6 +9083,9 @@ $(OBJS)\basedll_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\basedll_string.obj: ..\..\src\common\string.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
$(OBJS)\basedll_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
$(OBJS)\basedll_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
@ -9340,6 +9353,9 @@ $(OBJS)\baselib_stream.obj: ..\..\src\common\stream.cpp
$(OBJS)\baselib_string.obj: ..\..\src\common\string.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
$(OBJS)\baselib_strvararg.obj: ..\..\src\common\strvararg.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
$(OBJS)\baselib_sysopt.obj: ..\..\src\common\sysopt.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**

View File

@ -3031,6 +3031,7 @@ MONODLL_OBJECTS = &
$(OBJS)\monodll_strconv.obj &
$(OBJS)\monodll_stream.obj &
$(OBJS)\monodll_string.obj &
$(OBJS)\monodll_strvararg.obj &
$(OBJS)\monodll_sysopt.obj &
$(OBJS)\monodll_tarstrm.obj &
$(OBJS)\monodll_textbuf.obj &
@ -3151,6 +3152,7 @@ MONOLIB_OBJECTS = &
$(OBJS)\monolib_strconv.obj &
$(OBJS)\monolib_stream.obj &
$(OBJS)\monolib_string.obj &
$(OBJS)\monolib_strvararg.obj &
$(OBJS)\monolib_sysopt.obj &
$(OBJS)\monolib_tarstrm.obj &
$(OBJS)\monolib_textbuf.obj &
@ -3273,6 +3275,7 @@ BASEDLL_OBJECTS = &
$(OBJS)\basedll_strconv.obj &
$(OBJS)\basedll_stream.obj &
$(OBJS)\basedll_string.obj &
$(OBJS)\basedll_strvararg.obj &
$(OBJS)\basedll_sysopt.obj &
$(OBJS)\basedll_tarstrm.obj &
$(OBJS)\basedll_textbuf.obj &
@ -3379,6 +3382,7 @@ BASELIB_OBJECTS = &
$(OBJS)\baselib_strconv.obj &
$(OBJS)\baselib_stream.obj &
$(OBJS)\baselib_string.obj &
$(OBJS)\baselib_strvararg.obj &
$(OBJS)\baselib_sysopt.obj &
$(OBJS)\baselib_tarstrm.obj &
$(OBJS)\baselib_textbuf.obj &
@ -5072,6 +5076,9 @@ $(OBJS)\monodll_stream.obj : .AUTODEPEND ..\..\src\common\stream.cpp
$(OBJS)\monodll_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
$(OBJS)\monodll_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
$(OBJS)\monodll_sysopt.obj : .AUTODEPEND ..\..\src\common\sysopt.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
@ -7184,6 +7191,9 @@ $(OBJS)\monolib_stream.obj : .AUTODEPEND ..\..\src\common\stream.cpp
$(OBJS)\monolib_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
$(OBJS)\monolib_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
$(OBJS)\monolib_sysopt.obj : .AUTODEPEND ..\..\src\common\sysopt.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
@ -9299,6 +9309,9 @@ $(OBJS)\basedll_stream.obj : .AUTODEPEND ..\..\src\common\stream.cpp
$(OBJS)\basedll_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
$(OBJS)\basedll_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
$(OBJS)\basedll_sysopt.obj : .AUTODEPEND ..\..\src\common\sysopt.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
@ -9566,6 +9579,9 @@ $(OBJS)\baselib_stream.obj : .AUTODEPEND ..\..\src\common\stream.cpp
$(OBJS)\baselib_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
$(OBJS)\baselib_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
$(OBJS)\baselib_sysopt.obj : .AUTODEPEND ..\..\src\common\sysopt.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<

View File

@ -675,6 +675,10 @@ SOURCE=..\..\src\common\string.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\common\strvararg.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\common\sysopt.cpp
# End Source File
# Begin Source File
@ -1755,6 +1759,10 @@ SOURCE=..\..\include\wx\string.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\strvararg.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\sysopt.h
# End Source File
# Begin Source File

View File

@ -14,6 +14,34 @@ Changes in behaviour which may result in compilation errors
- WXWIN_COMPATIBILITY_2_4 doesn't exist any more, please update your code if
you still relied on features deprecated since version 2.4
- Return type of wxString::operator[] and wxString::iterator::operator* is no
longer wxChar (i.e. char or wchar_t), but wxUniChar. This is not a problem
in vast majority of cases because of conversion operators, but it can break
code that depends on the result being wxChar.
- The value returned by wxString::operator[] or wxString::iterator cannot be
used in switch statements anymore, because it's a class instance. Code like
this won't compile:
switch (str[i]) { ... }
and has to be replaced with this:
switch (str[i].GetValue()) { ... }
- Return type of wxString::c_str() is now wxCStrData struct and not
const wxChar*. wxCStrData is implicitly convertible to const char* and
const wchar_t*, so this only presents a problem if the compiler cannot
convert the type. In particular, Borland C++ and DigitalMars compilers
don't correctly convert operator?: operands to the same type and fail with
compilation error instead. This can be worked around by explicitly casting
to const wxChar*:
wxLogError(_("error: %s"), !err.empty() ? (const wxChar*)err.c_str() : "")
- DigitalMars compiler has a bug that prevents it from using
wxUniChar::operator bool in conditions and it erroneously reports type
conversion ambiguity in expressions such as this:
for ( wxString::const_iterator p = s.begin(); *p; ++p )
This can be worked around by explicitly casting to bool:
for ( wxString::const_iterator p = s.begin(); (bool)*p; ++p )
Deprecated methods and their replacements
-----------------------------------------

View File

@ -389,7 +389,7 @@ public:
static wxString GetPathTerminators(wxPathFormat format = wxPATH_NATIVE);
// get the canonical path separator for this format
static wxChar GetPathSeparator(wxPathFormat format = wxPATH_NATIVE)
static wxUniChar GetPathSeparator(wxPathFormat format = wxPATH_NATIVE)
{ return GetPathSeparators(format)[0u]; }
// is the char a path separator for this format?

View File

@ -21,6 +21,7 @@
#include "wx/dialog.h"
#include "wx/module.h"
#include "wx/cmndata.h"
#include "wx/strvararg.h"
extern WXDLLIMPEXP_DATA_CORE(int) wxPageNumber;
@ -85,7 +86,7 @@ public:
static void SetResolution(int ppi);
static int GetResolution();
void PsPrintf( const wxChar* fmt, ... );
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, DoPsPrintfFormat)
void PsPrint( const char* psdata );
void PsPrint( int ch );
@ -94,6 +95,8 @@ public:
#endif
private:
void DoPsPrintfFormat(const wxChar *fmt, ... );
static float ms_PSScaleFactor;
protected:

View File

@ -45,6 +45,7 @@ typedef unsigned long wxLogLevel;
// ----------------------------------------------------------------------------
#include "wx/string.h"
#include "wx/strvararg.h"
#if wxUSE_LOG
@ -470,33 +471,39 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
// define wxLog<level>
// ----------------------------------------------------------------------------
#define DECLARE_LOG_FUNCTION(level) \
extern void WXDLLIMPEXP_BASE wxVLog##level(const wxChar *szFormat, \
va_list argptr); \
extern void WXDLLIMPEXP_BASE wxLog##level(const wxChar *szFormat, \
...) ATTRIBUTE_PRINTF_1
#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
extern void expdecl wxVLog##level(argclass arg, \
const wxChar *szFormat, \
va_list argptr); \
extern void expdecl wxLog##level(argclass arg, \
const wxChar *szFormat, \
...) ATTRIBUTE_PRINTF_2
#define DECLARE_LOG_FUNCTION_PUBLIC(level) \
/* void wxLog##level(const wxChar *szFormat, ...); */ \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, wxDoLog##level)
#define DECLARE_LOG_FUNCTION_IMPL(level) \
extern void WXDLLIMPEXP_BASE wxVLog##level(const wxChar *szFormat, \
va_list argptr); \
extern void WXDLLIMPEXP_BASE wxDoLog##level(const wxChar *szFormat, \
...) ATTRIBUTE_PRINTF_1
#define DECLARE_LOG_FUNCTION2_EXP_IMPL(level, argclass, arg, expdecl) \
extern void expdecl wxVLog##level(argclass arg, \
const wxChar *szFormat, \
va_list argptr); \
extern void expdecl wxDoLog##level(argclass arg, \
const wxChar *szFormat, \
...) ATTRIBUTE_PRINTF_2
#else // !wxUSE_LOG
// log functions do nothing at all
#define DECLARE_LOG_FUNCTION(level) \
inline void wxVLog##level(const wxChar *WXUNUSED(szFormat), \
va_list WXUNUSED(argptr)) { } \
inline void wxLog##level(const wxChar *WXUNUSED(szFormat), \
...) { }
#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
inline void wxVLog##level(argclass WXUNUSED(arg), \
const wxChar *WXUNUSED(szFormat), \
va_list WXUNUSED(argptr)) {} \
inline void wxLog##level(argclass WXUNUSED(arg), \
const wxChar *WXUNUSED(szFormat), \
...) { }
#define DECLARE_LOG_FUNCTION_PUBLIC(level) \
/* void wxLog##level(const wxChar *szFormat, ...) {} */ \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level)
#define DECLARE_LOG_FUNCTION_IMPL(level) \
inline void wxVLog##level(const wxChar *WXUNUSED(szFormat), \
va_list WXUNUSED(argptr)) { } \
#define DECLARE_LOG_FUNCTION2_EXP_IMPL(level, argclass, arg, expdecl) \
inline void wxVLog##level(argclass WXUNUSED(arg), \
const wxChar *WXUNUSED(szFormat), \
va_list WXUNUSED(argptr)) {}
// Empty Class to fake wxLogNull
class WXDLLIMPEXP_BASE wxLogNull
@ -514,6 +521,21 @@ public:
#endif // wxUSE_LOG/!wxUSE_LOG
#define DECLARE_LOG_FUNCTION(level) \
DECLARE_LOG_FUNCTION_PUBLIC(level) \
DECLARE_LOG_FUNCTION_IMPL(level)
#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
DECLARE_LOG_FUNCTION_PUBLIC(level) \
DECLARE_LOG_FUNCTION2_EXP_IMPL(level, argclass, arg, expdecl)
#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
DECLARE_LOG_FUNCTION_PUBLIC(level) \
DECLARE_LOG_FUNCTION2_EXP_IMPL(level, argclass, arg, expdecl)
#define DECLARE_LOG_FUNCTION2_IMPL(level, argclass, arg) \
DECLARE_LOG_FUNCTION2_EXP_IMPL(level, argclass, arg, WXDLLIMPEXP_BASE)
#define DECLARE_LOG_FUNCTION2(level, argclass, arg) \
DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, WXDLLIMPEXP_BASE)
@ -531,22 +553,26 @@ DECLARE_LOG_FUNCTION(Verbose);
// this function sends the log message to the status line of the top level
// application frame, if any
DECLARE_LOG_FUNCTION(Status);
DECLARE_LOG_FUNCTION_IMPL(Status);
#if wxUSE_GUI
// this one is the same as previous except that it allows to explicitly
class WXDLLEXPORT wxFrame;
// specify the frame to which the output should go
DECLARE_LOG_FUNCTION2_EXP(Status, wxFrame *, pFrame, WXDLLIMPEXP_CORE);
DECLARE_LOG_FUNCTION2_EXP_IMPL(Status, wxFrame *, pFrame, WXDLLIMPEXP_CORE);
#endif // wxUSE_GUI
DECLARE_LOG_FUNCTION_PUBLIC(Status);
// additional one: as wxLogError, but also logs last system call error code
// and the corresponding error message if available
DECLARE_LOG_FUNCTION(SysError);
DECLARE_LOG_FUNCTION_IMPL(SysError);
// and another one which also takes the error code (for those broken APIs
// that don't set the errno (like registry APIs in Win32))
DECLARE_LOG_FUNCTION2(SysError, long, lErrCode);
DECLARE_LOG_FUNCTION2_IMPL(SysError, long, lErrCode);
DECLARE_LOG_FUNCTION_PUBLIC(SysError);
// debug functions do nothing in release mode
#if wxUSE_LOG && wxUSE_LOG_DEBUG
@ -558,12 +584,12 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode);
// this version only logs the message if the mask had been added to the
// list of masks with AddTraceMask()
DECLARE_LOG_FUNCTION2(Trace, const wxChar *, mask);
DECLARE_LOG_FUNCTION2_IMPL(Trace, const wxChar*, mask);
// and this one does nothing if all of level bits are not set in
// wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of
// string identifiers
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
DECLARE_LOG_FUNCTION2_IMPL(Trace, wxTraceMask, mask);
DECLARE_LOG_FUNCTION_PUBLIC(Trace);
#else //!debug || !wxUSE_LOG
// these functions do nothing in release builds, but don't define them as
// nothing as it could result in different code structure in debug and
@ -586,11 +612,11 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode);
#define wxLogDebug(fmt, ...) wxLogNop()
#define wxLogTrace(mask, fmt, ...) wxLogNop()
#else // !HAVE_VARIADIC_MACROS
// note that leaving out "fmt" in the vararg functions provokes a warning
// from SGI CC: "the last argument of the varargs function is unnamed"
inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); }
inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); }
inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); }
//inline void wxLogDebug(const wxString& fmt, ...) {}
WX_DEFINE_VARARG_FUNC_NOP(wxLogDebug, wxLogNopVararg)
//inline void wxLogTrace(wxTraceMask, const wxString& fmt, ...) {}
//inline void wxLogTrace(const wxString&, const wxString& fmt, ...) {}
WX_DEFINE_VARARG_FUNC_NOP(wxLogTrace, wxLogNopVararg)
#endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS
#endif // debug/!debug

View File

@ -18,20 +18,42 @@
#include "wx/defs.h"
#include "wx/wxchar.h"
#include "wx/strvararg.h"
// ----------------------------------------------------------------------------
// wxMessageOutput is a class abstracting formatted output target, i.e.
// something you can printf() to
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxMessageOutput
// NB: VC6 has a bug that causes linker errors if you have template methods
// in a class using __declspec(dllimport). The solution is to split such
// class into two classes, one that contains the template methods and does
// *not* use WXDLLIMPEXP_BASE and another class that contains the rest
// (with DLL linkage).
class wxMessageOutputBase
{
public:
virtual ~wxMessageOutputBase() { }
// show a message to the user
// void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0;
WX_DEFINE_VARARG_FUNC_VOID(Printf, DoPrintf)
protected:
virtual void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0;
};
#ifdef __VISUALC__
// "non dll-interface class 'wxStringPrintfMixin' used as base interface
// for dll-interface class 'wxString'" -- this is OK in our case
#pragma warning (disable:4275)
#endif
class WXDLLIMPEXP_BASE wxMessageOutput : public wxMessageOutputBase
{
public:
virtual ~wxMessageOutput() { }
// show a message to the user
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0;
// gets the current wxMessageOutput object (may be NULL during
// initialization or shutdown)
static wxMessageOutput* Get();
@ -43,6 +65,10 @@ private:
static wxMessageOutput* ms_msgOut;
};
#ifdef __VISUALC__
#pragma warning (default:4275)
#endif
// ----------------------------------------------------------------------------
// implementation showing the message to the user in "best" possible way: uses
// native message box if available (currently only under Windows) and stderr
@ -54,7 +80,8 @@ class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput
public:
wxMessageOutputBest() { }
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
protected:
virtual void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
};
// ----------------------------------------------------------------------------
@ -66,7 +93,8 @@ class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
public:
wxMessageOutputStderr() { }
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
protected:
virtual void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
};
// ----------------------------------------------------------------------------
@ -80,7 +108,8 @@ class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput
public:
wxMessageOutputMessageBox() { }
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
protected:
virtual void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
};
#endif // wxUSE_GUI
@ -94,7 +123,8 @@ class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput
public:
wxMessageOutputDebug() { }
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
protected:
virtual void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
};
// ----------------------------------------------------------------------------
@ -106,7 +136,8 @@ class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput
public:
wxMessageOutputLog() { }
virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
protected:
virtual void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
};
#endif

View File

@ -52,6 +52,7 @@
#endif
#include "wx/wxchar.h" // for wxChar
#include "wx/strvararg.h"
#include "wx/buffer.h" // for wxCharBuffer
#include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes
@ -251,9 +252,6 @@ struct WXDLLIMPEXP_BASE wxStringData
class WXDLLIMPEXP_BASE wxStringBase
{
#if !wxUSE_STL
friend class WXDLLIMPEXP_BASE wxArrayString;
#endif
public :
// an 'invalid' value for string index, moved to this place due to a CW bug
static const size_t npos;
@ -295,51 +293,141 @@ protected:
bool Alloc(size_t nLen);
public:
// standard types
typedef wxChar value_type;
typedef wxChar char_type;
typedef wxUniChar value_type;
typedef wxUniChar char_type;
typedef wxUniCharRef reference;
typedef wxChar* pointer;
typedef const wxChar* const_pointer;
typedef size_t size_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type *iterator;
typedef const value_type *const_iterator;
typedef wxUniChar const_reference;
#define wxSTRING_REVERSE_ITERATOR(name, const_or_not) \
class name \
{ \
public: \
typedef wxChar value_type; \
typedef const_or_not value_type& reference; \
typedef const_or_not value_type *pointer; \
typedef const_or_not value_type *iterator_type; \
\
name(iterator_type i) : m_cur(i) { } \
name(const name& ri) : m_cur(ri.m_cur) { } \
\
iterator_type base() const { return m_cur; } \
\
reference operator*() const { return *(m_cur - 1); } \
\
name& operator++() { --m_cur; return *this; } \
name operator++(int) { name tmp = *this; --m_cur; return tmp; } \
name& operator--() { ++m_cur; return *this; } \
name operator--(int) { name tmp = *this; ++m_cur; return tmp; } \
\
bool operator==(name ri) const { return m_cur == ri.m_cur; } \
bool operator!=(name ri) const { return !(*this == ri); } \
\
private: \
iterator_type m_cur; \
}
#define WX_STR_ITERATOR_IMPL(iterator_name, pointer_type, \
reference_type, reference_ctor) \
public: \
typedef wxUniChar value_type; \
typedef reference_type reference; \
typedef pointer_type pointer; \
\
iterator_name(const iterator_name& i) : m_cur(i.m_cur) {} \
\
reference operator*() const { return reference_ctor; } \
\
iterator_name& operator++() \
{ ++m_cur; return *this; } \
iterator_name operator++(int) \
{ iterator_name tmp = *this; ++m_cur; return tmp; } \
iterator_name& operator--() \
{ --m_cur; return *this; } \
iterator_name operator--(int) \
{ iterator_name tmp = *this; --m_cur; return tmp; } \
\
iterator_name operator+(int n) const \
{ return iterator_name(m_cur + n); } \
iterator_name operator+(size_t n) const \
{ return iterator_name(m_cur + n); } \
iterator_name operator-(int n) const \
{ return iterator_name(m_cur - n); } \
iterator_name operator-(size_t n) const \
{ return iterator_name(m_cur - n); } \
iterator_name operator+=(int n) \
{ m_cur += n; return *this; } \
iterator_name operator+=(size_t n) \
{ m_cur += n; return *this; } \
iterator_name operator-=(int n) \
{ m_cur -= n; return *this; } \
iterator_name operator-=(size_t n) \
{ m_cur -= n; return *this; } \
\
unsigned operator-(const iterator_name& i) const \
{ return m_cur - i.m_cur; } \
\
bool operator==(const iterator_name&i) const \
{ return m_cur == i.m_cur; } \
bool operator!=(const iterator_name& i) const \
{ return m_cur != i.m_cur; } \
\
bool operator<(const iterator_name& i) const \
{ return m_cur < i.m_cur; } \
bool operator>(const iterator_name& i) const \
{ return m_cur > i.m_cur; } \
bool operator<=(const iterator_name& i) const \
{ return m_cur <= i.m_cur; } \
bool operator>=(const iterator_name& i) const \
{ return m_cur >= i.m_cur; } \
\
protected: \
/* for internal wxString use only: */ \
iterator_name(pointer ptr) : m_cur(ptr) {} \
operator pointer() const { return m_cur; } \
\
friend class WXDLLIMPEXP_BASE wxString; \
friend class WXDLLIMPEXP_BASE wxStringBase; \
friend class WXDLLIMPEXP_BASE wxCStrData; \
\
protected: \
pointer m_cur;
wxSTRING_REVERSE_ITERATOR(const_reverse_iterator, const);
class const_iterator;
#define wxSTRING_CONST
wxSTRING_REVERSE_ITERATOR(reverse_iterator, wxSTRING_CONST);
#undef wxSTRING_CONST
class iterator
{
WX_STR_ITERATOR_IMPL(iterator, wxChar*, wxUniCharRef,
wxUniCharRef::CreateForString(m_cur))
#undef wxSTRING_REVERSE_ITERATOR
friend class const_iterator;
};
class const_iterator
{
// NB: reference_type is intentionally value, not reference, the character
// may be encoded differently in wxString data:
WX_STR_ITERATOR_IMPL(const_iterator, const wxChar*, wxUniChar,
wxUniChar(*m_cur))
public:
const_iterator(const iterator& i) : m_cur(i.m_cur) {}
};
#undef WX_STR_ITERATOR
template <typename T>
class reverse_iterator_impl
{
public:
typedef T iterator_type;
typedef typename T::value_type value_type;
typedef typename T::reference reference;
typedef typename T::pointer *pointer;
reverse_iterator_impl(iterator_type i) : m_cur(i) {}
reverse_iterator_impl(const reverse_iterator_impl& ri)
: m_cur(ri.m_cur) {}
iterator_type base() const { return m_cur; }
reference operator*() const { return *(m_cur-1); }
reverse_iterator_impl& operator++()
{ --m_cur; return *this; }
reverse_iterator_impl operator++(int)
{ reverse_iterator_impl tmp = *this; --m_cur; return tmp; }
reverse_iterator_impl& operator--()
{ ++m_cur; return *this; }
reverse_iterator_impl operator--(int)
{ reverse_iterator_impl tmp = *this; ++m_cur; return tmp; }
bool operator==(const reverse_iterator_impl& ri) const
{ return m_cur == ri.m_cur; }
bool operator!=(const reverse_iterator_impl& ri) const
{ return !(*this == ri); }
private:
iterator_type m_cur;
};
typedef reverse_iterator_impl<iterator> reverse_iterator;
typedef reverse_iterator_impl<const_iterator> const_reverse_iterator;
// constructors and destructor
@ -361,7 +449,7 @@ public:
}
}
// string containing nRepeat copies of ch
wxStringBase(size_type nRepeat, wxChar ch);
wxStringBase(size_type nRepeat, wxUniChar ch);
// ctor takes first nLength characters from C string
// (default value of npos means take all the string)
wxStringBase(const wxChar *psz)
@ -404,7 +492,7 @@ public:
// from another wxString
wxStringBase& operator=(const wxStringBase& stringSrc);
// from a character
wxStringBase& operator=(wxChar ch);
wxStringBase& operator=(wxUniChar ch);
// from a C string
wxStringBase& operator=(const wxChar *psz);
@ -415,7 +503,7 @@ public:
// return the maximum size of the string
size_type max_size() const { return npos; }
// resize the string, filling the space with c if c != 0
void resize(size_t nSize, wxChar ch = wxT('\0'));
void resize(size_t nSize, wxUniChar ch = wxT('\0'));
// delete the contents of the string
void clear() { erase(0, npos); }
// returns true if the string is empty
@ -430,7 +518,11 @@ public:
{ wxASSERT_VALID_INDEX( n ); return m_pchData[n]; }
// returns the writable character at position n
reference at(size_type n)
{ wxASSERT_VALID_INDEX( n ); CopyBeforeWrite(); return m_pchData[n]; }
{
wxASSERT_VALID_INDEX( n );
CopyBeforeWrite();
return wxUniCharRef::CreateForString(&m_pchData[n]);
}
// lib.string.modifiers
// append elements str[pos], ..., str[pos+n]
@ -449,7 +541,7 @@ public:
wxStringBase& append(const wxChar *sz, size_t n)
{ ConcatSelf(n, sz); return *this; }
// append n copies of ch
wxStringBase& append(size_t n, wxChar ch);
wxStringBase& append(size_t n, wxUniChar ch);
// append from first to last
wxStringBase& append(const_iterator first, const_iterator last)
{ ConcatSelf(last - first, first); return *this; }
@ -466,7 +558,7 @@ public:
wxStringBase& assign(const wxChar *sz, size_t n)
{ clear(); return append(sz, n); }
// same as `= n copies of ch'
wxStringBase& assign(size_t n, wxChar ch)
wxStringBase& assign(size_t n, wxUniChar ch)
{ clear(); return append(n, ch); }
// assign from first to last
wxStringBase& assign(const_iterator first, const_iterator last)
@ -504,13 +596,13 @@ public:
// insert first n (or all if n == npos) characters of sz
wxStringBase& insert(size_t nPos, const wxChar *sz, size_t n = npos);
// insert n copies of ch
wxStringBase& insert(size_t nPos, size_t n, wxChar ch)
wxStringBase& insert(size_t nPos, size_t n, wxUniChar ch)
{ return insert(nPos, wxStringBase(n, ch)); }
iterator insert(iterator it, wxChar ch)
iterator insert(iterator it, wxUniChar ch)
{ size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; }
void insert(iterator it, const_iterator first, const_iterator last)
{ insert(it - begin(), first, last - first); }
void insert(iterator it, size_type n, wxChar ch)
void insert(iterator it, size_type n, wxUniChar ch)
{ insert(it - begin(), n, ch); }
// delete characters from nStart to nStart + nLen
@ -533,7 +625,7 @@ public:
wxStringBase& replace(size_t nStart, size_t nLen, const wxStringBase& str)
{ return replace(nStart, nLen, str.c_str()); }
// replaces the substring with nCount copies of ch
wxStringBase& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch);
wxStringBase& replace(size_t nStart, size_t nLen, size_t nCount, wxUniChar ch);
// replaces a substring with another substring
wxStringBase& replace(size_t nStart, size_t nLen,
const wxStringBase& str, size_t nStart2, size_t nLen2);
@ -547,7 +639,7 @@ public:
{ return replace(first - begin(), last - first, s, n); }
wxStringBase& replace(iterator first, iterator last, const wxStringBase& s)
{ return replace(first - begin(), last - first, s); }
wxStringBase& replace(iterator first, iterator last, size_type n, wxChar c)
wxStringBase& replace(iterator first, iterator last, size_type n, wxUniChar c)
{ return replace(first - begin(), last - first, n, c); }
wxStringBase& replace(iterator first, iterator last,
const_iterator first1, const_iterator last1)
@ -567,7 +659,7 @@ public:
size_t find(const wxChar* sz, size_t nStart = 0, size_t n = npos) const;
// find the first occurence of character ch after nStart
size_t find(wxChar ch, size_t nStart = 0) const;
size_t find(wxUniChar ch, size_t nStart = 0) const;
// rfind() family is exactly like find() but works right to left
@ -578,7 +670,7 @@ public:
size_t rfind(const wxChar* sz, size_t nStart = npos,
size_t n = npos) const;
// as find, but from the end
size_t rfind(wxChar ch, size_t nStart = npos) const;
size_t rfind(wxUniChar ch, size_t nStart = npos) const;
// find first/last occurence of any character in the set
@ -589,7 +681,7 @@ public:
size_t find_first_of(const wxChar* sz, size_t nStart = 0) const;
size_t find_first_of(const wxChar* sz, size_t nStart, size_t n) const;
// same as find(char, size_t)
size_t find_first_of(wxChar c, size_t nStart = 0) const
size_t find_first_of(wxUniChar c, size_t nStart = 0) const
{ return find(c, nStart); }
// find the last (starting from nStart) char from str in this string
size_t find_last_of (const wxStringBase& str, size_t nStart = npos) const
@ -598,7 +690,7 @@ public:
size_t find_last_of (const wxChar* sz, size_t nStart = npos) const;
size_t find_last_of(const wxChar* sz, size_t nStart, size_t n) const;
// same as above
size_t find_last_of(wxChar c, size_t nStart = npos) const
size_t find_last_of(wxUniChar c, size_t nStart = npos) const
{ return rfind(c, nStart); }
// find first/last occurence of any character not in the set
@ -610,7 +702,7 @@ public:
size_t find_first_not_of(const wxChar* sz, size_t nStart = 0) const;
size_t find_first_not_of(const wxChar* sz, size_t nStart, size_t n) const;
// same as above
size_t find_first_not_of(wxChar ch, size_t nStart = 0) const;
size_t find_first_not_of(wxUniChar ch, size_t nStart = 0) const;
// as strcspn()
size_t find_last_not_of(const wxStringBase& str, size_t nStart = npos) const
{ return find_last_not_of(str.c_str(), nStart); }
@ -618,7 +710,7 @@ public:
size_t find_last_not_of(const wxChar* sz, size_t nStart = npos) const;
size_t find_last_not_of(const wxChar* sz, size_t nStart, size_t n) const;
// same as above
size_t find_last_not_of(wxChar ch, size_t nStart = npos) const;
size_t find_last_not_of(wxUniChar ch, size_t nStart = npos) const;
// All compare functions return -1, 0 or 1 if the [sub]string is less,
// equal or greater than the compare() argument.
@ -646,22 +738,157 @@ public:
// string += C string
wxStringBase& operator+=(const wxChar *psz) { return append(psz); }
// string += char
wxStringBase& operator+=(wxChar ch) { return append(1, ch); }
wxStringBase& operator+=(wxUniChar ch) { return append(1, ch); }
wxStringBase& operator+=(wxUniCharRef ch) { return append(1, ch); }
wxStringBase& operator+=(char ch) { return append(1, ch); }
wxStringBase& operator+=(wchar_t ch) { return append(1, ch); }
};
#endif // !wxUSE_STL
// ----------------------------------------------------------------------------
// wxCStrData
// ----------------------------------------------------------------------------
// Lightweight object returned by wxString::c_str() and implicitly convertible
// to either const char* or const wchar_t*.
class WXDLLIMPEXP_BASE wxCStrData
{
private:
// Ctors; for internal use by wxString and wxCStrData only
wxCStrData(const wxString *str, size_t offset = 0, bool owned = false)
: m_str(str), m_offset(offset), m_owned(owned) {}
public:
// Ctor constructs the object from char literal; they are needed to make
// operator?: compile and they intentionally take char*, not const char*
wxCStrData(char *buf);
wxCStrData(wchar_t *buf);
~wxCStrData();
// FIXME: we'll need convertors for both char* and wchar_t* and NONE
// for wxChar*, but that's after completing the transition to
// "smart" wxUniChar class. For now, just have conversion to
// char* in ANSI build and wchar_t in Unicode build.
#if wxUSE_UNICODE
const wchar_t* AsWChar() const;
operator const wchar_t*() const { return AsWChar(); }
#else
const char* AsChar() const;
operator const char*() const { return AsChar(); }
#endif
wxString AsString() const;
operator wxString() const;
// allow expressions like "c_str()[0]":
wxUniChar operator[](int n) const { return operator[](size_t(n)); }
wxUniChar operator[](size_t n) const;
#ifndef wxSIZE_T_IS_UINT
wxUniChar operator[](unsigned int n) const { return operator[](size_t(n)); }
#endif // size_t != unsigned int
// this operator is needed to emulate the pointer semantics of c_str():
// expressions like "wxChar *p = str.c_str() + 1;" should continue to work
// (we need both versions to resolve ambiguities):
wxCStrData operator+(int n) const
{ return wxCStrData(m_str, m_offset + n, m_owned); }
wxCStrData operator+(size_t n) const
{ return wxCStrData(m_str, m_offset + n, m_owned); }
// this operator is need to make expressions like "*c_str()" or
// "*(c_str() + 2)" work
wxUniChar operator*() const;
private:
const wxString *m_str;
size_t m_offset;
bool m_owned;
friend class WXDLLIMPEXP_BASE wxString;
};
// ----------------------------------------------------------------------------
// wxStringPrintfMixin
// ---------------------------------------------------------------------------
// NB: VC6 has a bug that causes linker errors if you have template methods
// in a class using __declspec(dllimport). The solution is to split such
// class into two classes, one that contains the template methods and does
// *not* use WXDLLIMPEXP_BASE and another class that contains the rest
// (with DLL linkage).
//
// We only do this for VC6 here, because the code is less efficient
// (Printf() has to use dynamic_cast<>) and because OpenWatcom compiler
// cannot compile this code.
#if defined(__VISUALC__) && __VISUALC__ < 1300
#define wxNEEDS_WXSTRING_PRINTF_MIXIN
#endif
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
// this class contains implementation of wxString's vararg methods, it's
// exported from wxBase DLL
class WXDLLIMPEXP_BASE wxStringPrintfMixinBase
{
protected:
wxStringPrintfMixinBase() {}
int DoPrintf(const wxChar *format, ...) ATTRIBUTE_PRINTF_2;
static wxString DoFormat(const wxChar *format, ...) ATTRIBUTE_PRINTF_1;
};
// this class contains template wrappers for wxString's vararg methods, it's
// intentionally *not* exported from the DLL in order to fix the VC6 bug
// described above
class wxStringPrintfMixin : public wxStringPrintfMixinBase
{
private:
// to further complicate things, we can't return wxString from
// wxStringPrintfMixin::Format() because wxString is not yet declared at
// this point; the solution is to use this fake type trait template - this
// way the compiler won't know the return type until Format() is used
// (this doesn't compile with Watcom, but VC6 compiles it just fine):
template<typename T> struct StringReturnType
{
typedef wxString type;
};
public:
// these are duplicated wxString methods, they're also declared below
// if !wxNEEDS_WXSTRING_PRINTF_MIXIN:
// int Printf(const wxChar *pszFormat, ...);
WX_DEFINE_VARARG_FUNC(int, Printf, DoPrintf)
// static wxString Format(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_1;
WX_DEFINE_VARARG_FUNC(static typename StringReturnType<T1>::type,
Format, DoFormat)
// int sprintf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, sprintf, DoPrintf)
protected:
wxStringPrintfMixin() : wxStringPrintfMixinBase() {}
};
#endif // wxNEEDS_WXSTRING_PRINTF_MIXIN
// ----------------------------------------------------------------------------
// wxString: string class trying to be compatible with std::string, MFC
// CString and wxWindows 1.x wxString all at once
// ---------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxString : public wxStringBase
{
#if !wxUSE_STL
friend class WXDLLIMPEXP_BASE wxArrayString;
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
// "non dll-interface class 'wxStringPrintfMixin' used as base interface
// for dll-interface class 'wxString'" -- this is OK in our case
#pragma warning (disable:4275)
#endif
class WXDLLIMPEXP_BASE wxString : public wxStringBase
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
,public wxStringPrintfMixin
#endif
{
// NB: special care was taken in arranging the member functions in such order
// that all inline functions can be effectively inlined, verify that all
// performance critical functions are still inlined if you change order!
@ -689,9 +916,21 @@ public:
wxString(const wxStringBase& stringSrc) : wxStringBase(stringSrc) { }
wxString(const wxString& stringSrc) : wxStringBase(stringSrc) { }
// string containing nRepeat copies of ch
wxString(wxChar ch, size_t nRepeat = 1)
wxString(wxUniChar ch, size_t nRepeat = 1)
: wxStringBase(nRepeat, ch) { }
wxString(size_t nRepeat, wxChar ch)
wxString(size_t nRepeat, wxUniChar ch)
: wxStringBase(nRepeat, ch) { }
wxString(wxUniCharRef ch, size_t nRepeat = 1)
: wxStringBase(nRepeat, ch) { }
wxString(size_t nRepeat, wxUniCharRef ch)
: wxStringBase(nRepeat, ch) { }
wxString(char ch, size_t nRepeat = 1)
: wxStringBase(nRepeat, ch) { }
wxString(size_t nRepeat, char ch)
: wxStringBase(nRepeat, ch) { }
wxString(wchar_t ch, size_t nRepeat = 1)
: wxStringBase(nRepeat, ch) { }
wxString(size_t nRepeat, wchar_t ch)
: wxStringBase(nRepeat, ch) { }
// ctor takes first nLength characters from C string
// (default value of npos means take all the string)
@ -775,17 +1014,17 @@ public:
// data access (all indexes are 0 based)
// read access
wxChar GetChar(size_t n) const
wxUniChar GetChar(size_t n) const
{ return at(n); }
// read/write access
wxChar& GetWritableChar(size_t n)
wxUniCharRef GetWritableChar(size_t n)
{ return at(n); }
// write access
void SetChar(size_t n, wxChar ch)
void SetChar(size_t n, wxUniChar ch)
{ at(n) = ch; }
// get last character
wxChar Last() const
wxUniChar Last() const
{
wxASSERT_MSG( !empty(), _T("wxString: index out of bounds") );
@ -793,7 +1032,7 @@ public:
}
// get writable last character
wxChar& Last()
wxUniCharRef Last()
{
wxASSERT_MSG( !empty(), _T("wxString: index out of bounds") );
return at(length() - 1);
@ -801,42 +1040,40 @@ public:
/*
Note that we we must define all of the overloads below to avoid
ambiguity when using str[0]. Also note that for a conforming compiler we
don't need const version of operatorp[] at all as indexed access to
const string is provided by implicit conversion to "const wxChar *"
below and defining them would only result in ambiguities, but some other
compilers refuse to compile "str[0]" without them.
ambiguity when using str[0].
*/
#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__MWERKS__)
wxChar operator[](int n) const
wxUniChar operator[](int n) const
{ return wxStringBase::at(n); }
wxChar operator[](size_type n) const
wxUniChar operator[](size_t n) const
{ return wxStringBase::at(n); }
#ifndef wxSIZE_T_IS_UINT
wxChar operator[](unsigned int n) const
wxUniChar operator[](unsigned int n) const
{ return wxStringBase::at(n); }
#endif // size_t != unsigned int
#endif // broken compiler
// operator versions of GetWriteableChar()
wxChar& operator[](int n)
wxUniCharRef operator[](int n)
{ return wxStringBase::at(n); }
wxChar& operator[](size_type n)
wxUniCharRef operator[](size_t n)
{ return wxStringBase::at(n); }
#ifndef wxSIZE_T_IS_UINT
wxChar& operator[](unsigned int n)
wxUniCharRef operator[](unsigned int n)
{ return wxStringBase::at(n); }
#endif // size_t != unsigned int
// explicit conversion to C string (use this with printf()!)
wxCStrData c_str() const { return wxCStrData(this); }
// implicit conversion to C string
operator wxCStrData() const { return c_str(); }
operator const wxChar*() const { return c_str(); }
// identical to c_str(), for wxWin 1.6x compatibility
const wxChar* wx_str() const { return c_str(); }
// identical to c_str(), for MFC compatibility
const wxChar* GetData() const { return c_str(); }
const wxCStrData GetData() const { return c_str(); }
// explicit conversion to C string in internal representation (char*,
// wchar_t*, UTF-8-encoded char*, depending on the build):
const_pointer wx_str() const { return data(); }
// conversion to/from plain (i.e. 7 bit) ASCII: this is useful for
// converting numbers or strings which are certain not to contain special
@ -901,8 +1138,14 @@ public:
wxString& operator=(const wxStringBase& stringSrc)
{ return (wxString&)wxStringBase::operator=(stringSrc); }
// from a character
wxString& operator=(wxChar ch)
wxString& operator=(wxUniChar ch)
{ return (wxString&)wxStringBase::operator=(ch); }
wxString& operator=(wxUniCharRef ch)
{ return (wxString&)wxStringBase::operator=((wxUniChar)ch); }
wxString& operator=(char ch)
{ return (wxString&)wxStringBase::operator=(wxUniChar(ch)); }
wxString& operator=(wchar_t ch)
{ return (wxString&)wxStringBase::operator=(wxUniChar(ch)); }
// from a C string - STL probably will crash on NULL,
// so we need to compensate in that case
#if wxUSE_STL
@ -952,9 +1195,14 @@ public:
}
// string += C string
wxString& operator<<(const wxChar *psz)
{ append(psz); return *this; }
wxString& operator<<(const wxCStrData& psz)
{ append(psz); return *this; }
// string += char
wxString& operator<<(wxChar ch) { append(1, ch); return *this; }
wxString& operator<<(wxUniChar ch) { append(1, ch); return *this; }
wxString& operator<<(wxUniCharRef ch) { append(1, ch); return *this; }
wxString& operator<<(char ch) { append(1, ch); return *this; }
wxString& operator<<(wchar_t ch) { append(1, ch); return *this; }
// string += buffer (i.e. from wxGetString)
#if wxUSE_UNICODE
@ -987,10 +1235,18 @@ public:
append(s);
return *this;
}
wxString& Append(const wxCStrData& psz)
{ append(psz); return *this; }
wxString& Append(const wxChar* psz)
{ append(psz); return *this; }
// append count copies of given character
wxString& Append(wxChar ch, size_t count = 1u)
wxString& Append(wxUniChar ch, size_t count = 1u)
{ append(count, ch); return *this; }
wxString& Append(wxUniCharRef ch, size_t count = 1u)
{ append(count, ch); return *this; }
wxString& Append(char ch, size_t count = 1u)
{ append(count, ch); return *this; }
wxString& Append(wchar_t ch, size_t count = 1u)
{ append(count, ch); return *this; }
wxString& Append(const wxChar* psz, size_t nLen)
{ append(psz, nLen); return *this; }
@ -1004,9 +1260,9 @@ public:
friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string1,
const wxString& string2);
// string with a single char
friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxChar ch);
friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxUniChar ch);
// char with a string
friend wxString WXDLLIMPEXP_BASE operator+(wxChar ch, const wxString& string);
friend wxString WXDLLIMPEXP_BASE operator+(wxUniChar ch, const wxString& string);
// string with C string
friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string,
const wxChar *psz);
@ -1060,7 +1316,7 @@ public:
bool IsSameAs(const wxChar *psz, bool compareWithCase = true) const
{ return (compareWithCase ? Cmp(psz) : CmpNoCase(psz)) == 0; }
// comparison with a single character: returns true if equal
bool IsSameAs(wxChar c, bool compareWithCase = true) const
bool IsSameAs(wxUniChar c, bool compareWithCase = true) const
{
return (length() == 1) && (compareWithCase ? GetChar(0u) == c
: wxToupper(GetChar(0u)) == wxToupper(c));
@ -1090,20 +1346,20 @@ public:
wxString Right(size_t nCount) const;
// get all characters before the first occurance of ch
// (returns the whole string if ch not found)
wxString BeforeFirst(wxChar ch) const;
wxString BeforeFirst(wxUniChar ch) const;
// get all characters before the last occurence of ch
// (returns empty string if ch not found)
wxString BeforeLast(wxChar ch) const;
wxString BeforeLast(wxUniChar ch) const;
// get all characters after the first occurence of ch
// (returns empty string if ch not found)
wxString AfterFirst(wxChar ch) const;
wxString AfterFirst(wxUniChar ch) const;
// get all characters after the last occurence of ch
// (returns the whole string if ch not found)
wxString AfterLast(wxChar ch) const;
wxString AfterLast(wxUniChar ch) const;
// for compatibility only, use more explicitly named functions above
wxString Before(wxChar ch) const { return BeforeLast(ch); }
wxString After(wxChar ch) const { return AfterFirst(ch); }
wxString Before(wxUniChar ch) const { return BeforeLast(ch); }
wxString After(wxUniChar ch) const { return AfterFirst(ch); }
// case conversion
// convert to upper case in place, return the string itself
@ -1120,11 +1376,11 @@ public:
// remove spaces from left or from right (default) side
wxString& Trim(bool bFromRight = true);
// add nCount copies chPad in the beginning or at the end (default)
wxString& Pad(size_t nCount, wxChar chPad = wxT(' '), bool bFromRight = true);
wxString& Pad(size_t nCount, wxUniChar chPad = wxT(' '), bool bFromRight = true);
// searching and replacing
// searching (return starting index, or -1 if not found)
int Find(wxChar ch, bool bFromEnd = false) const; // like strchr/strrchr
int Find(wxUniChar ch, bool bFromEnd = false) const; // like strchr/strrchr
// searching (return starting index, or -1 if not found)
int Find(const wxChar *pszSub) const; // like strstr
// replace first (or all of bReplaceAll) occurences of substring with
@ -1155,18 +1411,23 @@ public:
bool ToDouble(double *val) const;
#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
// formatted input/output
// as sprintf(), returns the number of characters written or < 0 on error
// (take 'this' into account in attribute parameter count)
int Printf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2;
// int Printf(const wxChar *pszFormat, ...);
WX_DEFINE_VARARG_FUNC(int, Printf, DoPrintf)
#endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN
// as vprintf(), returns the number of characters written or < 0 on error
int PrintfV(const wxChar* pszFormat, va_list argptr);
int PrintfV(const wxString& format, va_list argptr);
#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
// returns the string containing the result of Printf() to it
static wxString Format(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_1;
// static wxString Format(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_1;
WX_DEFINE_VARARG_FUNC(static wxString, Format, DoFormat)
#endif
// the same as above, but takes a va_list
static wxString FormatV(const wxChar *pszFormat, va_list argptr);
static wxString FormatV(const wxString& format, va_list argptr);
// raw access to string memory
// ensure that string has space for at least nLen characters
@ -1196,9 +1457,12 @@ public:
// values for first parameter of Strip function
enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
// use Printf()
// (take 'this' into account in attribute parameter count)
int sprintf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2;
// int sprintf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, sprintf, DoPrintf)
#endif // wxNEEDS_WXSTRING_PRINTF_MIXIN
// use Cmp()
inline int CompareTo(const wxChar* psz, caseCompare cmp = exact) const
@ -1207,7 +1471,7 @@ public:
// use Len
size_t Length() const { return length(); }
// Count the number of characters
int Freq(wxChar ch) const;
int Freq(wxUniChar ch) const;
// use MakeLower
void LowerCase() { MakeLower(); }
// use MakeUpper
@ -1217,7 +1481,7 @@ public:
// use Find (more general variants not yet supported)
size_t Index(const wxChar* psz) const { return Find(psz); }
size_t Index(wxChar ch) const { return Find(ch); }
size_t Index(wxUniChar ch) const { return Find(ch); }
// use Truncate
wxString& Remove(size_t pos) { return Truncate(pos); }
wxString& RemoveLast(size_t n = 1) { return Truncate(length() - n); }
@ -1226,10 +1490,12 @@ public:
{ return (wxString&)erase( nStart, nLen ); }
// use Find()
int First( const wxChar ch ) const { return Find(ch); }
int First( const wxUniChar ch ) const { return Find(ch); }
int First( char ch ) const { return Find(ch); }
int First( wchar_t ch ) const { return Find(ch); }
int First( const wxChar* psz ) const { return Find(psz); }
int First( const wxString &str ) const { return Find(str); }
int Last( const wxChar ch ) const { return Find(ch, true); }
int Last( const wxUniChar ch ) const { return Find(ch, true); }
bool Contains(const wxString& str) const { return Find(str) != wxNOT_FOUND; }
// use empty()
@ -1243,10 +1509,10 @@ public:
// take all characters from pStart to pEnd
wxString(const void *pStart, const void *pEnd)
: wxStringBase((const wxChar*)pStart, (const wxChar*)pEnd) { }
#if wxUSE_STL
wxString(const_iterator first, const_iterator last)
: wxStringBase(first, last) { }
#endif
wxString(iterator first, iterator last)
: wxStringBase(first, last) { }
// lib.string.modifiers
// append elements str[pos], ..., str[pos+n]
@ -1255,13 +1521,15 @@ public:
// append a string
wxString& append(const wxString& str)
{ return (wxString&)wxStringBase::append(str); }
wxString& append(const wxCStrData& str)
{ return (wxString&)wxStringBase::append(str.AsString()); }
// append first n (or all if n == npos) characters of sz
wxString& append(const wxChar *sz)
{ return (wxString&)wxStringBase::append(sz); }
wxString& append(const wxChar *sz, size_t n)
{ return (wxString&)wxStringBase::append(sz, n); }
// append n copies of ch
wxString& append(size_t n, wxChar ch)
wxString& append(size_t n, wxUniChar ch)
{ return (wxString&)wxStringBase::append(n, ch); }
// append from first to last
wxString& append(const_iterator first, const_iterator last)
@ -1279,7 +1547,7 @@ public:
wxString& assign(const wxChar *sz, size_t n)
{ return (wxString&)wxStringBase::assign(sz, n); }
// same as `= n copies of ch'
wxString& assign(size_t n, wxChar ch)
wxString& assign(size_t n, wxUniChar ch)
{ return (wxString&)wxStringBase::assign(n, ch); }
// assign from first to last
wxString& assign(const_iterator first, const_iterator last)
@ -1312,13 +1580,13 @@ public:
wxString& insert(size_t nPos, const wxChar *sz, size_t n)
{ return (wxString&)wxStringBase::insert(nPos, sz, n); }
// insert n copies of ch
wxString& insert(size_t nPos, size_t n, wxChar ch)
wxString& insert(size_t nPos, size_t n, wxUniChar ch)
{ return (wxString&)wxStringBase::insert(nPos, n, ch); }
iterator insert(iterator it, wxChar ch)
iterator insert(iterator it, wxUniChar ch)
{ return wxStringBase::insert(it, ch); }
void insert(iterator it, const_iterator first, const_iterator last)
{ wxStringBase::insert(it, first, last); }
void insert(iterator it, size_type n, wxChar ch)
void insert(iterator it, size_type n, wxUniChar ch)
{ wxStringBase::insert(it, n, ch); }
// delete characters from nStart to nStart + nLen
@ -1340,7 +1608,7 @@ public:
wxString& replace(size_t nStart, size_t nLen, const wxString& str)
{ return (wxString&)wxStringBase::replace(nStart, nLen, str); }
// replaces the substring with nCount copies of ch
wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch)
wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxUniChar ch)
{ return (wxString&)wxStringBase::replace(nStart, nLen, nCount, ch); }
// replaces a substring with another substring
wxString& replace(size_t nStart, size_t nLen,
@ -1358,7 +1626,7 @@ public:
{ return (wxString&)wxStringBase::replace(first, last, s, n); }
wxString& replace(iterator first, iterator last, const wxString& s)
{ return (wxString&)wxStringBase::replace(first, last, s); }
wxString& replace(iterator first, iterator last, size_type n, wxChar c)
wxString& replace(iterator first, iterator last, size_type n, wxUniChar c)
{ return (wxString&)wxStringBase::replace(first, last, n, c); }
wxString& replace(iterator first, iterator last,
const_iterator first1, const_iterator last1)
@ -1370,9 +1638,14 @@ public:
// string += C string
wxString& operator+=(const wxChar *psz)
{ return (wxString&)wxStringBase::operator+=(psz); }
wxString& operator+=(const wxCStrData& s)
{ return (wxString&)wxStringBase::operator+=(s.AsString()); }
// string += char
wxString& operator+=(wxChar ch)
wxString& operator+=(wxUniChar ch)
{ return (wxString&)wxStringBase::operator+=(ch); }
wxString& operator+=(wxUniCharRef ch) { return *this += wxUniChar(ch); }
wxString& operator+=(char ch) { return *this += wxUniChar(ch); }
wxString& operator+=(wchar_t ch) { return *this += wxUniChar(ch); }
private:
#if !wxUSE_STL
@ -1384,18 +1657,41 @@ private:
friend class WXDLLIMPEXP_BASE wxStringBuffer;
friend class WXDLLIMPEXP_BASE wxStringBufferLength;
#endif
#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
int DoPrintf(const wxChar *format, ...) ATTRIBUTE_PRINTF_2;
static wxString DoFormat(const wxChar *format, ...) ATTRIBUTE_PRINTF_1;
#endif
};
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
#pragma warning (default:4275)
#endif
// notice that even though for many compilers the friend declarations above are
// enough, from the point of view of C++ standard we must have the declarations
// here as friend ones are not injected in the enclosing namespace and without
// them the code fails to compile with conforming compilers such as xlC or g++4
wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2);
wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxChar ch);
wxString WXDLLIMPEXP_BASE operator+(wxChar ch, const wxString& string);
wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2);
wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const wxChar *psz);
wxString WXDLLIMPEXP_BASE operator+(const wxChar *psz, const wxString& string);
wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxUniChar ch);
wxString WXDLLIMPEXP_BASE operator+(wxUniChar ch, const wxString& string);
inline wxString operator+(const wxString& string, wxUniCharRef ch)
{ return string + (wxUniChar)ch; }
inline wxString operator+(const wxString& string, char ch)
{ return string + wxUniChar(ch); }
inline wxString operator+(const wxString& string, wchar_t ch)
{ return string + wxUniChar(ch); }
inline wxString operator+(wxUniCharRef ch, const wxString& string)
{ return (wxUniChar)ch + string; }
inline wxString operator+(char ch, const wxString& string)
{ return wxUniChar(ch) + string; }
inline wxString operator+(wchar_t ch, const wxString& string)
{ return wxUniChar(ch) + string; }
#if wxUSE_STL
// return an empty wxString (not very useful with wxUSE_STL == 1)
@ -1597,10 +1893,24 @@ inline wxString operator+(const wxCharBuffer& buf, const wxString& string)
// comparison with char (those are not defined by std::[w]string and so should
// be always available)
inline bool operator==(wxChar c, const wxString& s) { return s.IsSameAs(c); }
inline bool operator==(const wxString& s, wxChar c) { return s.IsSameAs(c); }
inline bool operator!=(wxChar c, const wxString& s) { return !s.IsSameAs(c); }
inline bool operator!=(const wxString& s, wxChar c) { return !s.IsSameAs(c); }
inline bool operator==(const wxUniChar& c, const wxString& s) { return s.IsSameAs(c); }
inline bool operator==(const wxUniCharRef& c, const wxString& s) { return s.IsSameAs(c); }
inline bool operator==(char c, const wxString& s) { return s.IsSameAs(c); }
inline bool operator==(wchar_t c, const wxString& s) { return s.IsSameAs(c); }
inline bool operator==(int c, const wxString& s) { return s.IsSameAs(c); }
inline bool operator==(const wxString& s, const wxUniChar& c) { return s.IsSameAs(c); }
inline bool operator==(const wxString& s, const wxUniCharRef& c) { return s.IsSameAs(c); }
inline bool operator==(const wxString& s, char c) { return s.IsSameAs(c); }
inline bool operator==(const wxString& s, wchar_t c) { return s.IsSameAs(c); }
inline bool operator!=(const wxUniChar& c, const wxString& s) { return !s.IsSameAs(c); }
inline bool operator!=(const wxUniCharRef& c, const wxString& s) { return !s.IsSameAs(c); }
inline bool operator!=(char c, const wxString& s) { return !s.IsSameAs(c); }
inline bool operator!=(wchar_t c, const wxString& s) { return !s.IsSameAs(c); }
inline bool operator!=(int c, const wxString& s) { return !s.IsSameAs(c); }
inline bool operator!=(const wxString& s, const wxUniChar& c) { return !s.IsSameAs(c); }
inline bool operator!=(const wxString& s, const wxUniCharRef& c) { return !s.IsSameAs(c); }
inline bool operator!=(const wxString& s, char c) { return !s.IsSameAs(c); }
inline bool operator!=(const wxString& s, wchar_t c) { return !s.IsSameAs(c); }
// comparison with C string in Unicode build
#if wxUSE_UNICODE
@ -1642,7 +1952,58 @@ inline bool operator>=(const char* s1, const wxString& s2)
#include "wx/iosfwrap.h"
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCStrData&);
#endif // wxSTD_STRING_COMPATIBILITY
// ---------------------------------------------------------------------------
// wxCStrData implementation
// ---------------------------------------------------------------------------
inline wxCStrData::wxCStrData(char *buf)
: m_str(new wxString(buf)), m_offset(0), m_owned(true) {}
inline wxCStrData::wxCStrData(wchar_t *buf)
: m_str(new wxString(buf)), m_offset(0), m_owned(true) {}
inline wxCStrData::~wxCStrData()
{
if ( m_owned )
delete m_str;
}
#if wxUSE_UNICODE
inline const wchar_t* wxCStrData::AsWChar() const
#else
inline const char* wxCStrData::AsChar() const
#endif
{
if ( m_offset == 0 )
return m_str->wx_str(); // FIXME
else
return (const wxChar*)(m_str->begin() + m_offset);
}
inline wxString wxCStrData::AsString() const
{
if ( m_offset == 0 )
return *m_str;
else
return m_str->Mid(m_offset);
}
inline wxCStrData::operator wxString() const { return AsString(); }
inline wxUniChar wxCStrData::operator*() const
{
if ( m_str->empty() )
return wxUniChar(_T('\0'));
else
return (*m_str)[m_offset];
}
inline wxUniChar wxCStrData::operator[](size_t n) const
{
return m_str->at(m_offset + n);
}
#endif // _WX_WXSTRINGH__

326
include/wx/strvararg.h Normal file
View File

@ -0,0 +1,326 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/strvararg.h
// Purpose: macros for implementing type-safe vararg passing of strings
// Author: Vaclav Slavik
// Created: 2007-02-19
// RCS-ID: $Id$
// Copyright: (c) 2007 REA Elektronik GmbH
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STRVARARG_H_
#define _WX_STRVARARG_H_
#include "wx/platform.h"
#if wxONLY_WATCOM_EARLIER_THAN(1,4)
#error "OpenWatcom version >= 1.4 is required to compile this code"
#endif
// include wchar_t definition if needed:
#if defined(__WATCOMC__)
#include <inttypes.h>
#elif defined(__VISUALC__)
#include <stdlib.h>
#endif
class WXDLLIMPEXP_BASE wxCStrData;
class WXDLLIMPEXP_BASE wxString;
class WXDLLIMPEXP_BASE wxCharBuffer;
class WXDLLIMPEXP_BASE wxWCharBuffer;
// ----------------------------------------------------------------------------
// WX_DEFINE_VARARG_FUNC* macros
// ----------------------------------------------------------------------------
// This macro is used to implement type-safe wrappers for variadic functions
// that accept strings as arguments. This makes it possible to pass char*,
// wchar_t* or even wxString (as opposed to having to use wxString::c_str())
// to e.g. wxPrintf().
//
// This is done by defining a set of N template function taking 1..N arguments
// (currently, N is set to 30 in this header). These functions are just thin
// wrappers around another variadic function (@a impl) and the only thing
// the wrapper does is that it normalizes the arguments passed in so that
// they are of the type expected by variadic functions taking string
// arguments, i.e., char* or wchar_t*, depending on the build:
// * char* in the current locale's charset in ANSI build
// * whchar_t* in the Unicode build
//
// Parameters:
// rettype Functions' return type.
// name Name of the function.
// impl Name of the variadic function that implements 'name'.
#define WX_DEFINE_VARARG_FUNC(rettype, name, impl) \
_WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
_WX_VARARG_DEFINE_FUNC, \
rettype, name, impl)
// Like WX_DEFINE_VARARG_FUNC, but for variadic functions that don't return
// a value.
#define WX_DEFINE_VARARG_FUNC_VOID(name, impl) \
_WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
_WX_VARARG_DEFINE_FUNC_VOID, \
void, name, impl)
// Like WX_DEFINE_VARARG_FUNC_VOID, but instead of wrapping an implementation
// function, does nothing in defined functions' bodies.
//
// Used to implement wxLogXXX functions if wxUSE_LOG=0.
#define WX_DEFINE_VARARG_FUNC_NOP(name) \
_WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
_WX_VARARG_DEFINE_FUNC_NOP, \
void, name, dummy)
// ----------------------------------------------------------------------------
// implementation
// ----------------------------------------------------------------------------
// Converts an argument passed to wxPrint etc. into standard form expected,
// by wxXXX functions, e.g. all strings (wxString, char*, wchar_t*) are
// converted into wchar_t* or char* depending on the build.
template<typename T>
struct wxArgNormalizer
{
wxArgNormalizer(const T& value) : m_value(value) {}
// Returns the value in a form that can be safely passed to real vararg
// functions. In case of strings, this is char* in ANSI build and wchar_t*
// in Unicode build.
const T& get() const { return m_value; }
const T& m_value;
};
// special cases for converting strings:
// FIXME-UTF8: move this to wxchartype.h!
#if wxUSE_UNICODE
/* for now, all Unicode builds are wchar_t* based: */
#define wxUSE_UNICODE_WCHAR 1
#else
#define wxUSE_UNICODE_WCHAR 0
#endif
// FIXME-UTF8: include wx/wxchartype.h and use wxChar after headers split
// FIXME-UTF8: this will be char* in UTF-8 build and wchar_t* on Windows
#if wxUSE_UNICODE_WCHAR
typedef wchar_t wxArgNativeCharType;
#else
typedef char wxArgNativeCharType;
#endif
template<>
struct WXDLLIMPEXP_BASE wxArgNormalizer<const wxCStrData&>
{
wxArgNormalizer(const wxCStrData& value) : m_value(value) {}
const wxArgNativeCharType *get() const;
const wxCStrData& m_value;
};
template<>
struct wxArgNormalizer<wxCStrData> : public wxArgNormalizer<const wxCStrData&>
{
wxArgNormalizer(const wxCStrData& value)
: wxArgNormalizer<const wxCStrData&>(value) {}
};
template<>
struct WXDLLIMPEXP_BASE wxArgNormalizer<const wxString&>
{
wxArgNormalizer(const wxString& value) : m_value(value) {}
const wxArgNativeCharType *get() const;
const wxString& m_value;
};
template<>
struct wxArgNormalizer<wxString> : public wxArgNormalizer<const wxString&>
{
wxArgNormalizer(const wxString& value)
: wxArgNormalizer<const wxString&>(value) {}
};
#if wxUSE_UNICODE_WCHAR
template<>
struct WXDLLIMPEXP_BASE wxArgNormalizer<const char*>
{
wxArgNormalizer(const char *value);
~wxArgNormalizer();
const wchar_t *get() const;
wxWCharBuffer *m_value;
};
template<>
struct wxArgNormalizer<char*> : public wxArgNormalizer<const char*>
{
wxArgNormalizer(char *value)
: wxArgNormalizer<const char*>(value) {}
};
#elif wxUSE_WCHAR_T // !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
template<>
struct WXDLLIMPEXP_BASE wxArgNormalizer<const wchar_t*>
{
wxArgNormalizer(const wchar_t *value);
~wxArgNormalizer();
const char *get() const;
wxCharBuffer *m_value;
};
template<>
struct wxArgNormalizer<wchar_t*> : public wxArgNormalizer<const wchar_t*>
{
wxArgNormalizer(wchar_t *value)
: wxArgNormalizer<const wchar_t*>(value) {}
};
#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
// NB: The vararg emulation code is limited to 30 arguments at the moment.
// If you need more, you need to
// 1) increase the value of _WX_VARARG_MAX_ARGS
// 2) add _WX_VARARG_JOIN_* and _WX_VARARG_ITER_* up to the new
// _WX_VARARG_MAX_ARGS value to the lists below
#define _WX_VARARG_MAX_ARGS 30
#define _WX_VARARG_JOIN_1(m) m(1)
#define _WX_VARARG_JOIN_2(m) _WX_VARARG_JOIN_1(m), m(2)
#define _WX_VARARG_JOIN_3(m) _WX_VARARG_JOIN_2(m), m(3)
#define _WX_VARARG_JOIN_4(m) _WX_VARARG_JOIN_3(m), m(4)
#define _WX_VARARG_JOIN_5(m) _WX_VARARG_JOIN_4(m), m(5)
#define _WX_VARARG_JOIN_6(m) _WX_VARARG_JOIN_5(m), m(6)
#define _WX_VARARG_JOIN_7(m) _WX_VARARG_JOIN_6(m), m(7)
#define _WX_VARARG_JOIN_8(m) _WX_VARARG_JOIN_7(m), m(8)
#define _WX_VARARG_JOIN_9(m) _WX_VARARG_JOIN_8(m), m(9)
#define _WX_VARARG_JOIN_10(m) _WX_VARARG_JOIN_9(m), m(10)
#define _WX_VARARG_JOIN_11(m) _WX_VARARG_JOIN_10(m), m(11)
#define _WX_VARARG_JOIN_12(m) _WX_VARARG_JOIN_11(m), m(12)
#define _WX_VARARG_JOIN_13(m) _WX_VARARG_JOIN_12(m), m(13)
#define _WX_VARARG_JOIN_14(m) _WX_VARARG_JOIN_13(m), m(14)
#define _WX_VARARG_JOIN_15(m) _WX_VARARG_JOIN_14(m), m(15)
#define _WX_VARARG_JOIN_16(m) _WX_VARARG_JOIN_15(m), m(16)
#define _WX_VARARG_JOIN_17(m) _WX_VARARG_JOIN_16(m), m(17)
#define _WX_VARARG_JOIN_18(m) _WX_VARARG_JOIN_17(m), m(18)
#define _WX_VARARG_JOIN_19(m) _WX_VARARG_JOIN_18(m), m(19)
#define _WX_VARARG_JOIN_20(m) _WX_VARARG_JOIN_19(m), m(20)
#define _WX_VARARG_JOIN_21(m) _WX_VARARG_JOIN_20(m), m(21)
#define _WX_VARARG_JOIN_22(m) _WX_VARARG_JOIN_21(m), m(22)
#define _WX_VARARG_JOIN_23(m) _WX_VARARG_JOIN_22(m), m(23)
#define _WX_VARARG_JOIN_24(m) _WX_VARARG_JOIN_23(m), m(24)
#define _WX_VARARG_JOIN_25(m) _WX_VARARG_JOIN_24(m), m(25)
#define _WX_VARARG_JOIN_26(m) _WX_VARARG_JOIN_25(m), m(26)
#define _WX_VARARG_JOIN_27(m) _WX_VARARG_JOIN_26(m), m(27)
#define _WX_VARARG_JOIN_28(m) _WX_VARARG_JOIN_27(m), m(28)
#define _WX_VARARG_JOIN_29(m) _WX_VARARG_JOIN_28(m), m(29)
#define _WX_VARARG_JOIN_30(m) _WX_VARARG_JOIN_29(m), m(30)
#define _WX_VARARG_ITER_1(m,a,b,c) m(1,a,b,c)
#define _WX_VARARG_ITER_2(m,a,b,c) _WX_VARARG_ITER_1(m,a,b,c) m(2,a,b,c)
#define _WX_VARARG_ITER_3(m,a,b,c) _WX_VARARG_ITER_2(m,a,b,c) m(3,a,b,c)
#define _WX_VARARG_ITER_4(m,a,b,c) _WX_VARARG_ITER_3(m,a,b,c) m(4,a,b,c)
#define _WX_VARARG_ITER_5(m,a,b,c) _WX_VARARG_ITER_4(m,a,b,c) m(5,a,b,c)
#define _WX_VARARG_ITER_6(m,a,b,c) _WX_VARARG_ITER_5(m,a,b,c) m(6,a,b,c)
#define _WX_VARARG_ITER_7(m,a,b,c) _WX_VARARG_ITER_6(m,a,b,c) m(7,a,b,c)
#define _WX_VARARG_ITER_8(m,a,b,c) _WX_VARARG_ITER_7(m,a,b,c) m(8,a,b,c)
#define _WX_VARARG_ITER_9(m,a,b,c) _WX_VARARG_ITER_8(m,a,b,c) m(9,a,b,c)
#define _WX_VARARG_ITER_10(m,a,b,c) _WX_VARARG_ITER_9(m,a,b,c) m(10,a,b,c)
#define _WX_VARARG_ITER_11(m,a,b,c) _WX_VARARG_ITER_10(m,a,b,c) m(11,a,b,c)
#define _WX_VARARG_ITER_12(m,a,b,c) _WX_VARARG_ITER_11(m,a,b,c) m(12,a,b,c)
#define _WX_VARARG_ITER_13(m,a,b,c) _WX_VARARG_ITER_12(m,a,b,c) m(13,a,b,c)
#define _WX_VARARG_ITER_14(m,a,b,c) _WX_VARARG_ITER_13(m,a,b,c) m(14,a,b,c)
#define _WX_VARARG_ITER_15(m,a,b,c) _WX_VARARG_ITER_14(m,a,b,c) m(15,a,b,c)
#define _WX_VARARG_ITER_16(m,a,b,c) _WX_VARARG_ITER_15(m,a,b,c) m(16,a,b,c)
#define _WX_VARARG_ITER_17(m,a,b,c) _WX_VARARG_ITER_16(m,a,b,c) m(17,a,b,c)
#define _WX_VARARG_ITER_18(m,a,b,c) _WX_VARARG_ITER_17(m,a,b,c) m(18,a,b,c)
#define _WX_VARARG_ITER_19(m,a,b,c) _WX_VARARG_ITER_18(m,a,b,c) m(19,a,b,c)
#define _WX_VARARG_ITER_20(m,a,b,c) _WX_VARARG_ITER_19(m,a,b,c) m(20,a,b,c)
#define _WX_VARARG_ITER_21(m,a,b,c) _WX_VARARG_ITER_20(m,a,b,c) m(21,a,b,c)
#define _WX_VARARG_ITER_22(m,a,b,c) _WX_VARARG_ITER_21(m,a,b,c) m(22,a,b,c)
#define _WX_VARARG_ITER_23(m,a,b,c) _WX_VARARG_ITER_22(m,a,b,c) m(23,a,b,c)
#define _WX_VARARG_ITER_24(m,a,b,c) _WX_VARARG_ITER_23(m,a,b,c) m(24,a,b,c)
#define _WX_VARARG_ITER_25(m,a,b,c) _WX_VARARG_ITER_24(m,a,b,c) m(25,a,b,c)
#define _WX_VARARG_ITER_26(m,a,b,c) _WX_VARARG_ITER_25(m,a,b,c) m(26,a,b,c)
#define _WX_VARARG_ITER_27(m,a,b,c) _WX_VARARG_ITER_26(m,a,b,c) m(27,a,b,c)
#define _WX_VARARG_ITER_28(m,a,b,c) _WX_VARARG_ITER_27(m,a,b,c) m(28,a,b,c)
#define _WX_VARARG_ITER_29(m,a,b,c) _WX_VARARG_ITER_28(m,a,b,c) m(29,a,b,c)
#define _WX_VARARG_ITER_30(m,a,b,c) _WX_VARARG_ITER_29(m,a,b,c) m(30,a,b,c)
// This macro calls another macro 'm' passed as second argument 'N' times,
// with its only argument set to 1..N, and concatenates the results using
// comma as separator.
//
// An example:
// #define foo(i) x##i
// // this expands to "x1,x2,x3,x4"
// _WX_VARARG_JOIN(4, foo)
//
//
// N must not be greater than _WX_VARARG_MAX_ARGS (=30).
#define _WX_VARARG_JOIN(N, m) _WX_VARARG_JOIN_IMPL(N, m)
#define _WX_VARARG_JOIN_IMPL(N, m) _WX_VARARG_JOIN_##N(m)
// This macro calls another macro 'm' passed as second argument 'N' times, with
// its first argument set to 1..N and the remaining arguments set to 'a', 'b'
// and 'c'. The results are separated with whitespace in the expansion.
//
// An example:
// // this macro expands to:
// // foo(1,a,b,c)
// // foo(2,a,b,c)
// // foo(3,a,b,c)
// _WX_VARARG_ITER(3, foo, a, b, c)
//
// N must not be greater than _WX_VARARG_MAX_ARGS (=30).
#define _WX_VARARG_ITER(N, m,a,b,c) _WX_VARARG_ITER_IMPL(N, m, a, b, c)
#define _WX_VARARG_ITER_IMPL(N, m,a,b,c) _WX_VARARG_ITER_##N(m, a, b, c)
// Generates code snippet for i-th argument in vararg function's prototype.
#define _WX_VARARG_ARG(i) T##i a##i
// Like _WX_VARARG_ARG_UNUSED, but outputs argument's type with WXUNUSED.
#define _WX_VARARG_ARG_UNUSED(i) T##i WXUNUSED(a##i)
// Generates code snippet for i-th type in vararg function's template<...>.
#define _WX_VARARG_TEMPL(i) typename T##i
// Generates code snippet for passing i-th argument of vararg function
// wrapper to its implementation, normalizing it in the process
#define _WX_VARARG_PASS(i) wxArgNormalizer<T##i>(a##i).get()
// Macro to be used with _WX_VARARG_ITER in the implementation of
// WX_DEFINE_VARARG_FUNC (see its documentation for the meaning of arguments)
#define _WX_VARARG_DEFINE_FUNC(N, rettype, name, impl) \
template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
rettype name(_WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
{ \
return impl(_WX_VARARG_JOIN(N, _WX_VARARG_PASS)); \
}
// Macro to be used with _WX_VARARG_ITER in the implementation of
// WX_DEFINE_VARARG_FUNC_VOID (see its documentation for the meaning of
// arguments; rettype is ignored and is used only to satisfy _WX_VARARG_ITER's
// requirements).
#define _WX_VARARG_DEFINE_FUNC_VOID(N, rettype, name, impl) \
template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
void name(_WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
{ \
impl(_WX_VARARG_JOIN(N, _WX_VARARG_PASS)); \
}
// Macro to be used with _WX_VARARG_ITER in the implementation of
// WX_DEFINE_VARARG_FUNC_NOP, i.e. empty stub for a disabled vararg function.
// The rettype and impl arguments are ignored.
#define _WX_VARARG_DEFINE_FUNC_NOP(N, rettype, name, impl) \
template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
void name(_WX_VARARG_JOIN(N, _WX_VARARG_ARG_UNUSED)) {}
#endif // _WX_STRVARARG_H_

View File

@ -116,9 +116,11 @@ protected:
static void Normalize(wxChar* uri, bool bIgnoreLeads = false);
static void UpTree(const wxChar* uristart, const wxChar*& uri);
static void UpTree(wxString::const_iterator uristart,
wxString::const_iterator& uri);
static wxChar TranslateEscape(const wxChar* s);
static void Escape (wxString& s, const wxChar& c);
static wxUniChar TranslateEscape(const wxString::const_iterator& s);
static void Escape(wxString& s, const wxChar& c);
static bool IsEscape(const wxChar*& uri);
static wxChar CharToHex(const wxChar& c);

View File

@ -18,6 +18,13 @@
#include "wx/platform.h"
#include "wx/dlimpexp.h"
#ifdef __cplusplus
#include "wx/strvararg.h"
#else
/* make the file compile without doing anything in C code: */
#define WX_DEFINE_VARARG_FUNC(rettype, name, impl)
#endif
#include <stdio.h> /* we use FILE below */
#if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
@ -115,6 +122,10 @@
#ifdef HAVE_WIDEC_H
#include <widec.h>
#endif
#if !defined(__GNUC__) || defined(__DARWIN__)
#define wxWINT_T_IS_TYPEDEF
#endif
#endif /* wxUSE_WCHAR_T */
/* ---------------------------------------------------------------------------- */
@ -212,13 +223,16 @@
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}Char, therefore we */
/* have to define wxChar conditionally depending on detected */
/* compiler & compiler version. */
/* 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;
@ -270,8 +284,8 @@
define wxFoo() function for each standard foo() function whose signature
(exceptionally including the return type) includes any mention of char:
wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
the same signature but with char replaced by wxChar which allows us to use
it in Unicode build as well
the same signature but with char replaced by wxChar which allows us to
use it in Unicode build as well
*/
#ifdef wxHAVE_TCHAR_SUPPORT
@ -300,8 +314,8 @@
There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
signed chars < 0, so "fix" it here.
*/
#define wxTolower(c) _totlower((wxUChar)(c))
#define wxToupper(c) _totupper((wxUChar)(c))
#define wxTolower(c) _totlower((wxUChar)(wxChar)(c))
#define wxToupper(c) _totupper((wxUChar)(wxChar)(c))
/* locale.h functons */
#define wxSetlocale _tsetlocale
@ -349,7 +363,7 @@
#endif
#define wxFputc _fputtc
#define wxFputchar _fputtchar
#define wxFprintf _ftprintf
WX_DEFINE_VARARG_FUNC(int, wxFprintf, _ftprintf)
#define wxFputs _fputts
#define wxFreopen _tfreopen
#define wxFscanf _ftscanf
@ -357,7 +371,7 @@
#define wxGetchar _gettchar
#define wxGets _getts
#define wxPerror _tperror
#define wxPrintf _tprintf
WX_DEFINE_VARARG_FUNC(int, wxPrintf, _tprintf)
#define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
#define wxPutchar _puttchar
#define wxPuts _putts
@ -365,13 +379,14 @@
#if defined(__DMC__)
#if wxUSE_UNICODE
/* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
int wxDoSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
WX_DEFINE_VARARG_FUNC(int, wxSprintf, wxDoSprintf)
#else
/* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
#define wxSprintf sprintf
WX_DEFINE_VARARG_FUNC(int, wxSprintf, sprintf)
#endif
#else
#define wxSprintf _stprintf
WX_DEFINE_VARARG_FUNC(int, wxSprintf, _stprintf)
#endif
#define wxSscanf _stscanf
@ -748,17 +763,17 @@
#define wxFputc fputc
#define wxFputs fputs
#define wxFputchar fputchar
#define wxFprintf fprintf
WX_DEFINE_VARARG_FUNC(int, wxFprintf, fprintf)
#define wxFscanf fscanf
#define wxGetc getc
#define wxGetchar getchar
#define wxGets gets
#define wxPrintf printf
WX_DEFINE_VARARG_FUNC(int, wxPrintf, printf)
#define wxPutc putc
#define wxPutchar putchar
#define wxPuts puts
#define wxScanf scanf
#define wxSprintf sprintf
WX_DEFINE_VARARG_FUNC(int, wxSprintf, sprintf)
#define wxSscanf sscanf
#define wxUngetc ungetc
#define wxVfprintf vfprintf
@ -943,7 +958,7 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
#if defined(__VISUALC__) || \
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
#define wxVsnprintf_ _vsntprintf
#define wxSnprintf_ _sntprintf
WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, _sntprintf)
#endif
#endif
@ -956,7 +971,7 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
#define wxVsnprintf_ vswprintf
#elif defined(__WATCOMC__)
#define wxVsnprintf_ _vsnwprintf
#define wxSnprintf_ _snwprintf
WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, _snwprintf)
#endif
#else /* ASCII */
/*
@ -966,7 +981,7 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
#if defined(HAVE_SNPRINTF) \
|| defined(__MWERKS__) || defined(__WATCOMC__)
#ifndef HAVE_BROKEN_SNPRINTF_DECL
#define wxSnprintf_ snprintf
WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, snprintf)
#endif
#endif
#if defined(HAVE_VSNPRINTF) \
@ -984,12 +999,15 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
#ifndef wxSnprintf_
/* no snprintf(), cook our own */
WXDLLIMPEXP_BASE int
wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...) ATTRIBUTE_PRINTF_3;
wxDoSnprintf_(wxChar *buf, size_t len,
const wxChar *format, ...) ATTRIBUTE_PRINTF_3;
WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, wxDoSnprintf_)
#endif
#ifndef wxVsnprintf_
/* no (suitable) vsnprintf(), cook our own */
WXDLLIMPEXP_BASE int
wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format, va_list argptr);
wxVsnprintf_(wxChar *buf, size_t len,
const wxChar *format, va_list argptr);
#define wxUSE_WXVSNPRINTF 1
#else
@ -1024,13 +1042,25 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
either because we don't have them at all or because they don't have the
semantics we need
*/
int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
int wxFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, wxScanf, wxDoScanf)
int wxDoScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
WX_DEFINE_VARARG_FUNC(int, wxSscanf, wxDoSscanf)
int wxDoSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, wxFscanf, wxDoFscanf)
int wxDoFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, wxPrintf, wxDoPrintf)
int wxDoPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
WX_DEFINE_VARARG_FUNC(int, wxSprintf, wxDoSprintf)
int wxDoSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, wxFprintf, wxDoFprintf)
int wxDoFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
int wxPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
int wxSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
int wxFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
int wxVprintf( const wxChar *format, va_list ap );
int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
@ -1043,7 +1073,8 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
anything as our own wxVsnprintf_() already behaves as needed.
*/
#if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_)
int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
WX_DEFINE_VARARG_FUNC(int, wxSnprintf, wxDoSnprintf)
int wxDoSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
#else
#define wxSnprintf wxSnprintf_
@ -1078,7 +1109,7 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
/* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
#if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
#undef wxIsspace
#define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
#define wxIsspace(c) ((((unsigned)(wxChar)c) < 128) && isspace(c))
#endif /* VC++ */
/*
@ -1233,7 +1264,8 @@ WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz);
/*silent gabby compilers*/
struct tm;
WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
const wxChar *fmt, const struct tm *tm);
const wxChar *fmt,
const struct tm *tm);
#endif /* wxNEED_WX_TIME_H */
#ifndef wxCtime
@ -1348,6 +1380,352 @@ WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
#endif /*__cplusplus*/
/*
FIXME-UTF8: split this header into more:
wxchartype.h for wxChar definition (only this one will have to
remain C header, the rest can be C++)
wxcrt.h for CRT wrappers
wxchar.h for wxChar+wxCharRef classes
*/
#ifdef __cplusplus
class WXDLLIMPEXP_BASE wxString;
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: 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: 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
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; }
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 // __cplusplus
#endif /* _WX_WXCHAR_H_ */

View File

@ -346,7 +346,7 @@ wxString wxExpandEnvVars(const wxString& str)
size_t m;
for ( size_t n = 0; n < str.length(); n++ ) {
switch ( str[n] ) {
switch ( str[n].GetValue() ) {
#ifdef __WXMSW__
case wxT('%'):
#endif //WINDOWS
@ -362,7 +362,7 @@ wxString wxExpandEnvVars(const wxString& str)
bracket = Bracket_None;
}
else {
switch ( str[n + 1] ) {
switch ( str[n + 1].GetValue() ) {
case wxT('('):
bracket = Bracket_Normal;
n++; // skip the bracket
@ -434,7 +434,7 @@ wxString wxExpandEnvVars(const wxString& str)
}
break;
case '\\':
case wxT('\\'):
// backslash can be used to suppress special meaning of % and $
if ( n != str.length() - 1 &&
(str[n + 1] == wxT('%') || str[n + 1] == wxT('$')) ) {

View File

@ -606,9 +606,9 @@ void wxDCBase::DrawLabel(const wxString& text,
// split the string into lines and draw each of them separately
wxString curLine;
for ( const wxChar *pc = text; ; pc++ )
for ( wxString::const_iterator pc = text.begin(); ; ++pc )
{
if ( *pc == _T('\n') || *pc == _T('\0') )
if ( *pc == _T('\n') || pc == text.end() )
{
int xRealStart = x; // init it here to avoid compielr warnings
@ -646,14 +646,14 @@ void wxDCBase::DrawLabel(const wxString& text,
endUnderscore += xRealStart;
}
if ( *pc == _T('\0') )
if ( pc == text.end() )
break;
curLine.clear();
}
else // not end of line
{
if ( pc - text.c_str() == indexAccel )
if ( pc - text.begin() == indexAccel )
{
// remeber to draw underscore here
GetTextExtent(curLine, &startUnderscore, NULL);

View File

@ -1233,10 +1233,12 @@ wxFileConfigLineList *wxFileConfig::LineListAppend(const wxString& str)
str.c_str() );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" head: %s"),
((m_linesHead) ? m_linesHead->Text().c_str() : wxEmptyString) );
((m_linesHead) ? (const wxChar*)m_linesHead->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" tail: %s"),
((m_linesTail) ? m_linesTail->Text().c_str() : wxEmptyString) );
((m_linesTail) ? (const wxChar*)m_linesTail->Text().c_str()
: wxEmptyString) );
wxFileConfigLineList *pLine = new wxFileConfigLineList(str);
@ -1256,10 +1258,12 @@ wxFileConfigLineList *wxFileConfig::LineListAppend(const wxString& str)
wxLogTrace( FILECONF_TRACE_MASK,
_T(" head: %s"),
((m_linesHead) ? m_linesHead->Text().c_str() : wxEmptyString) );
((m_linesHead) ? (const wxChar*)m_linesHead->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" tail: %s"),
((m_linesTail) ? m_linesTail->Text().c_str() : wxEmptyString) );
((m_linesTail) ? (const wxChar*)m_linesTail->Text().c_str()
: wxEmptyString) );
return m_linesTail;
}
@ -1271,13 +1275,16 @@ wxFileConfigLineList *wxFileConfig::LineListInsert(const wxString& str,
wxLogTrace( FILECONF_TRACE_MASK,
_T(" ** Inserting Line '%s' after '%s'"),
str.c_str(),
((pLine) ? pLine->Text().c_str() : wxEmptyString) );
((pLine) ? (const wxChar*)pLine->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" head: %s"),
((m_linesHead) ? m_linesHead->Text().c_str() : wxEmptyString) );
((m_linesHead) ? (const wxChar*)m_linesHead->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" tail: %s"),
((m_linesTail) ? m_linesTail->Text().c_str() : wxEmptyString) );
((m_linesTail) ? (const wxChar*)m_linesTail->Text().c_str()
: wxEmptyString) );
if ( pLine == m_linesTail )
return LineListAppend(str);
@ -1302,10 +1309,12 @@ wxFileConfigLineList *wxFileConfig::LineListInsert(const wxString& str,
wxLogTrace( FILECONF_TRACE_MASK,
_T(" head: %s"),
((m_linesHead) ? m_linesHead->Text().c_str() : wxEmptyString) );
((m_linesHead) ? (const wxChar*)m_linesHead->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" tail: %s"),
((m_linesTail) ? m_linesTail->Text().c_str() : wxEmptyString) );
((m_linesTail) ? (const wxChar*)m_linesTail->Text().c_str()
: wxEmptyString) );
return pNewLine;
}
@ -1317,10 +1326,12 @@ void wxFileConfig::LineListRemove(wxFileConfigLineList *pLine)
pLine->Text().c_str() );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" head: %s"),
((m_linesHead) ? m_linesHead->Text().c_str() : wxEmptyString) );
((m_linesHead) ? (const wxChar*)m_linesHead->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" tail: %s"),
((m_linesTail) ? m_linesTail->Text().c_str() : wxEmptyString) );
((m_linesTail) ? (const wxChar*)m_linesTail->Text().c_str()
: wxEmptyString) );
wxFileConfigLineList *pPrev = pLine->Prev(),
*pNext = pLine->Next();
@ -1344,10 +1355,12 @@ void wxFileConfig::LineListRemove(wxFileConfigLineList *pLine)
wxLogTrace( FILECONF_TRACE_MASK,
_T(" head: %s"),
((m_linesHead) ? m_linesHead->Text().c_str() : wxEmptyString) );
((m_linesHead) ? (const wxChar*)m_linesHead->Text().c_str()
: wxEmptyString) );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" tail: %s"),
((m_linesTail) ? m_linesTail->Text().c_str() : wxEmptyString) );
((m_linesTail) ? (const wxChar*)m_linesTail->Text().c_str()
: wxEmptyString) );
delete pLine;
}
@ -1715,7 +1728,8 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup)
m_pLine ? wx_static_cast(void*, m_pLine->Next()) : 0 );
wxLogTrace( FILECONF_TRACE_MASK,
_T(" text: '%s'"),
m_pLine ? m_pLine->Text().c_str() : wxEmptyString );
m_pLine ? (const wxChar*)m_pLine->Text().c_str()
: wxEmptyString );
// delete all entries...
size_t nCount = pGroup->m_aEntries.Count();
@ -1758,7 +1772,8 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup)
wxLogTrace( FILECONF_TRACE_MASK,
_T(" Removing from group '%s' : '%s'"),
Name().c_str(),
((m_pLine) ? m_pLine->Text().c_str() : wxEmptyString) );
((m_pLine) ? (const wxChar*)m_pLine->Text().c_str()
: wxEmptyString) );
// notice that we may do this test inside the previous "if"
// because the last entry's line is surely !NULL
@ -1990,7 +2005,7 @@ static wxString FilterInValue(const wxString& str)
for ( size_t n = bQuoted ? 1 : 0; n < str.Len(); n++ ) {
if ( str[n] == wxT('\\') ) {
switch ( str[++n] ) {
switch ( str[++n].GetValue() ) {
case wxT('n'):
strResult += wxT('\n');
break;
@ -2043,7 +2058,7 @@ static wxString FilterOutValue(const wxString& str)
wxChar c;
for ( size_t n = 0; n < str.Len(); n++ ) {
switch ( str[n] ) {
switch ( str[n].GetValue() ) {
case wxT('\n'):
c = wxT('n');
break;

View File

@ -398,7 +398,7 @@ wxFSFile* wxFileSystem::OpenFile(const wxString& location, int flags)
meta = 0;
for (i = 0; i < ln; i++)
{
switch (loc[i])
switch ( loc[i].GetValue() )
{
case wxT('/') : case wxT(':') : case wxT('#') :
meta = loc[i];

View File

@ -198,7 +198,7 @@ wxFontMapper::CharsetToEncoding(const wxString& charset, bool interactive)
// the message
wxString msg;
msg.Printf(_("The charset '%s' is unknown. You may select\nanother charset to replace it with or choose\n[Cancel] if it cannot be replaced"), charset.c_str());
msg.Printf(_("The charset '%s' is unknown. You may select\nanother charset to replace it with or choose\n[Cancel] if it cannot be replaced"), charset);
// the list of choices
const size_t count = GetSupportedEncodingsCount();
@ -240,7 +240,7 @@ wxFontMapper::CharsetToEncoding(const wxString& charset, bool interactive)
long value = n == -1 ? (long)wxFONTENCODING_UNKNOWN : (long)encoding;
if ( !config->Write(charset, value) )
{
wxLogError(_("Failed to remember the encoding for the charset '%s'."), charset.c_str());
wxLogError(_("Failed to remember the encoding for the charset '%s'."), charset);
}
}
#endif // wxUSE_CONFIG
@ -372,7 +372,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
else
{
wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"),
fontinfo.c_str());
fontinfo);
}
}
//else: there is no information in config about this encoding
@ -417,12 +417,12 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
{
// ask the user if he wants to override found alternative encoding
msg.Printf(_("No font for displaying text in encoding '%s' found,\nbut an alternative encoding '%s' is available.\nDo you want to use this encoding (otherwise you will have to choose another one)?"),
encDesc.c_str(), GetEncodingDescription(equivEncoding).c_str());
encDesc, GetEncodingDescription(equivEncoding));
}
else
{
msg.Printf(_("No font for displaying text in encoding '%s' found.\nWould you like to select a font to be used for this encoding\n(otherwise the text in this encoding will not be shown correctly)?"),
encDesc.c_str());
encDesc);
}
// the question is different in 2 cases so the answer has to be
@ -472,8 +472,9 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
GetConfig()->Write
(
configEntry,
foundEquivEncoding ? info->ToString().c_str()
: FONTMAPPER_FONT_DONT_ASK
foundEquivEncoding
? (const wxChar*)info->ToString().c_str()
: FONTMAPPER_FONT_DONT_ASK
);
}
#endif // wxUSE_CONFIG

View File

@ -434,19 +434,20 @@ wxString wxFTP::Pwd()
if ( CheckCommand(wxT("PWD"), '2') )
{
// the result is at least that long if CheckCommand() succeeded
const wxChar *p = m_lastResult.c_str() + LEN_CODE + 1;
wxString::const_iterator p = m_lastResult.begin() + LEN_CODE + 1;
if ( *p != _T('"') )
{
wxLogDebug(_T("Missing starting quote in reply for PWD: %s"), p);
wxLogDebug(_T("Missing starting quote in reply for PWD: %s"),
wxString(p, m_lastResult.end()));
}
else
{
for ( p++; *p; p++ )
for ( ++p; (bool)*p; ++p ) // FIXME-DMARS
{
if ( *p == _T('"') )
{
// check if the quote is doubled
p++;
++p;
if ( !*p || *p != _T('"') )
{
// no, this is the end

View File

@ -309,7 +309,7 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
m_http_response = wxAtoi(tmp_str2);
switch (tmp_str2[0u])
switch ( tmp_str2[0u].GetValue() )
{
case wxT('1'):
/* INFORMATION / SUCCESS */

View File

@ -2632,8 +2632,9 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString,
wxLogTrace(TRACE_I18N,
_T("string \"%s\"[%ld] not found in %slocale '%s'."),
szOrigString, (long)n,
szDomain ? wxString::Format(_T("domain '%s' "), szDomain).c_str()
: _T(""),
szDomain
? (const wxChar*)wxString::Format(_T("domain '%s' "), szDomain).c_str()
: _T(""),
m_strLocale.c_str());
}
#endif // __WXDEBUG__

View File

@ -91,7 +91,7 @@ void wxVLogGeneric(wxLogLevel level, const wxChar *szFormat, va_list argptr)
}
}
void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
void wxDoLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);
@ -108,7 +108,7 @@ void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
} \
} \
\
void wxLog##level(const wxChar *szFormat, ...) \
void wxDoLog##level(const wxChar *szFormat, ...) \
{ \
va_list argptr; \
va_start(argptr, szFormat); \
@ -145,7 +145,7 @@ void wxVLogFatalError(const wxChar *szFormat, va_list argptr)
#endif
}
void wxLogFatalError(const wxChar *szFormat, ...)
void wxDoLogFatalError(const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);
@ -167,7 +167,7 @@ void wxVLogVerbose(const wxChar *szFormat, va_list argptr)
}
}
void wxLogVerbose(const wxChar *szFormat, ...)
void wxDoLogVerbose(const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);
@ -186,7 +186,7 @@ void wxLogVerbose(const wxChar *szFormat, ...)
} \
} \
\
void wxLog##level(const wxChar *szFormat, ...) \
void wxDoLog##level(const wxChar *szFormat, ...) \
{ \
va_list argptr; \
va_start(argptr, szFormat); \
@ -199,12 +199,12 @@ void wxLogVerbose(const wxChar *szFormat, ...)
if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
wxString msg;
msg << _T("(") << mask << _T(") ") << wxString::FormatV(szFormat, argptr);
wxLog::OnLog(wxLOG_Trace, msg, time(NULL));
}
}
void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...)
void wxDoLogTrace(const wxChar *mask, const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);
@ -222,7 +222,7 @@ void wxLogVerbose(const wxChar *szFormat, ...)
}
}
void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
void wxDoLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);
@ -251,7 +251,7 @@ void WXDLLEXPORT wxVLogSysError(const wxChar *szFormat, va_list argptr)
wxVLogSysError(wxSysErrorCode(), szFormat, argptr);
}
void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...)
void WXDLLEXPORT wxDoLogSysError(const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);
@ -268,7 +268,7 @@ void WXDLLEXPORT wxVLogSysError(long err, const wxChar *fmt, va_list argptr)
}
}
void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...)
void WXDLLEXPORT wxDoLogSysError(long lErrCode, const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);

View File

@ -1263,7 +1263,7 @@ WXDLLIMPEXP_BASE wxTextOutputStream& operator<< (wxTextOutputStream& o, const wx
return o << ll.ToString();
}
#define READ_STRING_CHAR(s, idx, len) ((wxChar) ((idx!=len) ? s[idx++] : 0))
#define READ_STRING_CHAR(s, idx, len) ((idx!=len) ? (wxChar)s[idx++] : _T('\0'))
WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &o, wxULongLong &ll)
{

View File

@ -95,7 +95,7 @@ static inline bool IsInConsole()
#endif // __WINDOWS__
void wxMessageOutputBest::Printf(const wxChar* format, ...)
void wxMessageOutputBest::DoPrintf(const wxChar* format, ...)
{
va_list args;
va_start(args, format);
@ -120,7 +120,7 @@ void wxMessageOutputBest::Printf(const wxChar* format, ...)
// wxMessageOutputStderr
// ----------------------------------------------------------------------------
void wxMessageOutputStderr::Printf(const wxChar* format, ...)
void wxMessageOutputStderr::DoPrintf(const wxChar* format, ...)
{
va_list args;
va_start(args, format);
@ -136,7 +136,7 @@ void wxMessageOutputStderr::Printf(const wxChar* format, ...)
// wxMessageOutputDebug
// ----------------------------------------------------------------------------
void wxMessageOutputDebug::Printf(const wxChar* format, ...)
void wxMessageOutputDebug::DoPrintf(const wxChar* format, ...)
{
wxString out;
@ -175,7 +175,7 @@ void wxMessageOutputDebug::Printf(const wxChar* format, ...)
// wxMessageOutputLog
// ----------------------------------------------------------------------------
void wxMessageOutputLog::Printf(const wxChar* format, ...)
void wxMessageOutputLog::DoPrintf(const wxChar* format, ...)
{
wxString out;
@ -198,7 +198,7 @@ void wxMessageOutputLog::Printf(const wxChar* format, ...)
#if wxUSE_GUI
void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
void wxMessageOutputMessageBox::DoPrintf(const wxChar* format, ...)
{
va_list args;
va_start(args, format);

View File

@ -217,8 +217,8 @@ wxString wxIPV4address::IPAddress() const
bool wxIPV4address::operator==(const wxIPV4address& addr) const
{
return Hostname().Cmp(addr.Hostname().c_str()) == 0 &&
Service() == addr.Service();
return Hostname().Cmp(addr.Hostname()) == 0 &&
Service() == addr.Service();
}
#if wxUSE_IPV6

View File

@ -42,7 +42,7 @@ wxStringInputStream::wxStringInputStream(const wxString& s)
#if wxUSE_UNICODE
: m_str(s), m_buf(wxMBConvUTF8().cWX2MB(s).release()), m_len(strlen(m_buf))
#else
: m_str(s), m_buf((char*)s.c_str()), m_len(s.length())
: m_str(s), m_buf((char*)(const char*)s.c_str()), m_len(s.length())
#endif
{
#if wxUSE_UNICODE

View File

@ -3279,7 +3279,7 @@ wxMBConv *wxCSConv::DoCreate() const
wxLogTrace(TRACE_STRCONV,
wxT("creating conversion for %s"),
(m_name ? m_name
: wxFontMapperBase::GetEncodingName(m_encoding).c_str()));
: (const wxChar*)wxFontMapperBase::GetEncodingName(m_encoding).c_str()));
#endif // wxUSE_FONTMAP
// check for the special case of ASCII or ISO8859-1 charset: as we have
@ -3482,9 +3482,9 @@ wxMBConv *wxCSConv::DoCreate() const
m_name ? m_name
:
#if wxUSE_FONTMAP
wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
(const wxChar*)wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
#else // !wxUSE_FONTMAP
wxString::Format(_("encoding %i"), m_encoding).c_str()
(const wxChar*)wxString::Format(_("encoding %i"), m_encoding).c_str()
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
);

View File

@ -95,12 +95,16 @@ extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dummy;
wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str)
{
#ifdef __BORLANDC__
os << str.mb_str();
return os << str.c_str();
}
wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str)
{
#if wxUSE_UNICODE && !defined(__BORLANDC__)
return os << str.AsWChar();
#else
os << str.c_str();
return os << str.AsChar();
#endif
return os;
}
#endif // wxUSE_STD_IOSTREAM
@ -191,7 +195,7 @@ wxStringBase::wxStringBase(const void *pStart, const void *pEnd)
}
}
wxStringBase::wxStringBase(size_type n, wxChar ch)
wxStringBase::wxStringBase(size_type n, wxUniChar ch)
{
Init();
append(n, ch);
@ -300,7 +304,7 @@ bool wxStringBase::AllocBeforeWrite(size_t nLen)
return true;
}
wxStringBase& wxStringBase::append(size_t n, wxChar ch)
wxStringBase& wxStringBase::append(size_t n, wxUniChar ch)
{
size_type len = length();
@ -314,7 +318,7 @@ wxStringBase& wxStringBase::append(size_t n, wxChar ch)
return *this;
}
void wxStringBase::resize(size_t nSize, wxChar ch)
void wxStringBase::resize(size_t nSize, wxUniChar ch)
{
size_t len = length();
@ -495,7 +499,7 @@ size_t wxStringBase::find(const wxChar* sz, size_t nStart, size_t n) const
return find(wxStringBase(sz, n), nStart);
}
size_t wxStringBase::find(wxChar ch, size_t nStart) const
size_t wxStringBase::find(wxUniChar ch, size_t nStart) const
{
wxASSERT( nStart <= length() );
@ -542,7 +546,7 @@ size_t wxStringBase::rfind(const wxChar* sz, size_t nStart, size_t n) const
return rfind(wxStringBase(sz, n), nStart);
}
size_t wxStringBase::rfind(wxChar ch, size_t nStart) const
size_t wxStringBase::rfind(wxUniChar ch, size_t nStart) const
{
if ( nStart == npos )
{
@ -650,14 +654,14 @@ size_t wxStringBase::find_first_not_of(const wxChar* sz, size_t nStart,
return find_first_not_of(wxStringBase(sz, n), nStart);
}
size_t wxStringBase::find_first_not_of(wxChar ch, size_t nStart) const
size_t wxStringBase::find_first_not_of(wxUniChar ch, size_t nStart) const
{
wxASSERT( nStart <= length() );
for ( const wxChar *p = c_str() + nStart; *p; p++ )
for ( const_iterator p = begin() + nStart; (bool)*p; ++p ) // FIXME-DMARS
{
if ( *p != ch )
return p - c_str();
return p - begin();
}
return npos;
@ -691,7 +695,7 @@ size_t wxStringBase::find_last_not_of(const wxChar* sz, size_t nStart,
return find_last_not_of(wxStringBase(sz, n), nStart);
}
size_t wxStringBase::find_last_not_of(wxChar ch, size_t nStart) const
size_t wxStringBase::find_last_not_of(wxUniChar ch, size_t nStart) const
{
if ( nStart == npos )
{
@ -702,10 +706,10 @@ size_t wxStringBase::find_last_not_of(wxChar ch, size_t nStart) const
wxASSERT( nStart <= length() );
}
for ( const wxChar *p = c_str() + nStart; p >= c_str(); --p )
for ( const_iterator p = begin() + nStart; p != begin(); --p )
{
if ( *p != ch )
return p - c_str();
return p - begin();
}
return npos;
@ -744,7 +748,7 @@ wxStringBase& wxStringBase::replace(size_t nStart, size_t nLen,
}
wxStringBase& wxStringBase::replace(size_t nStart, size_t nLen,
size_t nCount, wxChar ch)
size_t nCount, wxUniChar ch)
{
return replace(nStart, nLen, wxStringBase(nCount, ch).c_str());
}
@ -791,9 +795,10 @@ wxStringBase& wxStringBase::operator=(const wxStringBase& stringSrc)
}
// assigns a single character
wxStringBase& wxStringBase::operator=(wxChar ch)
wxStringBase& wxStringBase::operator=(wxUniChar ch)
{
if ( !AssignCopy(1, &ch) ) {
wxChar c(ch);
if ( !AssignCopy(1, &c) ) {
wxFAIL_MSG( _T("out of memory in wxStringBase::operator=(wxChar)") );
}
return *this;
@ -1163,7 +1168,7 @@ wxString operator+(const wxString& str1, const wxString& str2)
return s;
}
wxString operator+(const wxString& str, wxChar ch)
wxString operator+(const wxString& str, wxUniChar ch)
{
#if !wxUSE_STL
wxASSERT( str.GetStringData()->IsValid() );
@ -1175,7 +1180,7 @@ wxString operator+(const wxString& str, wxChar ch)
return s;
}
wxString operator+(wxChar ch, const wxString& str)
wxString operator+(wxUniChar ch, const wxString& str)
{
#if !wxUSE_STL
wxASSERT( str.GetStringData()->IsValid() );
@ -1415,7 +1420,7 @@ bool wxString::EndsWith(const wxChar *suffix, wxString *rest) const
wxASSERT_MSG( suffix, _T("invalid parameter in wxString::EndssWith") );
int start = length() - wxStrlen(suffix);
if ( start < 0 || wxStrcmp(c_str() + start, suffix) != 0 )
if ( start < 0 || wxStrcmp(wx_str() + start, suffix) != 0 )
return false;
if ( rest )
@ -1443,14 +1448,14 @@ wxString wxString::Right(size_t nCount) const
// get all characters after the last occurence of ch
// (returns the whole string if ch not found)
wxString wxString::AfterLast(wxChar ch) const
wxString wxString::AfterLast(wxUniChar ch) const
{
wxString str;
int iPos = Find(ch, true);
if ( iPos == wxNOT_FOUND )
str = *this;
else
str = c_str() + iPos + 1;
str = wx_str() + iPos + 1;
return str;
}
@ -1470,7 +1475,7 @@ wxString wxString::Left(size_t nCount) const
// get all characters before the first occurence of ch
// (returns the whole string if ch not found)
wxString wxString::BeforeFirst(wxChar ch) const
wxString wxString::BeforeFirst(wxUniChar ch) const
{
int iPos = Find(ch);
if ( iPos == wxNOT_FOUND ) iPos = length();
@ -1479,7 +1484,7 @@ wxString wxString::BeforeFirst(wxChar ch) const
/// get all characters before the last occurence of ch
/// (returns empty string if ch not found)
wxString wxString::BeforeLast(wxChar ch) const
wxString wxString::BeforeLast(wxUniChar ch) const
{
wxString str;
int iPos = Find(ch, true);
@ -1491,12 +1496,12 @@ wxString wxString::BeforeLast(wxChar ch) const
/// get all characters after the first occurence of ch
/// (returns empty string if ch not found)
wxString wxString::AfterFirst(wxChar ch) const
wxString wxString::AfterFirst(wxUniChar ch) const
{
wxString str;
int iPos = Find(ch);
if ( iPos != wxNOT_FOUND )
str = c_str() + iPos + 1;
str = wx_str() + iPos + 1;
return str;
}
@ -1653,7 +1658,7 @@ wxString& wxString::Trim(bool bFromRight)
}
// adds nCount characters chPad to the string from either side
wxString& wxString::Pad(size_t nCount, wxChar chPad, bool bFromRight)
wxString& wxString::Pad(size_t nCount, wxUniChar chPad, bool bFromRight)
{
wxString s(chPad, nCount);
@ -1685,7 +1690,7 @@ wxString& wxString::Truncate(size_t uiLen)
// ---------------------------------------------------------------------------
// find a character
int wxString::Find(wxChar ch, bool bFromEnd) const
int wxString::Find(wxUniChar ch, bool bFromEnd) const
{
size_type idx = bFromEnd ? find_last_of(ch) : find_first_of(ch);
@ -1734,18 +1739,18 @@ bool wxStringToIntType(const wxChar *start,
bool wxString::ToLong(long *val, int base) const
{
return wxStringToIntType(c_str(), val, base, wxStrtol);
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtol);
}
bool wxString::ToULong(unsigned long *val, int base) const
{
return wxStringToIntType(c_str(), val, base, wxStrtoul);
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtoul);
}
bool wxString::ToLongLong(wxLongLong_t *val, int base) const
{
#ifdef wxHAS_STRTOLL
return wxStringToIntType(c_str(), val, base, wxStrtoll);
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtoll);
#else
// TODO: implement this ourselves
wxUnusedVar(val);
@ -1757,7 +1762,7 @@ bool wxString::ToLongLong(wxLongLong_t *val, int base) const
bool wxString::ToULongLong(wxULongLong_t *val, int base) const
{
#ifdef wxHAS_STRTOLL
return wxStringToIntType(c_str(), val, base, wxStrtoull);
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtoull);
#else
// TODO: implement this ourselves
wxUnusedVar(val);
@ -1792,13 +1797,17 @@ bool wxString::ToDouble(double *val) const
// ---------------------------------------------------------------------------
/* static */
wxString wxString::Format(const wxChar *pszFormat, ...)
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
wxString wxStringPrintfMixinBase::DoFormat(const wxChar *format, ...)
#else
wxString wxString::DoFormat(const wxChar *format, ...)
#endif
{
va_list argptr;
va_start(argptr, pszFormat);
va_start(argptr, format);
wxString s;
s.PrintfV(pszFormat, argptr);
s.PrintfV(format, argptr);
va_end(argptr);
@ -1806,26 +1815,39 @@ wxString wxString::Format(const wxChar *pszFormat, ...)
}
/* static */
wxString wxString::FormatV(const wxChar *pszFormat, va_list argptr)
wxString wxString::FormatV(const wxString& format, va_list argptr)
{
wxString s;
s.PrintfV(pszFormat, argptr);
s.PrintfV(format, argptr);
return s;
}
int wxString::Printf(const wxChar *pszFormat, ...)
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
int wxStringPrintfMixinBase::DoPrintf(const wxChar *format, ...)
#else
int wxString::DoPrintf(const wxChar *format, ...)
#endif
{
va_list argptr;
va_start(argptr, pszFormat);
va_start(argptr, format);
int iLen = PrintfV(pszFormat, argptr);
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
// get a pointer to the wxString instance; we have to use dynamic_cast<>
// because it's the only cast that works safely for downcasting when
// multiple inheritance is used:
wxString *str = static_cast<wxString*>(this);
#else
wxString *str = this;
#endif
int iLen = str->PrintfV(format, argptr);
va_end(argptr);
return iLen;
}
int wxString::PrintfV(const wxChar* pszFormat, va_list argptr)
int wxString::PrintfV(const wxString& format, va_list argptr)
{
int size = 1024;
@ -1844,7 +1866,7 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr)
// only a copy
va_list argptrcopy;
wxVaCopy(argptrcopy, argptr);
int len = wxVsnprintf(buf, size, pszFormat, argptrcopy);
int len = wxVsnprintf(buf, size, format, argptrcopy);
va_end(argptrcopy);
// some implementations of vsnprintf() don't NUL terminate
@ -2036,7 +2058,7 @@ match:
}
// Count the number of chars
int wxString::Freq(wxChar ch) const
int wxString::Freq(wxUniChar ch) const
{
int count = 0;
int len = length();
@ -2055,15 +2077,6 @@ wxString wxString::Upper() const
// convert to lower case, return the copy of the string
wxString wxString::Lower() const { wxString s(*this); return s.MakeLower(); }
int wxString::sprintf(const wxChar *pszFormat, ...)
{
va_list argptr;
va_start(argptr, pszFormat);
int iLen = PrintfV(pszFormat, argptr);
va_end(argptr);
return iLen;
}
// ============================================================================
// ArrayString
// ============================================================================

79
src/common/strvararg.cpp Normal file
View File

@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/common/strvararg.cpp
// Purpose: macros for implementing type-safe vararg passing of strings
// Author: Vaclav Slavik
// Created: 2007-02-19
// RCS-ID: $Id$
// Copyright: (c) 2007 REA Elektronik GmbH
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/strvararg.h"
#include "wx/buffer.h"
#include "wx/strconv.h"
#include "wx/string.h"
// ============================================================================
// implementation
// ============================================================================
const wxArgNativeCharType *wxArgNormalizer<const wxCStrData&>::get() const
{
return m_value;
}
const wxArgNativeCharType *wxArgNormalizer<const wxString&>::get() const
{
return m_value.c_str();
}
#if wxUSE_UNICODE_WCHAR
wxArgNormalizer<const char*>::wxArgNormalizer(const char *value)
{
m_value = new wxWCharBuffer(wxConvLibc.cMB2WC(value));
}
wxArgNormalizer<const char*>::~wxArgNormalizer()
{
delete m_value;
}
const wchar_t *wxArgNormalizer<const char*>::get() const
{
return m_value->data();
}
#elif wxUSE_WCHAR_T // !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
wxArgNormalizer<const wchar_t*>::wxArgNormalizer(const wchar_t *value)
{
m_value = new wxCharBuffer(wxConvLibc.cWC2MB(value));
}
wxArgNormalizer<const wchar_t*>::~wxArgNormalizer()
{
delete m_value;
}
const char *wxArgNormalizer<const wchar_t*>::get() const
{
return m_value->data();
}
#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T

View File

@ -289,7 +289,10 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv)
size_t len = name.length();
wxCharBuffer approx(len);
for (size_t i = 0; i < len; i++)
approx.data()[i] = name[i] & ~0x7F ? '_' : name[i];
{
wxChar c = name[i];
approx.data()[i] = c & ~0x7F ? '_' : c;
}
nameBuf = approx;
}
@ -1265,7 +1268,7 @@ wxString wxTarOutputStream::PaxHeaderPath(const wxString& format,
if (end == wxString::npos || end + 1 >= format.length())
break;
ret << format.substr(begin, end - begin);
switch (format[end + 1]) {
switch ( format[end + 1].GetValue() ) {
case 'd': ret << d; break;
case 'f': ret << f; break;
case 'p': ret << wxGetProcessId(); break;

View File

@ -109,26 +109,29 @@ const wxChar* wxURI::Create(const wxString& uri)
// Unescape unencodes all 3 character URL escape sequences in a wxString
// ---------------------------------------------------------------------------
wxChar wxURI::TranslateEscape(const wxChar* s)
wxUniChar wxURI::TranslateEscape(const wxString::const_iterator& s)
{
wxASSERT_MSG( IsHex(s[0]) && IsHex(s[1]), wxT("Invalid escape sequence!"));
wxChar c1(*s);
wxChar c2(*(s + 1));
return wx_truncate_cast(wxChar, (CharToHex(s[0]) << 4 ) | CharToHex(s[1]));
wxASSERT_MSG( IsHex(c1) && IsHex(c2), wxT("Invalid escape sequence!"));
return wx_truncate_cast(wxChar, (CharToHex(c1) << 4 ) | CharToHex(c2));
}
wxString wxURI::Unescape(const wxString& uri)
{
wxString new_uri;
for(size_t i = 0; i < uri.length(); ++i)
for (wxString::const_iterator i = uri.begin(); i != uri.end(); ++i)
{
if (uri[i] == wxT('%'))
if ( *i == wxT('%') )
{
new_uri += wxURI::TranslateEscape( &(uri.c_str()[i+1]) );
new_uri += wxURI::TranslateEscape(i + 1);
i += 2;
}
else
new_uri += uri[i];
new_uri += *i;
}
return new_uri;
@ -870,18 +873,18 @@ void wxURI::Resolve(const wxURI& base, int flags)
if (m_path[0u] != wxT('/'))
{
//Merge paths
const wxChar* op = m_path.c_str();
const wxChar* bp = base.m_path.c_str() + base.m_path.Length();
wxString::const_iterator op = m_path.begin();
wxString::const_iterator bp = base.m_path.begin() + base.m_path.length();
//not a ending directory? move up
if (base.m_path[0] && *(bp-1) != wxT('/'))
UpTree(base.m_path, bp);
UpTree(base.m_path.begin(), bp);
//normalize directories
while(*op == wxT('.') && *(op+1) == wxT('.') &&
(*(op+2) == '\0' || *(op+2) == wxT('/')) )
{
UpTree(base.m_path, bp);
UpTree(base.m_path.begin(), bp);
if (*(op+2) == '\0')
op += 2;
@ -889,8 +892,8 @@ void wxURI::Resolve(const wxURI& base, int flags)
op += 3;
}
m_path = base.m_path.substr(0, bp - base.m_path.c_str()) +
m_path.substr((op - m_path.c_str()), m_path.Length());
m_path = base.m_path.substr(0, bp - base.m_path.begin()) +
m_path.substr((op - m_path.begin()), m_path.length());
}
}
@ -904,7 +907,8 @@ void wxURI::Resolve(const wxURI& base, int flags)
// ---------------------------------------------------------------------------
//static
void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri)
void wxURI::UpTree(wxString::const_iterator uristart,
wxString::const_iterator& uri)
{
if (uri != uristart && *(uri-1) == wxT('/'))
{
@ -926,6 +930,30 @@ void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri)
//!!!//
}
// FIXME-UTF8: fix Normalize() to use iterators instead of having this method!
/*static*/ void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri)
{
if (uri != uristart && *(uri-1) == wxT('/'))
{
uri -= 2;
}
for(;uri != uristart; --uri)
{
if (*uri == wxT('/'))
{
++uri;
break;
}
}
//!!!TODO:HACK!!!//
if (uri == uristart && *uri == wxT('/'))
++uri;
//!!!//
}
// end of FIXME-UTF8
// ---------------------------------------------------------------------------
// Normalize
//

View File

@ -1220,7 +1220,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
#endif // !wxVsnprintf_
#if !defined(wxSnprintf_)
int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
int WXDLLEXPORT wxDoSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
{
va_list argptr;
va_start(argptr, format);
@ -1236,7 +1236,7 @@ int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
#if defined(__DMC__)
/* Digital Mars adds count to _stprintf (C99) so convert */
#if wxUSE_UNICODE
int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... )
int wxDoSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... )
{
va_list arglist;
@ -1576,7 +1576,7 @@ wxString wxConvertFormat(const wxChar *format)
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
int wxScanf( const wxChar *format, ... )
int wxDoScanf( const wxChar *format, ... )
{
va_list argptr;
va_start(argptr, format);
@ -1588,7 +1588,7 @@ int wxScanf( const wxChar *format, ... )
return ret;
}
int wxSscanf( const wxChar *str, const wxChar *format, ... )
int wxDoSscanf( const wxChar *str, const wxChar *format, ... )
{
va_list argptr;
va_start(argptr, format);
@ -1600,7 +1600,7 @@ int wxSscanf( const wxChar *str, const wxChar *format, ... )
return ret;
}
int wxFscanf( FILE *stream, const wxChar *format, ... )
int wxDoFscanf( FILE *stream, const wxChar *format, ... )
{
va_list argptr;
va_start(argptr, format);
@ -1611,7 +1611,7 @@ int wxFscanf( FILE *stream, const wxChar *format, ... )
return ret;
}
int wxPrintf( const wxChar *format, ... )
int wxDoPrintf( const wxChar *format, ... )
{
va_list argptr;
va_start(argptr, format);
@ -1624,7 +1624,7 @@ int wxPrintf( const wxChar *format, ... )
}
#ifndef wxSnprintf
int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... )
int wxDoSnprintf( wxChar *str, size_t size, const wxChar *format, ... )
{
va_list argptr;
va_start(argptr, format);
@ -1641,7 +1641,7 @@ int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... )
}
#endif // wxSnprintf
int wxSprintf( wxChar *str, const wxChar *format, ... )
int wxDoSprintf( wxChar *str, const wxChar *format, ... )
{
va_list argptr;
va_start(argptr, format);
@ -1656,7 +1656,7 @@ int wxSprintf( wxChar *str, const wxChar *format, ... )
return s.length();
}
int wxFprintf( FILE *stream, const wxChar *format, ... )
int wxDoFprintf( FILE *stream, const wxChar *format, ... )
{
va_list argptr;
va_start( argptr, format );
@ -2265,3 +2265,34 @@ int wxRemove(const wxChar *path)
}
#endif
// ----------------------------------------------------------------------------
// wxUniChar
// ----------------------------------------------------------------------------
/* static */
wxUniChar::unicode_type wxUniChar::From8bit(char c)
{
// all supported charsets have the first 128 characters same as ASCII:
if ( (unsigned char)c < 0x80 )
return c;
wchar_t buf[2];
if ( wxConvLibc.ToWChar(buf, 2, &c, 1) != 2 )
return wxT('?'); // FIXME-UTF8: what to use as failure character?
return buf[0];
}
/* static */
char wxUniChar::To8bit(wxUniChar::unicode_type c)
{
// all supported charsets have the first 128 characters same as ASCII:
if ( c < 0x80 )
return c;
wchar_t in = c;
char buf[2];
if ( wxConvLibc.FromWChar(buf, 2, &in, 1) != 2 )
return '?'; // FIXME-UTF8: what to use as failure character?
return buf[0];
}

View File

@ -2201,7 +2201,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string,
}
// print postscript datas via required method (file, stream)
void wxPostScriptDC::PsPrintf( const wxChar* fmt, ... )
void wxPostScriptDC::DoPsPrintfFormat(const wxChar *fmt, ... )
{
va_list argptr;
va_start(argptr, fmt);

View File

@ -457,10 +457,15 @@ bool wxExtHelpController::KeywordSearch(const wxString& k,
break;
default:
idx = wxGetSingleChoiceIndex(
showAll ? _("Help Index") : _("Relevant entries:"),
showAll ? _("Help Index") : _("Entries found"),
idx, choices);
if (showAll)
idx = wxGetSingleChoiceIndex(_("Help Index"),
_("Help Index"),
idx, choices);
else
idx = wxGetSingleChoiceIndex(_("Relevant entries:"),
_("Entries found"),
idx, choices);
if (idx >= 0)
rc = DisplayHelp(urls[idx]);
break;

View File

@ -211,7 +211,7 @@ void wxVLogStatus(wxFrame *pFrame, const wxChar *szFormat, va_list argptr)
}
}
void wxLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...)
void wxDoLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, szFormat);

View File

@ -643,7 +643,10 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
bool hasNext = HasNextPage(m_page);
if ( btnLabelWasNext != hasNext )
{
m_btnNext->SetLabel(hasNext ? _("&Next >") : _("&Finish"));
if ( hasNext )
m_btnNext->SetLabel(_("&Next >"));
else
m_btnNext->SetLabel(_("&Finish"));
}
// nothing to do: the label was already correct

View File

@ -35,7 +35,7 @@ static wxString LINKAGEMODE HtmlizeWhitespaces(const wxString& str)
size_t linepos = 0;
for (size_t i = 0; i < len; i++)
{
switch (str[i])
switch ( str[i].GetValue() )
{
case wxT('<'):
while (i < len && str[i] != wxT('>'))

View File

@ -220,7 +220,8 @@ wxChoice::~wxChoice()
int wxChoice::DoAppend(const wxString& item)
{
int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LPARAM)item.c_str());
int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0,
(LPARAM)item.wx_str());
if ( n == CB_ERR )
{
wxLogLastError(wxT("SendMessage(CB_ADDSTRING)"));
@ -242,7 +243,8 @@ int wxChoice::DoInsert(const wxString& item, unsigned int pos)
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
int n = (int)SendMessage(GetHwnd(), CB_INSERTSTRING, pos, (LPARAM)item.c_str());
int n = (int)SendMessage(GetHwnd(), CB_INSERTSTRING, pos,
(LPARAM)item.wx_str());
if ( n == CB_ERR )
{
wxLogLastError(wxT("SendMessage(CB_INSERTSTRING)"));
@ -368,7 +370,7 @@ int wxChoice::FindString(const wxString& s, bool bCase) const
else
{
int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT,
(WPARAM)-1, (LPARAM)s.c_str());
(WPARAM)-1, (LPARAM)s.wx_str());
return pos == LB_ERR ? wxNOT_FOUND : pos;
}
@ -394,7 +396,7 @@ void wxChoice::SetString(unsigned int n, const wxString& s)
}
::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0);
::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.c_str() );
::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.wx_str() );
if ( data )
{

View File

@ -978,7 +978,7 @@ static HSZ DDEAtomFromString(const wxString& s)
{
wxASSERT_MSG( DDEIdInst, _T("DDE not initialized") );
HSZ hsz = DdeCreateStringHandle(DDEIdInst, (wxChar*) s.c_str(), DDE_CP);
HSZ hsz = DdeCreateStringHandle(DDEIdInst, (wxChar*)s.wx_str(), DDE_CP);
if ( !hsz )
{
DDELogError(_("Failed to create DDE string"));

View File

@ -184,7 +184,10 @@ bool wxDirData::Read(wxString *filename)
{
filespec += _T('\\');
}
filespec += (!m_filespec ? _T("*.*") : m_filespec.c_str());
if ( !m_filespec )
filespec += _T("*.*");
else
filespec += m_filespec;
m_finddata = FindFirst(filespec, PTR_TO_FINDDATA);

View File

@ -134,7 +134,7 @@ int wxDirDialog::ShowModal()
#endif
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)m_path.c_str(); // param for the callback
bi.lParam = (LPARAM)m_path.wx_str(); // param for the callback
static const int verComCtl32 = wxApp::GetComCtl32Version();
@ -234,7 +234,7 @@ BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
}
SendMessage(hwnd, BFFM_SETSTATUSTEXT,
0, (LPARAM)strDir.c_str());
0, (LPARAM)strDir.wx_str());
}
}
break;

View File

@ -482,7 +482,9 @@ wxVideoMode wxDisplayImplWin32Base::GetCurrentMode() const
// according to MSDN. The version of GetName() we implement for Win95
// returns an empty string.
const wxString name = GetName();
const wxChar * const deviceName = name.empty() ? NULL : name.c_str();
const wxChar * const deviceName = name.empty()
? (const wxChar*)NULL
: (const wxChar*)name.c_str();
DEVMODE dm;
dm.dmSize = sizeof(dm);
@ -669,7 +671,9 @@ wxDisplayImplMultimon::GetModes(const wxVideoMode& modeMatch) const
// according to MSDN. The version of GetName() we implement for Win95
// returns an empty string.
const wxString name = GetName();
const wxChar * const deviceName = name.empty() ? NULL : name.c_str();
const wxChar * const deviceName = name.empty()
? (const wxChar*)NULL
: (const wxChar*)name.c_str();
DEVMODE dm;
dm.dmSize = sizeof(dm);

View File

@ -191,7 +191,7 @@ wxString wxVersionDLL::GetFileVersion(const wxString& filename) const
wxString ver;
if ( m_dll.IsLoaded() )
{
wxChar *pc = wx_const_cast(wxChar *, filename.c_str());
wxChar *pc = wx_const_cast(wxChar *, filename.wx_str());
DWORD dummy;
DWORD sizeVerInfo = m_pfnGetFileVersionInfoSize(pc, &dummy);

View File

@ -57,7 +57,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
// we must pass NULL if the string is empty to metafile functions
static inline const wxChar *GetMetaFileName(const wxString& fn)
{ return !fn ? (wxChar *)NULL : fn.c_str(); }
{ return !fn ? (const wxChar *)NULL : (const wxChar*)fn.c_str(); }
// ============================================================================
// implementation

View File

@ -391,7 +391,7 @@ int wxFileDialog::ShowModal()
}
}
of.lpstrFilter = (LPTSTR)filterBuffer.c_str();
of.lpstrFilter = (LPTSTR)filterBuffer.wx_str();
of.nFilterIndex = m_filterIndex + 1;
//=== Setting defaultFileName >>=========================================

View File

@ -822,7 +822,7 @@ wxString wxNativeFontInfo::ToString() const
lf.lfClipPrecision,
lf.lfQuality,
lf.lfPitchAndFamily,
lf.lfFaceName);
(const wxChar*)lf.lfFaceName);
return s;
}

View File

@ -3040,7 +3040,7 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl,
else
{
// pszText is not const, hence the cast
lvItem.pszText = (wxChar *)info.m_text.c_str();
lvItem.pszText = (wxChar *)info.m_text.wx_str();
if ( lvItem.pszText )
lvItem.cchTextMax = info.m_text.length();
else
@ -3061,7 +3061,7 @@ static void wxConvertToMSWListCol(HWND hwndList,
if ( item.m_mask & wxLIST_MASK_TEXT )
{
lvCol.mask |= LVCF_TEXT;
lvCol.pszText = (wxChar *)item.m_text.c_str(); // cast is safe
lvCol.pszText = (wxChar *)item.m_text.wx_str(); // cast is safe
}
if ( item.m_mask & wxLIST_MASK_FORMAT )

View File

@ -185,7 +185,7 @@ bool wxHandleFatalExceptions(bool doit)
wxString name = wxString::Format
(
_T("%s_%s_%lu.dmp"),
wxTheApp ? wxTheApp->GetAppName().c_str()
wxTheApp ? (const wxChar*)wxTheApp->GetAppName().c_str()
: _T("wxwindows"),
wxDateTime::Now().Format(_T("%Y%m%dT%H%M%S")).c_str(),
::GetCurrentProcessId()

View File

@ -468,7 +468,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
}
mii.cch = itemText.length();
mii.dwTypeData = wx_const_cast(wxChar *, itemText.c_str());
mii.dwTypeData = wx_const_cast(wxChar *, itemText.wx_str());
if (flags & MF_POPUP)
{
@ -548,7 +548,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
itemText = wxMenuItem::GetLabelFromText(itemText);
#endif
pData = (wxChar*)itemText.c_str();
pData = (wxChar*)itemText.wx_str();
}
// item might have already been inserted by InsertMenuItem() above

View File

@ -392,7 +392,7 @@ void wxMenuItem::SetText(const wxString& txt)
#endif //owner drawn
{
flagsOld |= MF_STRING;
data = (wxChar*) m_text.c_str();
data = (wxChar*) m_text.wx_str();
}
#ifdef __WXWINCE__

View File

@ -505,7 +505,7 @@ bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = (wxChar *)strText.c_str();
tcItem.pszText = (wxChar *)strText.wx_str();
if ( !HasFlag(wxNB_MULTILINE) )
return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0;
@ -773,7 +773,7 @@ bool wxNotebook::InsertPage(size_t nPage,
if ( !strText.empty() )
{
tcItem.mask |= TCIF_TEXT;
tcItem.pszText = (wxChar *)strText.c_str(); // const_cast
tcItem.pszText = (wxChar *)strText.wx_str(); // const_cast
}
// hide the page: unless it is selected, it shouldn't be shown (and if it

View File

@ -355,7 +355,8 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc,
SIZE sizeRect;
::GetTextExtentPoint32(hdc, strMenuText.c_str(), strMenuText.length(), &sizeRect);
::DrawState(hdc, NULL, NULL,
(LPARAM)strMenuText.c_str(), strMenuText.length(),
(LPARAM)strMenuText.wx_str(),
strMenuText.length(),
xText, rc.y + (int) ((rc.GetHeight()-sizeRect.cy)/2.0), // centre text vertically
rc.GetWidth()-margin, sizeRect.cy,
DST_PREFIXTEXT |
@ -372,7 +373,8 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc,
// right align accel string with right edge of menu ( offset by the
// margin width )
::DrawState(hdc, NULL, NULL,
(LPARAM)m_strAccel.c_str(), m_strAccel.length(),
(LPARAM)m_strAccel.wx_str(),
m_strAccel.length(),
rc.GetWidth()-16-accel_width, rc.y+(int) ((rc.GetHeight()-sizeRect.cy)/2.0),
0, 0,
DST_TEXT |

View File

@ -967,7 +967,7 @@ bool wxRegKey::SetValue(const wxChar *szValue, const wxString& strValue)
{
if ( CONST_CAST Open() ) {
m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, (DWORD) RESERVED, REG_SZ,
(RegString)strValue.c_str(),
(RegString)strValue.wx_str(),
(strValue.Len() + 1)*sizeof(wxChar));
if ( m_dwLastError == ERROR_SUCCESS )
return true;

View File

@ -856,7 +856,7 @@ bool wxToolBar::Realize()
{
const wxString& label = tool->GetLabel();
if ( !label.empty() )
button.iString = (int)label.c_str();
button.iString = (int)label.wx_str();
}
button.idCommand = tool->GetId();

View File

@ -1115,7 +1115,7 @@ void wxTextCtrl::DoWriteText(const wxString& value, int flags)
::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
// EM_REPLACESEL takes 1 to indicate the operation should be redoable
selectionOnly ? 1 : 0, (LPARAM)valueDos.c_str());
selectionOnly ? 1 : 0, (LPARAM)valueDos.wx_str());
if ( !ucf.GotUpdate() && (flags & SetValue_SendEvent) )
{

View File

@ -291,7 +291,7 @@ void wxToolTip::Add(WXHWND hWnd)
// NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips
// of any length
ti.hwnd = hwnd;
ti.lpszText = (wxChar *)m_text.c_str(); // const_cast
ti.lpszText = (wxChar *)m_text.wx_str(); // const_cast
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
{
@ -360,7 +360,7 @@ void wxToolTip::Add(WXHWND hWnd)
// replace the '\n's with spaces because otherwise they appear as
// unprintable characters in the tooltip string
m_text.Replace(_T("\n"), _T(" "));
ti.lpszText = (wxChar *)m_text.c_str(); // const_cast
ti.lpszText = (wxChar *)m_text.wx_str(); // const_cast
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
{
@ -434,7 +434,7 @@ void wxToolTip::SetTip(const wxString& tip)
{
// update the tip text shown by the control
wxToolInfo ti(GetHwndOf(m_window));
ti.lpszText = (wxChar *)m_text.c_str();
ti.lpszText = (wxChar *)m_text.wx_str();
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti);
}

View File

@ -923,7 +923,7 @@ void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text)
return;
wxTreeViewItem tvItem(item, TVIF_TEXT);
tvItem.pszText = (wxChar *)text.c_str(); // conversion is ok
tvItem.pszText = (wxChar *)text.wx_str(); // conversion is ok
DoSetItem(&tvItem);
// when setting the text of the item being edited, the text control should
@ -1434,7 +1434,7 @@ wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent,
if ( !text.empty() )
{
mask |= TVIF_TEXT;
tvIns.item.pszText = (wxChar *)text.c_str(); // cast is ok
tvIns.item.pszText = (wxChar *)text.wx_str(); // cast is ok
}
else
{

View File

@ -723,13 +723,13 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
// Win32 allows for null
#ifdef __WXWINCE__
(wxChar *)
moduleName.c_str(), // application name
moduleName.wx_str(),// application name
(wxChar *)
arguments.c_str(), // arguments
arguments.wx_str(), // arguments
#else
NULL, // application name (use only cmd line)
(wxChar *)
command.c_str(), // full command line
command.wx_str(), // full command line
#endif
NULL, // security attributes: defaults for both
NULL, // the process and its main thread

View File

@ -3450,7 +3450,7 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
(
extendedStyle,
className,
title ? title : m_windowName.c_str(),
title ? title : (const wxChar*)m_windowName.c_str(),
style,
x, y, w, h,
(HWND)MSWGetParent(),

View File

@ -8201,8 +8201,8 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageT
int i;
for (i = 0; i < dataSize; i ++)
{
str[0] = stream.GetC();
str[1] = stream.GetC();
str[0] = (char)stream.GetC();
str[1] = (char)stream.GetC();
m_data[i] = (unsigned char)wxHexToDec(str);
}

View File

@ -271,14 +271,12 @@ void *wxDynamicLibrary::RawGetSymbol(wxDllType handle, const wxString& name)
/* static */
void wxDynamicLibrary::Error()
{
#if wxUSE_UNICODE
wxWCharBuffer buffer = wxConvLocal.cMB2WC( dlerror() );
const wxChar *err = buffer;
#else
const wxChar *err = dlerror();
#endif
wxString err(dlerror());
wxLogError(wxT("%s"), err ? err : _("Unknown dynamic library error"));
if ( err.empty() )
err = _("Unknown dynamic library error");
wxLogError(wxT("%s"), err);
}
#endif // wxHAVE_DYNLIB_ERROR

View File

@ -394,7 +394,7 @@ int wxJoystick::GetNumberButtons() const
if (m_device != -1)
ioctl(m_device, JSIOCGBUTTONS, &nb);
if (nb > wxJS_MAX_BUTTONS)
if ((int)nb > wxJS_MAX_BUTTONS)
nb = wxJS_MAX_BUTTONS;
return nb;
@ -407,7 +407,7 @@ int wxJoystick::GetNumberAxes() const
if (m_device != -1)
ioctl(m_device, JSIOCGAXES, &nb);
if (nb > wxJS_MAX_AXES)
if ((int)nb > wxJS_MAX_AXES)
nb = wxJS_MAX_AXES;
return nb;

View File

@ -1,6 +1,6 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
# Bakefile 0.2.2 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
@ -71,7 +71,9 @@ TEST_OBJECTS = \
test_strings.o \
test_stdstrings.o \
test_tokenizer.o \
test_unichar.o \
test_unicode.o \
test_vararg.o \
test_crt.o \
test_vsnprintf.o \
test_bstream.o \
@ -360,9 +362,15 @@ test_stdstrings.o: $(srcdir)/strings/stdstrings.cpp $(TEST_ODEP)
test_tokenizer.o: $(srcdir)/strings/tokenizer.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/strings/tokenizer.cpp
test_unichar.o: $(srcdir)/strings/unichar.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/strings/unichar.cpp
test_unicode.o: $(srcdir)/strings/unicode.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/strings/unicode.cpp
test_vararg.o: $(srcdir)/strings/vararg.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/strings/vararg.cpp
test_crt.o: $(srcdir)/strings/crt.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/strings/crt.cpp
@ -409,7 +417,7 @@ test_uris.o: $(srcdir)/uris/uris.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/uris/uris.cpp
test_gui_sample_rc.o: $(srcdir)/../samples/sample.rc $(TEST_GUI_ODEP)
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_5) $(__EXCEPTIONS_DEFINE_p_5) $(__RTTI_DEFINE_p_5) $(__THREAD_DEFINE_p_5) --include-dir $(srcdir) $(__DLLFLAG_p_5) --include-dir $(srcdir)/../samples $(__RCDEFDIR_p_1) --include-dir $(top_srcdir)/include
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_5) $(__EXCEPTIONS_DEFINE_p_5) $(__RTTI_DEFINE_p_5) $(__THREAD_DEFINE_p_5) --include-dir $(srcdir) $(__DLLFLAG_p_5) --include-dir $(srcdir)/../samples $(__RCDEFDIR_p_1) --include-dir $(top_srcdir)/include
test_gui_test.o: $(srcdir)/test.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/test.cpp

View File

@ -1,6 +1,6 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
# Bakefile 0.2.2 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
@ -59,7 +59,9 @@ TEST_OBJECTS = \
$(OBJS)\test_strings.obj \
$(OBJS)\test_stdstrings.obj \
$(OBJS)\test_tokenizer.obj \
$(OBJS)\test_unichar.obj \
$(OBJS)\test_unicode.obj \
$(OBJS)\test_vararg.obj \
$(OBJS)\test_crt.obj \
$(OBJS)\test_vsnprintf.obj \
$(OBJS)\test_bstream.obj \
@ -396,9 +398,15 @@ $(OBJS)\test_stdstrings.obj: .\strings\stdstrings.cpp
$(OBJS)\test_tokenizer.obj: .\strings\tokenizer.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_unichar.obj: .\strings\unichar.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_unicode.obj: .\strings\unicode.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_vararg.obj: .\strings\vararg.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_crt.obj: .\strings\crt.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
@ -445,7 +453,7 @@ $(OBJS)\test_uris.obj: .\uris\uris.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_gui_sample.res: .\..\samples\sample.rc
brcc32 -32 -r -fo$@ -i$(BCCDIR)\include -d__WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) -i$(SETUPHDIR) -i.\..\include -i. $(__DLLFLAG_p_3) -i.\..\samples $**
brcc32 -32 -r -fo$@ -i$(BCCDIR)\include -d__WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) -i$(SETUPHDIR) -i.\..\include -i. $(__DLLFLAG_p_3) -i.\..\samples -dNOPCH $**
$(OBJS)\test_gui_dummy.obj: .\dummy.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) -H $**

View File

@ -1,6 +1,6 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
# Bakefile 0.2.2 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
@ -51,7 +51,9 @@ TEST_OBJECTS = \
$(OBJS)\test_strings.o \
$(OBJS)\test_stdstrings.o \
$(OBJS)\test_tokenizer.o \
$(OBJS)\test_unichar.o \
$(OBJS)\test_unicode.o \
$(OBJS)\test_vararg.o \
$(OBJS)\test_crt.o \
$(OBJS)\test_vsnprintf.o \
$(OBJS)\test_bstream.o \
@ -374,9 +376,15 @@ $(OBJS)\test_stdstrings.o: ./strings/stdstrings.cpp
$(OBJS)\test_tokenizer.o: ./strings/tokenizer.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_unichar.o: ./strings/unichar.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_unicode.o: ./strings/unicode.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_vararg.o: ./strings/vararg.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_crt.o: ./strings/crt.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
@ -423,7 +431,7 @@ $(OBJS)\test_uris.o: ./uris/uris.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_sample_rc.o: ./../samples/sample.rc
windres --use-temp-file -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) --include-dir $(SETUPHDIR) --include-dir ./../include --include-dir . $(__DLLFLAG_p_3) --include-dir ./../samples
windres --use-temp-file -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) --include-dir $(SETUPHDIR) --include-dir ./../include --include-dir . $(__DLLFLAG_p_3) --include-dir ./../samples --define NOPCH
$(OBJS)\test_gui_dummy.o: ./dummy.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<

View File

@ -1,6 +1,6 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
# Bakefile 0.2.2 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
@ -51,7 +51,9 @@ TEST_OBJECTS = \
$(OBJS)\test_strings.obj \
$(OBJS)\test_stdstrings.obj \
$(OBJS)\test_tokenizer.obj \
$(OBJS)\test_unichar.obj \
$(OBJS)\test_unicode.obj \
$(OBJS)\test_vararg.obj \
$(OBJS)\test_crt.obj \
$(OBJS)\test_vsnprintf.obj \
$(OBJS)\test_bstream.obj \
@ -77,8 +79,8 @@ TEST_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_23)$(__DEBUGRUNTIME) /DWIN32 \
$(__EXCEPTIONSFLAG) /Yu"testprec.h" /Fp"$(OBJS)\testprec_test_gui.pch" \
$(CPPFLAGS) $(CXXFLAGS)
TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_sample.res \
$(OBJS)\test_gui_dummy.obj \
$(OBJS)\test_gui_sample.res \
$(OBJS)\test_gui_test.obj \
$(OBJS)\test_gui_rect.obj \
$(OBJS)\test_gui_size.obj \
@ -480,9 +482,15 @@ $(OBJS)\test_stdstrings.obj: .\strings\stdstrings.cpp
$(OBJS)\test_tokenizer.obj: .\strings\tokenizer.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_unichar.obj: .\strings\unichar.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_unicode.obj: .\strings\unicode.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_vararg.obj: .\strings\vararg.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_crt.obj: .\strings\crt.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
@ -528,12 +536,12 @@ $(OBJS)\test_textfiletest.obj: .\textfile\textfiletest.cpp
$(OBJS)\test_uris.obj: .\uris\uris.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
$(OBJS)\test_gui_sample.res: .\..\samples\sample.rc
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_17_p_1) $(__NO_VC_CRTDBG_p_3) /d __WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) /i $(SETUPHDIR) /i .\..\include /i . $(__DLLFLAG_p_3) /i .\..\samples $**
$(OBJS)\test_gui_dummy.obj: .\dummy.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) /Yctestprec.h $**
$(OBJS)\test_gui_sample.res: .\..\samples\sample.rc
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_17_p_1) $(__NO_VC_CRTDBG_p_3) /d __WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) $(__GFXCTX_DEFINE_p_3) /i $(SETUPHDIR) /i .\..\include /i . $(__DLLFLAG_p_3) /i .\..\samples /d NOPCH /d _CONSOLE $**
$(OBJS)\test_gui_test.obj: .\test.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) $**

View File

@ -1,6 +1,6 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
# Bakefile 0.2.2 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
@ -256,7 +256,9 @@ TEST_OBJECTS = &
$(OBJS)\test_strings.obj &
$(OBJS)\test_stdstrings.obj &
$(OBJS)\test_tokenizer.obj &
$(OBJS)\test_unichar.obj &
$(OBJS)\test_unicode.obj &
$(OBJS)\test_vararg.obj &
$(OBJS)\test_crt.obj &
$(OBJS)\test_vsnprintf.obj &
$(OBJS)\test_bstream.obj &
@ -429,9 +431,15 @@ $(OBJS)\test_stdstrings.obj : .AUTODEPEND .\strings\stdstrings.cpp
$(OBJS)\test_tokenizer.obj : .AUTODEPEND .\strings\tokenizer.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_unichar.obj : .AUTODEPEND .\strings\unichar.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_unicode.obj : .AUTODEPEND .\strings\unicode.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_vararg.obj : .AUTODEPEND .\strings\vararg.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_crt.obj : .AUTODEPEND .\strings\crt.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
@ -478,7 +486,7 @@ $(OBJS)\test_uris.obj : .AUTODEPEND .\uris\uris.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_gui_sample.res : .AUTODEPEND .\..\samples\sample.rc
wrc -q -ad -bt=nt -r -fo=$^@ -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) $(__GFXCTX_DEFINE_p) -i=$(SETUPHDIR) -i=.\..\include -i=. $(__DLLFLAG_p) -i=.\..\samples $<
wrc -q -ad -bt=nt -r -fo=$^@ -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) $(__GFXCTX_DEFINE_p) -i=$(SETUPHDIR) -i=.\..\include -i=. $(__DLLFLAG_p) -i=.\..\samples -dNOPCH $<
$(OBJS)\test_gui_dummy.obj : .AUTODEPEND .\dummy.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<

View File

@ -74,7 +74,7 @@ strStream::strStream()
m_str.reserve(LEN);
for ( size_t n = 0; n < LEN; n++ )
{
m_str += _T('A') + n % (_T('Z') - _T('A') + 1);
m_str += wxChar(_T('A') + n % (_T('Z') - _T('A') + 1));
}
}

View File

@ -451,19 +451,19 @@ void StdStringTestCase::StdRiter()
const wxString s(_T("fozbar"));
wxString::const_reverse_iterator ri(s.rbegin());
CPPUNIT_ASSERT_EQUAL( _T('r'), *ri );
CPPUNIT_ASSERT_EQUAL( _T('a'), *++ri );
CPPUNIT_ASSERT_EQUAL( _T('r'), *--ri );
CPPUNIT_ASSERT( _T('r') == *ri );
CPPUNIT_ASSERT( _T('a') == *++ri );
CPPUNIT_ASSERT( _T('r') == *--ri );
ri = s.rend();
ri--;
CPPUNIT_ASSERT_EQUAL( _T('f'), *ri );
CPPUNIT_ASSERT( _T('f') == *ri );
--ri;
CPPUNIT_ASSERT_EQUAL( _T('o'), *ri );
CPPUNIT_ASSERT( _T('o') == *ri );
wxString::const_iterator i = ri.base();
CPPUNIT_ASSERT_EQUAL( _T('z'), *i );
CPPUNIT_ASSERT( _T('z') == *i );
}
void StdStringTestCase::StdSubstr()

View File

@ -630,9 +630,10 @@ void StringTestCase::WriteBuf()
wxString s;
wxStrcpy(wxStringBuffer(s, 10), _T("foo"));
CPPUNIT_ASSERT_EQUAL(_T('f'), s[0u]);
CPPUNIT_ASSERT_EQUAL(_T('o'), s[1]);
CPPUNIT_ASSERT_EQUAL(_T('o'), s[2]);
CPPUNIT_ASSERT(s[0u] == _T('f') );
CPPUNIT_ASSERT(_T('f') == s[0u]);
CPPUNIT_ASSERT(_T('o') == s[1]);
CPPUNIT_ASSERT(_T('o') == s[2]);
CPPUNIT_ASSERT_EQUAL((size_t)3, s.length());
@ -642,10 +643,10 @@ void StringTestCase::WriteBuf()
buf.SetLength(4);
}
CPPUNIT_ASSERT_EQUAL(_T('b'), s[0u]);
CPPUNIT_ASSERT_EQUAL(_T('a'), s[1]);
CPPUNIT_ASSERT_EQUAL(_T('r'), s[2]);
CPPUNIT_ASSERT_EQUAL(_T('r'), s[3]);
CPPUNIT_ASSERT(_T('b') == s[0u]);
CPPUNIT_ASSERT(_T('a') == s[1]);
CPPUNIT_ASSERT(_T('r') == s[2]);
CPPUNIT_ASSERT(_T('r') == s[3]);
CPPUNIT_ASSERT_EQUAL((size_t)4, s.length());
CPPUNIT_ASSERT_EQUAL( 0, wxStrcmp(_T("barr"), s) );

236
tests/strings/unichar.cpp Normal file
View File

@ -0,0 +1,236 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/strings/unichar.cpp
// Purpose: Test for wxUniChar class
// Author: Vaclav Slavik
// Created: 2007-03-11
// RCS-ID: $Id$
// Copyright: (c) 2007 REA Elektronik GmbH
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "testprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif // WX_PRECOMP
#include "wx/string.h"
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
class UniCharTestCase : public CppUnit::TestCase
{
public:
UniCharTestCase() {}
private:
CPPUNIT_TEST_SUITE( UniCharTestCase );
CPPUNIT_TEST( CharCompare );
CPPUNIT_TEST( CharCompareIntl );
CPPUNIT_TEST( StringCompare );
CPPUNIT_TEST( StringCompareIntl );
CPPUNIT_TEST_SUITE_END();
void CharCompare();
void CharCompareIntl();
void StringCompare();
void StringCompareIntl();
DECLARE_NO_COPY_CLASS(UniCharTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( UniCharTestCase );
// also include in it's own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UniCharTestCase, "UniCharTestCase" );
void UniCharTestCase::CharCompare()
{
wxUniChar a('a');
wxUniChar b('b');
CPPUNIT_ASSERT( a == a );
CPPUNIT_ASSERT( a == 'a' );
CPPUNIT_ASSERT( a == _T('a') );
CPPUNIT_ASSERT( a == wxUniChar('a') );
CPPUNIT_ASSERT( a == wxUniChar(_T('a')) );
CPPUNIT_ASSERT( a != b );
CPPUNIT_ASSERT( a != 'b' );
CPPUNIT_ASSERT( a != _T('b') );
CPPUNIT_ASSERT( a != wxUniChar('b') );
CPPUNIT_ASSERT( a != wxUniChar(_T('b')) );
CPPUNIT_ASSERT( a < b );
CPPUNIT_ASSERT( a < 'b' );
CPPUNIT_ASSERT( a < _T('b') );
CPPUNIT_ASSERT( a < wxUniChar('b') );
CPPUNIT_ASSERT( a < wxUniChar(_T('b')) );
CPPUNIT_ASSERT( a <= b );
CPPUNIT_ASSERT( a <= 'b' );
CPPUNIT_ASSERT( a <= _T('b') );
CPPUNIT_ASSERT( a <= wxUniChar('b') );
CPPUNIT_ASSERT( a <= wxUniChar(_T('b')) );
CPPUNIT_ASSERT( a <= a );
CPPUNIT_ASSERT( a <= 'a' );
CPPUNIT_ASSERT( a <= _T('a') );
CPPUNIT_ASSERT( a <= wxUniChar('a') );
CPPUNIT_ASSERT( a <= wxUniChar(_T('a')) );
CPPUNIT_ASSERT( b > a );
CPPUNIT_ASSERT( b > 'a' );
CPPUNIT_ASSERT( b > _T('a') );
CPPUNIT_ASSERT( b > wxUniChar('a') );
CPPUNIT_ASSERT( b > wxUniChar(_T('a')) );
CPPUNIT_ASSERT( b >= a );
CPPUNIT_ASSERT( b >= 'a' );
CPPUNIT_ASSERT( b >= _T('a') );
CPPUNIT_ASSERT( b >= wxUniChar('a') );
CPPUNIT_ASSERT( b >= wxUniChar(_T('a')) );
CPPUNIT_ASSERT( b >= b );
CPPUNIT_ASSERT( b >= 'b' );
CPPUNIT_ASSERT( b >= _T('b') );
CPPUNIT_ASSERT( b >= wxUniChar('b') );
CPPUNIT_ASSERT( b >= wxUniChar(_T('b')) );
CPPUNIT_ASSERT( b - a == 1 );
CPPUNIT_ASSERT( a - b == -1 );
}
#define CYRILLIC_SMALL_LETTER_YU ((wchar_t)0x044E)
#define ARABIC_LETTER_NOON ((wchar_t)0x0646)
void UniCharTestCase::CharCompareIntl()
{
wxUniChar a(CYRILLIC_SMALL_LETTER_YU);
wxUniChar b(ARABIC_LETTER_NOON);
CPPUNIT_ASSERT( a == a );
CPPUNIT_ASSERT( a == CYRILLIC_SMALL_LETTER_YU );
CPPUNIT_ASSERT( a == wxUniChar(CYRILLIC_SMALL_LETTER_YU) );
CPPUNIT_ASSERT( a != b );
CPPUNIT_ASSERT( a != ARABIC_LETTER_NOON );
CPPUNIT_ASSERT( a != wxUniChar(ARABIC_LETTER_NOON) );
CPPUNIT_ASSERT( a < b );
CPPUNIT_ASSERT( a < ARABIC_LETTER_NOON );
CPPUNIT_ASSERT( a < wxUniChar(ARABIC_LETTER_NOON) );
CPPUNIT_ASSERT( a <= b );
CPPUNIT_ASSERT( a <= ARABIC_LETTER_NOON );
CPPUNIT_ASSERT( a <= wxUniChar(ARABIC_LETTER_NOON) );
CPPUNIT_ASSERT( a <= a );
CPPUNIT_ASSERT( a <= CYRILLIC_SMALL_LETTER_YU );
CPPUNIT_ASSERT( a <= wxUniChar(CYRILLIC_SMALL_LETTER_YU) );
CPPUNIT_ASSERT( b > a );
CPPUNIT_ASSERT( b > CYRILLIC_SMALL_LETTER_YU );
CPPUNIT_ASSERT( b > wxUniChar(CYRILLIC_SMALL_LETTER_YU) );
CPPUNIT_ASSERT( b >= a );
CPPUNIT_ASSERT( b >= CYRILLIC_SMALL_LETTER_YU );
CPPUNIT_ASSERT( b >= wxUniChar(CYRILLIC_SMALL_LETTER_YU) );
CPPUNIT_ASSERT( b >= b );
CPPUNIT_ASSERT( b >= ARABIC_LETTER_NOON );
CPPUNIT_ASSERT( b >= wxUniChar(ARABIC_LETTER_NOON) );
CPPUNIT_ASSERT( b - a == 504 );
CPPUNIT_ASSERT( a - b == -504 );
}
void UniCharTestCase::StringCompare()
{
// test string comparison with chars
wxString sa = "a";
const wxString sb = "b";
char c1 = 'a';
wchar_t c2 = _T('a');
wxUniChar c3 = 'a';
CPPUNIT_ASSERT( sa == 'a');
CPPUNIT_ASSERT( 'a' == sa);
CPPUNIT_ASSERT( sb != 'a');
CPPUNIT_ASSERT( 'a' != sb);
CPPUNIT_ASSERT( sa == c1);
CPPUNIT_ASSERT( c1 == sa);
CPPUNIT_ASSERT( sb != c1);
CPPUNIT_ASSERT( c1 != sb);
CPPUNIT_ASSERT( sa == c2);
CPPUNIT_ASSERT( c2 == sa);
CPPUNIT_ASSERT( sb != c2);
CPPUNIT_ASSERT( c2 != sb);
CPPUNIT_ASSERT( sa == c3);
CPPUNIT_ASSERT( c3 == sa);
CPPUNIT_ASSERT( sb != c3);
CPPUNIT_ASSERT( c3 != sb);
// test wxUniCharRef:
CPPUNIT_ASSERT( sa == sa[0]);
CPPUNIT_ASSERT( sa[0] == sa);
CPPUNIT_ASSERT( sb != sa[0]);
CPPUNIT_ASSERT( sa[0] != sb);
// test const version of operator[] (returns wxUniChar, not wxUniCharRef):
CPPUNIT_ASSERT( sb == sb[0]);
CPPUNIT_ASSERT( sb[0] == sb);
CPPUNIT_ASSERT( sa != sb[0]);
CPPUNIT_ASSERT( sb[0] != sa);
}
void UniCharTestCase::StringCompareIntl()
{
// test string comparison with chars
wxString sa = CYRILLIC_SMALL_LETTER_YU;
const wxString sb = ARABIC_LETTER_NOON;
wchar_t c2 = CYRILLIC_SMALL_LETTER_YU;
wxUniChar c3 = CYRILLIC_SMALL_LETTER_YU;
CPPUNIT_ASSERT( sa == CYRILLIC_SMALL_LETTER_YU);
CPPUNIT_ASSERT( CYRILLIC_SMALL_LETTER_YU == sa);
CPPUNIT_ASSERT( sb != CYRILLIC_SMALL_LETTER_YU);
CPPUNIT_ASSERT( CYRILLIC_SMALL_LETTER_YU != sb);
CPPUNIT_ASSERT( sa == c2);
CPPUNIT_ASSERT( c2 == sa);
CPPUNIT_ASSERT( sb != c2);
CPPUNIT_ASSERT( c2 != sb);
CPPUNIT_ASSERT( sa == c3);
CPPUNIT_ASSERT( c3 == sa);
CPPUNIT_ASSERT( sb != c3);
CPPUNIT_ASSERT( c3 != sb);
// test wxUniCharRef:
CPPUNIT_ASSERT( sa == sa[0]);
CPPUNIT_ASSERT( sa[0] == sa);
CPPUNIT_ASSERT( sb != sa[0]);
CPPUNIT_ASSERT( sa[0] != sb);
// test const version of operator[] (returns wxUniChar, not wxUniCharRef):
CPPUNIT_ASSERT( sb == sb[0]);
CPPUNIT_ASSERT( sb[0] == sb);
CPPUNIT_ASSERT( sa != sb[0]);
CPPUNIT_ASSERT( sb[0] != sa);
}

67
tests/strings/vararg.cpp Normal file
View File

@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/strings/vararg.cpp
// Purpose: Test for wx vararg look-alike macros
// Author: Vaclav Slavik
// Created: 2007-02-20
// RCS-ID: $Id$
// Copyright: (c) 2007 REA Elektronik GmbH
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "testprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif // WX_PRECOMP
#include "wx/string.h"
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
class VarArgTestCase : public CppUnit::TestCase
{
public:
VarArgTestCase() {}
private:
CPPUNIT_TEST_SUITE( VarArgTestCase );
CPPUNIT_TEST( StringPrintf );
CPPUNIT_TEST_SUITE_END();
void StringPrintf();
DECLARE_NO_COPY_CLASS(VarArgTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( VarArgTestCase );
// also include in it's own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VarArgTestCase, "VarArgTestCase" );
void VarArgTestCase::StringPrintf()
{
wxString s, s2;
s.Printf("%s %i", "foo", 42);
CPPUNIT_ASSERT( s == "foo 42" );
s.Printf("%s %s %i", _T("bar"), "=", 11);
CPPUNIT_ASSERT( s == "bar = 11" );
s2.Printf("(%s)", s.c_str());
CPPUNIT_ASSERT( s2 == "(bar = 11)" );
s2.Printf(_T("[%s](%s)"), s.c_str(), "str");
CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
s2.Printf(_T("[%s](%s)"), s, "str");
CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
}

View File

@ -46,7 +46,9 @@
strings/strings.cpp
strings/stdstrings.cpp
strings/tokenizer.cpp
strings/unichar.cpp
strings/unicode.cpp
strings/vararg.cpp
strings/crt.cpp
strings/vsnprintf.cpp
streams/bstream.cpp

View File

@ -573,6 +573,10 @@ SOURCE=.\strings\tokenizer.cpp
# End Source File
# Begin Source File
SOURCE=.\strings\unichar.cpp
# End Source File
# Begin Source File
SOURCE=.\strings\unicode.cpp
# End Source File
# Begin Source File
@ -581,6 +585,10 @@ SOURCE=.\uris\uris.cpp
# End Source File
# Begin Source File
SOURCE=.\strings\vararg.cpp
# End Source File
# Begin Source File
SOURCE=.\strings\vsnprintf.cpp
# End Source File
# Begin Source File

View File

@ -295,6 +295,7 @@ wx/stopwatch.h
wx/strconv.h
wx/stream.h
wx/string.h
wx/strvararg.h
wx/sysopt.h
wx/tarstrm.h
wx/textbuf.h

View File

@ -198,6 +198,7 @@ wx/stopwatch.h
wx/strconv.h
wx/stream.h
wx/string.h
wx/strvararg.h
wx/sysopt.h
wx/tarstrm.h
wx/textbuf.h

View File

@ -223,6 +223,7 @@ wx/stopwatch.h
wx/strconv.h
wx/stream.h
wx/string.h
wx/strvararg.h
wx/sysopt.h
wx/tarstrm.h
wx/textbuf.h