moved primitive string and string iterators operations to stringops.h/cpp files to make wxString code easier to read
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e7308074d8
commit
467175ab3f
19
Makefile.in
19
Makefile.in
@ -400,6 +400,7 @@ ALL_BASE_HEADERS = \
|
||||
wx/stream.h \
|
||||
wx/string.h \
|
||||
wx/stringimpl.h \
|
||||
wx/stringops.h \
|
||||
wx/strvararg.h \
|
||||
wx/sysopt.h \
|
||||
wx/tarstrm.h \
|
||||
@ -541,6 +542,7 @@ ALL_PORTS_BASE_HEADERS = \
|
||||
wx/stream.h \
|
||||
wx/string.h \
|
||||
wx/stringimpl.h \
|
||||
wx/stringops.h \
|
||||
wx/strvararg.h \
|
||||
wx/sysopt.h \
|
||||
wx/tarstrm.h \
|
||||
@ -681,6 +683,7 @@ ALL_BASE_SOURCES = \
|
||||
src/common/stream.cpp \
|
||||
src/common/string.cpp \
|
||||
src/common/stringimpl.cpp \
|
||||
src/common/stringops.cpp \
|
||||
src/common/strvararg.cpp \
|
||||
src/common/sysopt.cpp \
|
||||
src/common/tarstrm.cpp \
|
||||
@ -844,6 +847,7 @@ MONODLL_OBJECTS = \
|
||||
monodll_stream.o \
|
||||
monodll_string.o \
|
||||
monodll_stringimpl.o \
|
||||
monodll_stringops.o \
|
||||
monodll_strvararg.o \
|
||||
monodll_sysopt.o \
|
||||
monodll_tarstrm.o \
|
||||
@ -953,6 +957,7 @@ MONOLIB_OBJECTS = \
|
||||
monolib_stream.o \
|
||||
monolib_string.o \
|
||||
monolib_stringimpl.o \
|
||||
monolib_stringops.o \
|
||||
monolib_strvararg.o \
|
||||
monolib_sysopt.o \
|
||||
monolib_tarstrm.o \
|
||||
@ -1059,6 +1064,7 @@ BASEDLL_OBJECTS = \
|
||||
basedll_stream.o \
|
||||
basedll_string.o \
|
||||
basedll_stringimpl.o \
|
||||
basedll_stringops.o \
|
||||
basedll_strvararg.o \
|
||||
basedll_sysopt.o \
|
||||
basedll_tarstrm.o \
|
||||
@ -1148,6 +1154,7 @@ BASELIB_OBJECTS = \
|
||||
baselib_stream.o \
|
||||
baselib_string.o \
|
||||
baselib_stringimpl.o \
|
||||
baselib_stringops.o \
|
||||
baselib_strvararg.o \
|
||||
baselib_sysopt.o \
|
||||
baselib_tarstrm.o \
|
||||
@ -13373,6 +13380,9 @@ monodll_string.o: $(srcdir)/src/common/string.cpp $(MONODLL_ODEP)
|
||||
monodll_stringimpl.o: $(srcdir)/src/common/stringimpl.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/stringimpl.cpp
|
||||
|
||||
monodll_stringops.o: $(srcdir)/src/common/stringops.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/stringops.cpp
|
||||
|
||||
monodll_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
|
||||
|
||||
@ -17552,6 +17562,9 @@ monolib_string.o: $(srcdir)/src/common/string.cpp $(MONOLIB_ODEP)
|
||||
monolib_stringimpl.o: $(srcdir)/src/common/stringimpl.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/stringimpl.cpp
|
||||
|
||||
monolib_stringops.o: $(srcdir)/src/common/stringops.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/stringops.cpp
|
||||
|
||||
monolib_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
|
||||
|
||||
@ -21731,6 +21744,9 @@ basedll_string.o: $(srcdir)/src/common/string.cpp $(BASEDLL_ODEP)
|
||||
basedll_stringimpl.o: $(srcdir)/src/common/stringimpl.cpp $(BASEDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/stringimpl.cpp
|
||||
|
||||
basedll_stringops.o: $(srcdir)/src/common/stringops.cpp $(BASEDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/stringops.cpp
|
||||
|
||||
basedll_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(BASEDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
|
||||
|
||||
@ -22334,6 +22350,9 @@ baselib_string.o: $(srcdir)/src/common/string.cpp $(BASELIB_ODEP)
|
||||
baselib_stringimpl.o: $(srcdir)/src/common/stringimpl.cpp $(BASELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/stringimpl.cpp
|
||||
|
||||
baselib_stringops.o: $(srcdir)/src/common/stringops.cpp $(BASELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/stringops.cpp
|
||||
|
||||
baselib_strvararg.o: $(srcdir)/src/common/strvararg.cpp $(BASELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/strvararg.cpp
|
||||
|
||||
|
@ -342,6 +342,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
src/common/stream.cpp
|
||||
src/common/string.cpp
|
||||
src/common/stringimpl.cpp
|
||||
src/common/stringops.cpp
|
||||
src/common/strvararg.cpp
|
||||
src/common/sysopt.cpp
|
||||
src/common/tarstrm.cpp
|
||||
@ -458,6 +459,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
wx/stream.h
|
||||
wx/string.h
|
||||
wx/stringimpl.h
|
||||
wx/stringops.h
|
||||
wx/strvararg.h
|
||||
wx/sysopt.h
|
||||
wx/tarstrm.h
|
||||
|
@ -346,6 +346,7 @@ MONODLL_OBJECTS = \
|
||||
$(OBJS)\monodll_stream.obj \
|
||||
$(OBJS)\monodll_string.obj \
|
||||
$(OBJS)\monodll_stringimpl.obj \
|
||||
$(OBJS)\monodll_stringops.obj \
|
||||
$(OBJS)\monodll_strvararg.obj \
|
||||
$(OBJS)\monodll_sysopt.obj \
|
||||
$(OBJS)\monodll_tarstrm.obj \
|
||||
@ -474,6 +475,7 @@ MONOLIB_OBJECTS = \
|
||||
$(OBJS)\monolib_stream.obj \
|
||||
$(OBJS)\monolib_string.obj \
|
||||
$(OBJS)\monolib_stringimpl.obj \
|
||||
$(OBJS)\monolib_stringops.obj \
|
||||
$(OBJS)\monolib_strvararg.obj \
|
||||
$(OBJS)\monolib_sysopt.obj \
|
||||
$(OBJS)\monolib_tarstrm.obj \
|
||||
@ -600,6 +602,7 @@ BASEDLL_OBJECTS = \
|
||||
$(OBJS)\basedll_stream.obj \
|
||||
$(OBJS)\basedll_string.obj \
|
||||
$(OBJS)\basedll_stringimpl.obj \
|
||||
$(OBJS)\basedll_stringops.obj \
|
||||
$(OBJS)\basedll_strvararg.obj \
|
||||
$(OBJS)\basedll_sysopt.obj \
|
||||
$(OBJS)\basedll_tarstrm.obj \
|
||||
@ -710,6 +713,7 @@ BASELIB_OBJECTS = \
|
||||
$(OBJS)\baselib_stream.obj \
|
||||
$(OBJS)\baselib_string.obj \
|
||||
$(OBJS)\baselib_stringimpl.obj \
|
||||
$(OBJS)\baselib_stringops.obj \
|
||||
$(OBJS)\baselib_strvararg.obj \
|
||||
$(OBJS)\baselib_sysopt.obj \
|
||||
$(OBJS)\baselib_tarstrm.obj \
|
||||
@ -5318,6 +5322,9 @@ $(OBJS)\monodll_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\monodll_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monodll_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monodll_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
|
||||
|
||||
@ -7372,6 +7379,9 @@ $(OBJS)\monolib_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\monolib_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monolib_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monolib_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
|
||||
|
||||
@ -9426,6 +9436,9 @@ $(OBJS)\basedll_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\basedll_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\basedll_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\basedll_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
|
||||
|
||||
@ -9708,6 +9721,9 @@ $(OBJS)\baselib_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\baselib_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\baselib_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\baselib_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
|
||||
|
||||
|
@ -330,6 +330,7 @@ MONODLL_OBJECTS = \
|
||||
$(OBJS)\monodll_stream.o \
|
||||
$(OBJS)\monodll_string.o \
|
||||
$(OBJS)\monodll_stringimpl.o \
|
||||
$(OBJS)\monodll_stringops.o \
|
||||
$(OBJS)\monodll_strvararg.o \
|
||||
$(OBJS)\monodll_sysopt.o \
|
||||
$(OBJS)\monodll_tarstrm.o \
|
||||
@ -460,6 +461,7 @@ MONOLIB_OBJECTS = \
|
||||
$(OBJS)\monolib_stream.o \
|
||||
$(OBJS)\monolib_string.o \
|
||||
$(OBJS)\monolib_stringimpl.o \
|
||||
$(OBJS)\monolib_stringops.o \
|
||||
$(OBJS)\monolib_strvararg.o \
|
||||
$(OBJS)\monolib_sysopt.o \
|
||||
$(OBJS)\monolib_tarstrm.o \
|
||||
@ -587,6 +589,7 @@ BASEDLL_OBJECTS = \
|
||||
$(OBJS)\basedll_stream.o \
|
||||
$(OBJS)\basedll_string.o \
|
||||
$(OBJS)\basedll_stringimpl.o \
|
||||
$(OBJS)\basedll_stringops.o \
|
||||
$(OBJS)\basedll_strvararg.o \
|
||||
$(OBJS)\basedll_sysopt.o \
|
||||
$(OBJS)\basedll_tarstrm.o \
|
||||
@ -697,6 +700,7 @@ BASELIB_OBJECTS = \
|
||||
$(OBJS)\baselib_stream.o \
|
||||
$(OBJS)\baselib_string.o \
|
||||
$(OBJS)\baselib_stringimpl.o \
|
||||
$(OBJS)\baselib_stringops.o \
|
||||
$(OBJS)\baselib_strvararg.o \
|
||||
$(OBJS)\baselib_sysopt.o \
|
||||
$(OBJS)\baselib_tarstrm.o \
|
||||
@ -5479,6 +5483,9 @@ $(OBJS)\monodll_string.o: ../../src/common/string.cpp
|
||||
$(OBJS)\monodll_stringimpl.o: ../../src/common/stringimpl.cpp
|
||||
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\monodll_stringops.o: ../../src/common/stringops.cpp
|
||||
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\monodll_strvararg.o: ../../src/common/strvararg.cpp
|
||||
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
@ -7633,6 +7640,9 @@ $(OBJS)\monolib_string.o: ../../src/common/string.cpp
|
||||
$(OBJS)\monolib_stringimpl.o: ../../src/common/stringimpl.cpp
|
||||
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\monolib_stringops.o: ../../src/common/stringops.cpp
|
||||
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\monolib_strvararg.o: ../../src/common/strvararg.cpp
|
||||
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
@ -9787,6 +9797,9 @@ $(OBJS)\basedll_string.o: ../../src/common/string.cpp
|
||||
$(OBJS)\basedll_stringimpl.o: ../../src/common/stringimpl.cpp
|
||||
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\basedll_stringops.o: ../../src/common/stringops.cpp
|
||||
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\basedll_strvararg.o: ../../src/common/strvararg.cpp
|
||||
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
@ -10069,6 +10082,9 @@ $(OBJS)\baselib_string.o: ../../src/common/string.cpp
|
||||
$(OBJS)\baselib_stringimpl.o: ../../src/common/stringimpl.cpp
|
||||
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\baselib_stringops.o: ../../src/common/stringops.cpp
|
||||
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\baselib_strvararg.o: ../../src/common/strvararg.cpp
|
||||
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@ -345,6 +345,7 @@ MONODLL_OBJECTS = \
|
||||
$(OBJS)\monodll_stream.obj \
|
||||
$(OBJS)\monodll_string.obj \
|
||||
$(OBJS)\monodll_stringimpl.obj \
|
||||
$(OBJS)\monodll_stringops.obj \
|
||||
$(OBJS)\monodll_strvararg.obj \
|
||||
$(OBJS)\monodll_sysopt.obj \
|
||||
$(OBJS)\monodll_tarstrm.obj \
|
||||
@ -479,6 +480,7 @@ MONOLIB_OBJECTS = \
|
||||
$(OBJS)\monolib_stream.obj \
|
||||
$(OBJS)\monolib_string.obj \
|
||||
$(OBJS)\monolib_stringimpl.obj \
|
||||
$(OBJS)\monolib_stringops.obj \
|
||||
$(OBJS)\monolib_strvararg.obj \
|
||||
$(OBJS)\monolib_sysopt.obj \
|
||||
$(OBJS)\monolib_tarstrm.obj \
|
||||
@ -611,6 +613,7 @@ BASEDLL_OBJECTS = \
|
||||
$(OBJS)\basedll_stream.obj \
|
||||
$(OBJS)\basedll_string.obj \
|
||||
$(OBJS)\basedll_stringimpl.obj \
|
||||
$(OBJS)\basedll_stringops.obj \
|
||||
$(OBJS)\basedll_strvararg.obj \
|
||||
$(OBJS)\basedll_sysopt.obj \
|
||||
$(OBJS)\basedll_tarstrm.obj \
|
||||
@ -727,6 +730,7 @@ BASELIB_OBJECTS = \
|
||||
$(OBJS)\baselib_stream.obj \
|
||||
$(OBJS)\baselib_string.obj \
|
||||
$(OBJS)\baselib_stringimpl.obj \
|
||||
$(OBJS)\baselib_stringops.obj \
|
||||
$(OBJS)\baselib_strvararg.obj \
|
||||
$(OBJS)\baselib_sysopt.obj \
|
||||
$(OBJS)\baselib_tarstrm.obj \
|
||||
@ -4505,7 +4509,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
|
||||
|
||||
@ -4858,7 +4862,7 @@ wxgl: $(____wxgl_namedll_DEP) $(____wxgl_namelib_DEP)
|
||||
sub_samples:
|
||||
cd ..\..\samples
|
||||
$(MAKE) -f makefile.vc $(MAKEARGS) all
|
||||
cd "$(MAKEDIR)"
|
||||
cd $(MAKEDIR)
|
||||
|
||||
$(LIBDIRNAME):
|
||||
if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
|
||||
@ -5670,6 +5674,9 @@ $(OBJS)\monodll_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\monodll_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monodll_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monodll_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
|
||||
|
||||
@ -7724,6 +7731,9 @@ $(OBJS)\monolib_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\monolib_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monolib_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\monolib_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
|
||||
|
||||
@ -9778,6 +9788,9 @@ $(OBJS)\basedll_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\basedll_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\basedll_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\basedll_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
|
||||
|
||||
@ -10060,6 +10073,9 @@ $(OBJS)\baselib_string.obj: ..\..\src\common\string.cpp
|
||||
$(OBJS)\baselib_stringimpl.obj: ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\baselib_stringops.obj: ..\..\src\common\stringops.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
|
||||
|
||||
$(OBJS)\baselib_strvararg.obj: ..\..\src\common\strvararg.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
|
||||
|
||||
|
@ -3286,6 +3286,7 @@ MONODLL_OBJECTS = &
|
||||
$(OBJS)\monodll_stream.obj &
|
||||
$(OBJS)\monodll_string.obj &
|
||||
$(OBJS)\monodll_stringimpl.obj &
|
||||
$(OBJS)\monodll_stringops.obj &
|
||||
$(OBJS)\monodll_strvararg.obj &
|
||||
$(OBJS)\monodll_sysopt.obj &
|
||||
$(OBJS)\monodll_tarstrm.obj &
|
||||
@ -3415,6 +3416,7 @@ MONOLIB_OBJECTS = &
|
||||
$(OBJS)\monolib_stream.obj &
|
||||
$(OBJS)\monolib_string.obj &
|
||||
$(OBJS)\monolib_stringimpl.obj &
|
||||
$(OBJS)\monolib_stringops.obj &
|
||||
$(OBJS)\monolib_strvararg.obj &
|
||||
$(OBJS)\monolib_sysopt.obj &
|
||||
$(OBJS)\monolib_tarstrm.obj &
|
||||
@ -3542,6 +3544,7 @@ BASEDLL_OBJECTS = &
|
||||
$(OBJS)\basedll_stream.obj &
|
||||
$(OBJS)\basedll_string.obj &
|
||||
$(OBJS)\basedll_stringimpl.obj &
|
||||
$(OBJS)\basedll_stringops.obj &
|
||||
$(OBJS)\basedll_strvararg.obj &
|
||||
$(OBJS)\basedll_sysopt.obj &
|
||||
$(OBJS)\basedll_tarstrm.obj &
|
||||
@ -3653,6 +3656,7 @@ BASELIB_OBJECTS = &
|
||||
$(OBJS)\baselib_stream.obj &
|
||||
$(OBJS)\baselib_string.obj &
|
||||
$(OBJS)\baselib_stringimpl.obj &
|
||||
$(OBJS)\baselib_stringops.obj &
|
||||
$(OBJS)\baselib_strvararg.obj &
|
||||
$(OBJS)\baselib_sysopt.obj &
|
||||
$(OBJS)\baselib_tarstrm.obj &
|
||||
@ -5750,6 +5754,9 @@ $(OBJS)\monodll_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
|
||||
$(OBJS)\monodll_stringimpl.obj : .AUTODEPEND ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\monodll_stringops.obj : .AUTODEPEND ..\..\src\common\stringops.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\monodll_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
|
||||
|
||||
@ -7904,6 +7911,9 @@ $(OBJS)\monolib_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
|
||||
$(OBJS)\monolib_stringimpl.obj : .AUTODEPEND ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\monolib_stringops.obj : .AUTODEPEND ..\..\src\common\stringops.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\monolib_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
|
||||
|
||||
@ -10058,6 +10068,9 @@ $(OBJS)\basedll_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
|
||||
$(OBJS)\basedll_stringimpl.obj : .AUTODEPEND ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\basedll_stringops.obj : .AUTODEPEND ..\..\src\common\stringops.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\basedll_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
|
||||
|
||||
@ -10340,6 +10353,9 @@ $(OBJS)\baselib_string.obj : .AUTODEPEND ..\..\src\common\string.cpp
|
||||
$(OBJS)\baselib_stringimpl.obj : .AUTODEPEND ..\..\src\common\stringimpl.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\baselib_stringops.obj : .AUTODEPEND ..\..\src\common\stringops.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\baselib_strvararg.obj : .AUTODEPEND ..\..\src\common\strvararg.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
|
||||
|
||||
|
@ -683,6 +683,10 @@ SOURCE=..\..\src\common\stringimpl.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\common\stringops.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\common\strvararg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -1787,6 +1791,10 @@ SOURCE=..\..\include\wx\stringimpl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\wx\stringops.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\wx\strvararg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "wx/buffer.h" // for wxCharBuffer
|
||||
#include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes
|
||||
#include "wx/stringimpl.h"
|
||||
#include "wx/stringops.h"
|
||||
#include "wx/unichar.h"
|
||||
|
||||
class WXDLLIMPEXP_BASE wxString;
|
||||
@ -373,7 +374,6 @@ private:
|
||||
|
||||
// buffer for holding temporary substring when using any of the methods
|
||||
// that take (char*,size_t) or (wchar_t*,size_t) arguments:
|
||||
// FIXME-UTF8: This will need changes when UTF8 build is introduced
|
||||
template<typename T>
|
||||
struct SubstrBufFromType
|
||||
{
|
||||
@ -441,28 +441,6 @@ private:
|
||||
{ return ConvertStr(str, n, wxConvLibc); }
|
||||
#endif
|
||||
|
||||
// moves the iterator to the next Unicode character
|
||||
static void IncIter(wxStringImpl::iterator& i) { ++i; }
|
||||
static void IncIter(wxStringImpl::const_iterator& i) { ++i; }
|
||||
// moves the iterator to the previous Unicode character
|
||||
static void DecIter(wxStringImpl::iterator& i) { --i; }
|
||||
static void DecIter(wxStringImpl::const_iterator& i) { --i; }
|
||||
// moves the iterator by n Unicode characters
|
||||
static wxStringImpl::iterator AddToIter(wxStringImpl::iterator i, int n)
|
||||
{ return i + n; }
|
||||
static wxStringImpl::const_iterator AddToIter(wxStringImpl::const_iterator i, int n)
|
||||
{ return i + n; }
|
||||
// returns distance of the two iterators in Unicode characters
|
||||
static int DiffIters(wxStringImpl::iterator i1, wxStringImpl::iterator i2)
|
||||
{ return i1 - i2; }
|
||||
static int DiffIters(wxStringImpl::const_iterator i1, wxStringImpl::const_iterator i2)
|
||||
{ return i1 - i2; }
|
||||
|
||||
// encodes the character to a form used to represent it in internal
|
||||
// representation (returns a string in UTF8 version)
|
||||
static wxChar EncodeChar(wxUniChar ch) { return (wxChar)ch; }
|
||||
static wxUniChar DecodeChar(wxStringImpl::const_iterator i) { return *i; }
|
||||
|
||||
// translates position index in wxString to/from index in underlying
|
||||
// wxStringImpl:
|
||||
static size_t PosToImpl(size_t pos) { return pos; }
|
||||
@ -474,55 +452,20 @@ private:
|
||||
|
||||
#else // wxUSE_UNICODE_UTF8
|
||||
|
||||
// checks correctness of UTF-8 sequence
|
||||
static bool IsValidUtf8String(const char *c);
|
||||
#ifdef __WXDEBUG__
|
||||
static bool IsValidUtf8LeadByte(unsigned char c);
|
||||
#endif
|
||||
// FIXME-UTF8: return as-is without copying under UTF8 locale, return
|
||||
// converted string under other locales - needs wxCharBuffer
|
||||
// changes
|
||||
static wxCharBuffer ImplStr(const char* str,
|
||||
const wxMBConv& conv = wxConvLibc)
|
||||
{ return ConvertStr(str, npos, conv).data; }
|
||||
static SubstrBufFromMB ImplStr(const char* str, size_t n,
|
||||
const wxMBConv& conv = wxConvLibc)
|
||||
{ return ConvertStr(str, n, conv); }
|
||||
|
||||
// table of offsets to skip forward when iterating
|
||||
static unsigned char ms_utf8IterTable[256];
|
||||
|
||||
static void IncIter(wxStringImpl::iterator& i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
i += ms_utf8IterTable[(unsigned char)*i];
|
||||
}
|
||||
static void IncIter(wxStringImpl::const_iterator& i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
i += ms_utf8IterTable[(unsigned char)*i];
|
||||
}
|
||||
|
||||
static void DecIter(wxStringImpl::iterator& i);
|
||||
static void DecIter(wxStringImpl::const_iterator& i);
|
||||
static wxStringImpl::iterator AddToIter(wxStringImpl::iterator i, int n);
|
||||
static wxStringImpl::const_iterator AddToIter(wxStringImpl::const_iterator i, int n);
|
||||
static int DiffIters(wxStringImpl::const_iterator i1, wxStringImpl::const_iterator i2);
|
||||
static int DiffIters(wxStringImpl::iterator i1, wxStringImpl::iterator i2);
|
||||
|
||||
struct Utf8CharBuffer
|
||||
{
|
||||
char data[5];
|
||||
operator const char*() const { return data; }
|
||||
};
|
||||
static Utf8CharBuffer EncodeChar(wxUniChar ch);
|
||||
// returns n copies of ch encoded in UTF-8 string
|
||||
static wxCharBuffer EncodeNChars(size_t n, wxUniChar ch);
|
||||
|
||||
// returns the length of UTF-8 encoding of the character with lead byte 'c'
|
||||
static size_t GetUtf8CharLength(char c)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(c) );
|
||||
return ms_utf8IterTable[(unsigned char)c];
|
||||
}
|
||||
|
||||
// decodes single UTF-8 character from UTF-8 string
|
||||
// FIXME-UTF8: move EncodeChar/DecodeChar and other operations to separate
|
||||
// class
|
||||
static wxUniChar DecodeChar(wxStringImpl::const_iterator i)
|
||||
{ return wxUniCharRef::DecodeChar(i); }
|
||||
friend class WXDLLIMPEXP_BASE wxUniCharRef;
|
||||
static wxCharBuffer ImplStr(const wchar_t* str)
|
||||
{ return ConvertStr(str, npos, wxConvUTF8).data; }
|
||||
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
||||
{ return ConvertStr(str, n, wxConvUTF8); }
|
||||
|
||||
size_t PosToImpl(size_t pos) const
|
||||
{
|
||||
@ -548,21 +491,6 @@ private:
|
||||
else
|
||||
return const_iterator(m_impl.begin() + pos) - begin();
|
||||
}
|
||||
|
||||
// FIXME-UTF8: return as-is without copying under UTF8 locale, return
|
||||
// converted string under other locales - needs wxCharBuffer
|
||||
// changes
|
||||
static wxCharBuffer ImplStr(const char* str,
|
||||
const wxMBConv& conv = wxConvLibc)
|
||||
{ return ConvertStr(str, npos, conv).data; }
|
||||
static SubstrBufFromMB ImplStr(const char* str, size_t n,
|
||||
const wxMBConv& conv = wxConvLibc)
|
||||
{ return ConvertStr(str, n, conv); }
|
||||
|
||||
static wxCharBuffer ImplStr(const wchar_t* str)
|
||||
{ return ConvertStr(str, npos, wxConvUTF8).data; }
|
||||
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
||||
{ return ConvertStr(str, n, wxConvUTF8); }
|
||||
#endif // !wxUSE_UNICODE_UTF8/wxUSE_UNICODE_UTF8
|
||||
|
||||
public:
|
||||
@ -602,33 +530,45 @@ public:
|
||||
reference operator[](size_t n) const { return *(*this + n); } \
|
||||
\
|
||||
iterator_name& operator++() \
|
||||
{ wxString::IncIter(m_cur); return *this; } \
|
||||
{ wxStringOperations::IncIter(m_cur); return *this; } \
|
||||
iterator_name& operator--() \
|
||||
{ wxString::DecIter(m_cur); return *this; } \
|
||||
{ wxStringOperations::DecIter(m_cur); return *this; } \
|
||||
iterator_name operator++(int) \
|
||||
{ \
|
||||
iterator_name tmp = *this; \
|
||||
wxString::IncIter(m_cur); \
|
||||
wxStringOperations::IncIter(m_cur); \
|
||||
return tmp; \
|
||||
} \
|
||||
iterator_name operator--(int) \
|
||||
{ \
|
||||
iterator_name tmp = *this; \
|
||||
wxString::DecIter(m_cur); \
|
||||
wxStringOperations::DecIter(m_cur); \
|
||||
return tmp; \
|
||||
} \
|
||||
\
|
||||
iterator_name& operator+=(int n) \
|
||||
{ m_cur = wxString::AddToIter(m_cur, n); return *this; } \
|
||||
{ \
|
||||
m_cur = wxStringOperations::AddToIter(m_cur, n); \
|
||||
return *this; \
|
||||
} \
|
||||
iterator_name& operator+=(size_t n) \
|
||||
{ m_cur = wxString::AddToIter(m_cur, (int)n); return *this; } \
|
||||
{ \
|
||||
m_cur = wxStringOperations::AddToIter(m_cur, (int)n); \
|
||||
return *this; \
|
||||
} \
|
||||
iterator_name& operator-=(int n) \
|
||||
{ m_cur = wxString::AddToIter(m_cur, -n); return *this; } \
|
||||
{ \
|
||||
m_cur = wxStringOperations::AddToIter(m_cur, -n); \
|
||||
return *this; \
|
||||
} \
|
||||
iterator_name& operator-=(size_t n) \
|
||||
{ m_cur = wxString::AddToIter(m_cur, -(int)n); return *this; } \
|
||||
{ \
|
||||
m_cur = wxStringOperations::AddToIter(m_cur, -(int)n); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
difference_type operator-(const iterator_name& i) const \
|
||||
{ return wxString::DiffIters(m_cur, i.m_cur); } \
|
||||
{ return wxStringOperations::DiffIters(m_cur, i.m_cur); } \
|
||||
\
|
||||
bool operator==(const iterator_name& i) const \
|
||||
{ return m_cur == i.m_cur; } \
|
||||
@ -672,13 +612,13 @@ public:
|
||||
iterator(const iterator& i) : m_cur(i.m_cur), m_str(i.m_str) {}
|
||||
|
||||
iterator operator+(int n) const
|
||||
{ return iterator(m_str, wxString::AddToIter(m_cur, n)); }
|
||||
{ return iterator(m_str, wxStringOperations::AddToIter(m_cur, n)); }
|
||||
iterator operator+(size_t n) const
|
||||
{ return iterator(m_str, wxString::AddToIter(m_cur, (int)n)); }
|
||||
{ return iterator(m_str, wxStringOperations::AddToIter(m_cur, (int)n)); }
|
||||
iterator operator-(int n) const
|
||||
{ return iterator(m_str, wxString::AddToIter(m_cur, -n)); }
|
||||
{ return iterator(m_str, wxStringOperations::AddToIter(m_cur, -n)); }
|
||||
iterator operator-(size_t n) const
|
||||
{ return iterator(m_str, wxString::AddToIter(m_cur, -(int)n)); }
|
||||
{ return iterator(m_str, wxStringOperations::AddToIter(m_cur, -(int)n)); }
|
||||
|
||||
private:
|
||||
iterator(wxString *str, underlying_iterator ptr)
|
||||
@ -705,13 +645,13 @@ public:
|
||||
iterator(const iterator& i) : m_cur(i.m_cur) {}
|
||||
|
||||
iterator operator+(int n) const
|
||||
{ return iterator(wxString::AddToIter(m_cur, n)); }
|
||||
{ return iterator(wxStringOperations::AddToIter(m_cur, n)); }
|
||||
iterator operator+(size_t n) const
|
||||
{ return iterator(wxString::AddToIter(m_cur, (int)n)); }
|
||||
{ return iterator(wxStringOperations::AddToIter(m_cur, (int)n)); }
|
||||
iterator operator-(int n) const
|
||||
{ return iterator(wxString::AddToIter(m_cur, -n)); }
|
||||
{ return iterator(wxStringOperations::AddToIter(m_cur, -n)); }
|
||||
iterator operator-(size_t n) const
|
||||
{ return iterator(wxString::AddToIter(m_cur, -(int)n)); }
|
||||
{ return iterator(wxStringOperations::AddToIter(m_cur, -(int)n)); }
|
||||
|
||||
private:
|
||||
// for internal wxString use only:
|
||||
@ -727,20 +667,20 @@ public:
|
||||
// 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,
|
||||
wxString::DecodeChar(m_cur));
|
||||
wxStringOperations::DecodeChar(m_cur));
|
||||
|
||||
public:
|
||||
const_iterator(const const_iterator& i) : m_cur(i.m_cur) {}
|
||||
const_iterator(const iterator& i) : m_cur(i.m_cur) {}
|
||||
|
||||
const_iterator operator+(int n) const
|
||||
{ return const_iterator(wxString::AddToIter(m_cur, n)); }
|
||||
{ return const_iterator(wxStringOperations::AddToIter(m_cur, n)); }
|
||||
const_iterator operator+(size_t n) const
|
||||
{ return const_iterator(wxString::AddToIter(m_cur, (int)n)); }
|
||||
{ return const_iterator(wxStringOperations::AddToIter(m_cur, (int)n)); }
|
||||
const_iterator operator-(int n) const
|
||||
{ return const_iterator(wxString::AddToIter(m_cur, -n)); }
|
||||
{ return const_iterator(wxStringOperations::AddToIter(m_cur, -n)); }
|
||||
const_iterator operator-(size_t n) const
|
||||
{ return const_iterator(wxString::AddToIter(m_cur, -(int)n)); }
|
||||
{ return const_iterator(wxStringOperations::AddToIter(m_cur, -(int)n)); }
|
||||
|
||||
private:
|
||||
// for internal wxString use only:
|
||||
@ -1217,7 +1157,7 @@ public:
|
||||
{ return *this = cstr.AsString(); }
|
||||
// from a character
|
||||
wxString& operator=(wxUniChar ch)
|
||||
{ m_impl = EncodeChar(ch); return *this; }
|
||||
{ m_impl = wxStringOperations::EncodeChar(ch); return *this; }
|
||||
wxString& operator=(wxUniCharRef ch)
|
||||
{ return operator=((wxUniChar)ch); }
|
||||
wxString& operator=(char ch)
|
||||
@ -1693,7 +1633,7 @@ public:
|
||||
{
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
if ( !ch.IsAscii() )
|
||||
m_impl.append(EncodeNChars(n, ch));
|
||||
m_impl.append(wxStringOperations::EncodeNChars(n, ch));
|
||||
else
|
||||
#endif
|
||||
m_impl.append(n, (wxStringCharType)ch);
|
||||
@ -1749,7 +1689,7 @@ public:
|
||||
{
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
if ( !ch.IsAscii() )
|
||||
m_impl.assign(EncodeNChars(n, ch));
|
||||
m_impl.assign(wxStringOperations::EncodeNChars(n, ch));
|
||||
else
|
||||
#endif
|
||||
m_impl.assign(n, (wxStringCharType)ch);
|
||||
@ -1826,7 +1766,7 @@ public:
|
||||
{
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
if ( !ch.IsAscii() )
|
||||
m_impl.insert(PosToImpl(nPos), EncodeNChars(n, ch));
|
||||
m_impl.insert(PosToImpl(nPos), wxStringOperations::EncodeNChars(n, ch));
|
||||
else
|
||||
#endif
|
||||
m_impl.insert(PosToImpl(nPos), n, (wxStringCharType)ch);
|
||||
@ -1838,7 +1778,7 @@ public:
|
||||
if ( !ch.IsAscii() )
|
||||
{
|
||||
size_t pos = IterToImplPos(it);
|
||||
m_impl.insert(pos, EncodeChar(ch));
|
||||
m_impl.insert(pos, wxStringOperations::EncodeChar(ch));
|
||||
return iterator(this, m_impl.begin() + pos);
|
||||
}
|
||||
else
|
||||
@ -1860,7 +1800,7 @@ public:
|
||||
{
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
if ( !ch.IsAscii() )
|
||||
m_impl.insert(IterToImplPos(it), EncodeNChars(n, ch));
|
||||
m_impl.insert(IterToImplPos(it), wxStringOperations::EncodeNChars(n, ch));
|
||||
else
|
||||
#endif
|
||||
m_impl.insert(it.impl(), n, (wxStringCharType)ch);
|
||||
@ -1916,7 +1856,7 @@ public:
|
||||
PosLenToImpl(nStart, nLen, &from, &len);
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
if ( !ch.IsAscii() )
|
||||
m_impl.replace(from, len, EncodeNChars(nCount, ch));
|
||||
m_impl.replace(from, len, wxStringOperations::EncodeNChars(nCount, ch));
|
||||
else
|
||||
#endif
|
||||
m_impl.replace(from, len, nCount, (wxStringCharType)ch);
|
||||
@ -1989,7 +1929,8 @@ public:
|
||||
{
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
if ( !ch.IsAscii() )
|
||||
m_impl.replace(first.impl(), last.impl(), EncodeNChars(n, ch));
|
||||
m_impl.replace(first.impl(), last.impl(),
|
||||
wxStringOperations::EncodeNChars(n, ch));
|
||||
else
|
||||
#endif
|
||||
m_impl.replace(first.impl(), last.impl(), n, (wxStringCharType)ch);
|
||||
@ -2030,7 +1971,10 @@ public:
|
||||
|
||||
// find the first occurence of character ch after nStart
|
||||
size_t find(wxUniChar ch, size_t nStart = 0) const
|
||||
{ return PosFromImpl(m_impl.find(EncodeChar(ch), PosToImpl(nStart))); }
|
||||
{
|
||||
return PosFromImpl(m_impl.find(wxStringOperations::EncodeChar(ch),
|
||||
PosToImpl(nStart)));
|
||||
}
|
||||
size_t find(wxUniCharRef ch, size_t nStart = 0) const
|
||||
{ return find(wxUniChar(ch), nStart); }
|
||||
size_t find(char ch, size_t nStart = 0) const
|
||||
@ -2059,7 +2003,10 @@ public:
|
||||
}
|
||||
// as find, but from the end
|
||||
size_t rfind(wxUniChar ch, size_t nStart = npos) const
|
||||
{ return PosFromImpl(m_impl.rfind(EncodeChar(ch), PosToImpl(nStart))); }
|
||||
{
|
||||
return PosFromImpl(m_impl.rfind(wxStringOperations::EncodeChar(ch),
|
||||
PosToImpl(nStart)));
|
||||
}
|
||||
size_t rfind(wxUniCharRef ch, size_t nStart = npos) const
|
||||
{ return rfind(wxUniChar(ch), nStart); }
|
||||
size_t rfind(char ch, size_t nStart = npos) const
|
||||
@ -2239,7 +2186,7 @@ public:
|
||||
{ m_impl += s.AsString().m_impl; return *this; }
|
||||
// string += char
|
||||
wxString& operator+=(wxUniChar ch)
|
||||
{ m_impl += EncodeChar(ch); return *this; }
|
||||
{ m_impl += wxStringOperations::EncodeChar(ch); return *this; }
|
||||
wxString& operator+=(wxUniCharRef ch) { return *this += wxUniChar(ch); }
|
||||
wxString& operator+=(int ch) { return *this += wxUniChar(ch); }
|
||||
wxString& operator+=(char ch) { return *this += wxUniChar(ch); }
|
||||
|
173
include/wx/stringops.h
Normal file
173
include/wx/stringops.h
Normal file
@ -0,0 +1,173 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/stringops.h
|
||||
// Purpose: implementation of wxString primitive operations
|
||||
// Author: Vaclav Slavik
|
||||
// Modified by:
|
||||
// Created: 2007-04-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2007 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_WXSTRINGOPS_H__
|
||||
#define _WX_WXSTRINGOPS_H__
|
||||
|
||||
#include "wx/chartype.h"
|
||||
#include "wx/stringimpl.h"
|
||||
#include "wx/unichar.h"
|
||||
|
||||
// This header contains wxStringOperations "namespace" class that implements
|
||||
// elementary operations on string data as static methods; wxString methods and
|
||||
// iterators are implemented in terms of it. Two implementations are available,
|
||||
// one for UTF-8 encoded char* string and one for "raw" wchar_t* strings (or
|
||||
// char* in ANSI build).
|
||||
|
||||
// FIXME-UTF8: only wchar after we remove ANSI build
|
||||
#if wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE
|
||||
struct WXDLLIMPEXP_BASE wxStringOperationsWchar
|
||||
{
|
||||
// moves the iterator to the next Unicode character
|
||||
static void IncIter(wxStringImpl::iterator& i) { ++i; }
|
||||
static void IncIter(wxStringImpl::const_iterator& i) { ++i; }
|
||||
|
||||
// moves the iterator to the previous Unicode character
|
||||
static void DecIter(wxStringImpl::iterator& i) { --i; }
|
||||
static void DecIter(wxStringImpl::const_iterator& i) { --i; }
|
||||
|
||||
// moves the iterator by n Unicode characters
|
||||
static wxStringImpl::iterator AddToIter(const wxStringImpl::iterator& i, int n)
|
||||
{ return i + n; }
|
||||
static wxStringImpl::const_iterator AddToIter(const wxStringImpl::const_iterator& i, int n)
|
||||
{ return i + n; }
|
||||
|
||||
// returns distance of the two iterators in Unicode characters
|
||||
static int DiffIters(const wxStringImpl::iterator& i1,
|
||||
const wxStringImpl::iterator& i2)
|
||||
{ return i1 - i2; }
|
||||
static int DiffIters(const wxStringImpl::const_iterator& i1,
|
||||
const wxStringImpl::const_iterator& i2)
|
||||
{ return i1 - i2; }
|
||||
|
||||
// encodes the character to a form used to represent it in internal
|
||||
// representation (returns a string in UTF8 version)
|
||||
static wxChar EncodeChar(const wxUniChar& ch) { return (wxChar)ch; }
|
||||
|
||||
static wxUniChar DecodeChar(const wxStringImpl::const_iterator& i)
|
||||
{ return *i; }
|
||||
};
|
||||
#endif // wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE
|
||||
|
||||
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
|
||||
{
|
||||
// checks correctness of UTF-8 sequence
|
||||
static bool IsValidUtf8String(const char *c);
|
||||
#ifdef __WXDEBUG__
|
||||
static bool IsValidUtf8LeadByte(unsigned char c);
|
||||
#endif
|
||||
|
||||
// table of offsets to skip forward when iterating over UTF-8 sequence
|
||||
static unsigned char ms_utf8IterTable[256];
|
||||
|
||||
|
||||
template<typename Iterator>
|
||||
static void IncIter(Iterator& i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
i += ms_utf8IterTable[(unsigned char)*i];
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
static void DecIter(Iterator& i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
|
||||
// Non-lead bytes are all in the 0x80..0xBF range (i.e. 10xxxxxx in
|
||||
// binary), so we just have to go back until we hit a byte that is
|
||||
// either < 0x80 (i.e. 0xxxxxxx in binary) or 0xC0..0xFF (11xxxxxx in
|
||||
// binary; this includes some invalid values, but we can ignore it
|
||||
// here, because we assume valid UTF-8 input for the purpose of
|
||||
// efficient implementation).
|
||||
--i;
|
||||
while ( ((*i) & 0xC0) == 0x80 /* 2 highest bits are '10' */ )
|
||||
--i;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
static Iterator AddToIter(const Iterator& i, int n)
|
||||
{
|
||||
Iterator out(i);
|
||||
|
||||
if ( n > 0 )
|
||||
{
|
||||
for ( int j = 0; j < n; ++j )
|
||||
IncIter(out);
|
||||
}
|
||||
else if ( n < 0 )
|
||||
{
|
||||
for ( int j = 0; j > n; --j )
|
||||
DecIter(out);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
static int DiffIters(Iterator i1, Iterator i2)
|
||||
{
|
||||
int dist = 0;
|
||||
|
||||
if ( i1 < i2 )
|
||||
{
|
||||
while ( i1 != i2 )
|
||||
{
|
||||
IncIter(i1);
|
||||
dist--;
|
||||
}
|
||||
}
|
||||
else if ( i2 < i1 )
|
||||
{
|
||||
while ( i2 != i1 )
|
||||
{
|
||||
IncIter(i2);
|
||||
dist++;
|
||||
}
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
// buffer for single UTF-8 character
|
||||
struct Utf8CharBuffer
|
||||
{
|
||||
char data[5];
|
||||
operator const char*() const { return data; }
|
||||
};
|
||||
|
||||
// encodes the character as UTF-8:
|
||||
static Utf8CharBuffer EncodeChar(const wxUniChar& ch);
|
||||
|
||||
// returns n copies of ch encoded in UTF-8 string
|
||||
static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch);
|
||||
|
||||
// returns the length of UTF-8 encoding of the character with lead byte 'c'
|
||||
static size_t GetUtf8CharLength(char c)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(c) );
|
||||
return ms_utf8IterTable[(unsigned char)c];
|
||||
}
|
||||
|
||||
// decodes single UTF-8 character from UTF-8 string
|
||||
static wxUniChar DecodeChar(wxStringImpl::const_iterator i);
|
||||
};
|
||||
#endif // wxUSE_UNICODE_UTF8
|
||||
|
||||
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
typedef wxStringOperationsUtf8 wxStringOperations;
|
||||
#else
|
||||
typedef wxStringOperationsWchar wxStringOperations;
|
||||
#endif
|
||||
|
||||
#endif // _WX_WXSTRINGOPS_H_
|
@ -237,19 +237,10 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
wxUniChar UniChar() const
|
||||
{
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
return DecodeChar(m_pos);
|
||||
wxUniChar UniChar() const;
|
||||
#else
|
||||
return *m_pos;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
// FIXME-UTF8: move this to a separate 'string operations' class
|
||||
static wxUniChar DecodeChar(wxStringImpl::const_iterator i);
|
||||
friend class WXDLLIMPEXP_BASE wxString;
|
||||
wxUniChar UniChar() const { return *m_pos; }
|
||||
#endif
|
||||
|
||||
friend class WXDLLIMPEXP_BASE wxUniChar;
|
||||
|
@ -10,13 +10,6 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* About ref counting:
|
||||
* 1) all empty strings use g_strEmpty, nRefs = -1 (set in Init())
|
||||
* 2) AllocBuffer() sets nRefs to 1, Lock() increments it by one
|
||||
* 3) Unlock() decrements nRefs and frees memory if it goes to 0
|
||||
*/
|
||||
|
||||
// ===========================================================================
|
||||
// headers, declarations, constants
|
||||
// ===========================================================================
|
||||
@ -111,394 +104,6 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxWCharBuffer& str)
|
||||
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UTF-8 operations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Table 3.1B from Unicode spec: Legal UTF-8 Byte Sequences
|
||||
//
|
||||
// Code Points | 1st Byte | 2nd Byte | 3rd Byte | 4th Byte |
|
||||
// -------------------+----------+----------+----------+----------+
|
||||
// U+0000..U+007F | 00..7F | | | |
|
||||
// U+0080..U+07FF | C2..DF | 80..BF | | |
|
||||
// U+0800..U+0FFF | E0 | A0..BF | 80..BF | |
|
||||
// U+1000..U+FFFF | E1..EF | 80..BF | 80..BF | |
|
||||
// U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF |
|
||||
// U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF |
|
||||
// U+100000..U+10FFFF | F4 | 80..8F | 80..BF | 80..BF |
|
||||
// -------------------+----------+----------+----------+----------+
|
||||
|
||||
bool wxString::IsValidUtf8String(const char *str)
|
||||
{
|
||||
if ( !str )
|
||||
return true; // empty string is UTF8 string
|
||||
|
||||
const unsigned char *c = (const unsigned char*)str;
|
||||
|
||||
for ( ; *c; ++c )
|
||||
{
|
||||
unsigned char b = *c;
|
||||
|
||||
if ( b <= 0x7F ) // 00..7F
|
||||
continue;
|
||||
|
||||
else if ( b < 0xC2 ) // invalid lead bytes: 80..C1
|
||||
return false;
|
||||
|
||||
// two-byte sequences:
|
||||
else if ( b <= 0xDF ) // C2..DF
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// three-byte sequences:
|
||||
else if ( b == 0xE0 )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0xA0 && b <= 0xBF ) )
|
||||
return false;
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
else if ( b <= 0xEF ) // E1..EF
|
||||
{
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// four-byte sequences:
|
||||
else if ( b == 0xF0 )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x90 && b <= 0xBF ) )
|
||||
return false;
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( b <= 0xF3 ) // F1..F3
|
||||
{
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( b == 0xF4 )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0x8F ) )
|
||||
return false;
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // otherwise, it's invalid lead byte
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
/* static */
|
||||
bool wxString::IsValidUtf8LeadByte(unsigned char c)
|
||||
{
|
||||
return (c <= 0x7F) || (c >= 0xC2 && c <= 0xF4);
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned char wxString::ms_utf8IterTable[256] = {
|
||||
// single-byte sequences (ASCII):
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00..0F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10..1F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20..2F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30..3F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40..4F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50..5F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60..6F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70..7F
|
||||
|
||||
// these are invalid, we use step 1 to skip
|
||||
// over them (should never happen):
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80..8F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90..9F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A0..AF
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B0..BF
|
||||
1, 1, // C0,C1
|
||||
|
||||
// two-byte sequences:
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C2..CF
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D0..DF
|
||||
|
||||
// three-byte sequences:
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E0..EF
|
||||
|
||||
// four-byte sequences:
|
||||
4, 4, 4, 4, 4, // F0..F4
|
||||
|
||||
// these are invalid again (5- or 6-byte
|
||||
// sequences and sequences for code points
|
||||
// above U+10FFFF, as restricted by RFC 3629):
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F5..FF
|
||||
};
|
||||
|
||||
/* static */
|
||||
void wxString::DecIter(wxStringImpl::const_iterator& i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
|
||||
// Non-lead bytes are all in the 0x80..0xBF range (i.e. 10xxxxxx in
|
||||
// binary), so we just have to go back until we hit a byte that is either
|
||||
// < 0x80 (i.e. 0xxxxxxx in binary) or 0xC0..0xFF (11xxxxxx in binary; this
|
||||
// includes some invalid values, but we can ignore it here, because we
|
||||
// assume valid UTF-8 input for the purpose of efficient implementation).
|
||||
--i;
|
||||
while ( ((*i) & 0xC0) == 0x80 /* 2 highest bits are '10' */ )
|
||||
--i;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxString::DecIter(wxStringImpl::iterator& i)
|
||||
{
|
||||
// FIXME-UTF8: use template instead
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
--i;
|
||||
while ( ((*i) & 0xC0) == 0x80 /* 2 highest bits are '10' */ )
|
||||
--i;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxStringImpl::const_iterator
|
||||
wxString::AddToIter(wxStringImpl::const_iterator i, int n)
|
||||
{
|
||||
wxStringImpl::const_iterator out(i);
|
||||
|
||||
if ( n > 0 )
|
||||
{
|
||||
for ( int j = 0; j < n; ++j )
|
||||
IncIter(out);
|
||||
}
|
||||
else if ( n < 0 )
|
||||
{
|
||||
for ( int j = 0; j > n; --j )
|
||||
DecIter(out);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
wxStringImpl::iterator
|
||||
wxString::AddToIter(wxStringImpl::iterator i, int n)
|
||||
{
|
||||
// FIXME-UTF8: use template instead
|
||||
wxStringImpl::iterator out(i);
|
||||
|
||||
if ( n > 0 )
|
||||
{
|
||||
for ( int j = 0; j < n; ++j )
|
||||
IncIter(out);
|
||||
}
|
||||
else if ( n < 0 )
|
||||
{
|
||||
for ( int j = 0; j > n; --j )
|
||||
DecIter(out);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
int wxString::DiffIters(wxStringImpl::const_iterator i1,
|
||||
wxStringImpl::const_iterator i2)
|
||||
{
|
||||
int dist = 0;
|
||||
|
||||
if ( i1 < i2 )
|
||||
{
|
||||
while ( i1 != i2 )
|
||||
{
|
||||
IncIter(i1);
|
||||
dist--;
|
||||
}
|
||||
}
|
||||
else if ( i2 < i1 )
|
||||
{
|
||||
while ( i2 != i1 )
|
||||
{
|
||||
IncIter(i2);
|
||||
dist++;
|
||||
}
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
int wxString::DiffIters(wxStringImpl::iterator i1, wxStringImpl::iterator i2)
|
||||
{
|
||||
// FIXME-UTF8: use template instead
|
||||
int dist = 0;
|
||||
|
||||
if ( i1 < i2 )
|
||||
{
|
||||
while ( i1 != i2 )
|
||||
{
|
||||
IncIter(i1);
|
||||
dist--;
|
||||
}
|
||||
}
|
||||
else if ( i2 < i1 )
|
||||
{
|
||||
while ( i2 != i1 )
|
||||
{
|
||||
IncIter(i2);
|
||||
dist++;
|
||||
}
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxString::Utf8CharBuffer wxString::EncodeChar(wxUniChar ch)
|
||||
{
|
||||
Utf8CharBuffer buf;
|
||||
char *out = buf.data;
|
||||
|
||||
wxUniChar::value_type code = ch.GetValue();
|
||||
|
||||
// Char. number range | UTF-8 octet sequence
|
||||
// (hexadecimal) | (binary)
|
||||
// ----------------------+---------------------------------------------
|
||||
// 0000 0000 - 0000 007F | 0xxxxxxx
|
||||
// 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx
|
||||
// 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
//
|
||||
// Code point value is stored in bits marked with 'x', lowest-order bit
|
||||
// of the value on the right side in the diagram above.
|
||||
// (from RFC 3629)
|
||||
|
||||
if ( code <= 0x7F )
|
||||
{
|
||||
out[1] = 0;
|
||||
out[0] = (char)code;
|
||||
}
|
||||
else if ( code <= 0x07FF )
|
||||
{
|
||||
out[2] = 0;
|
||||
// NB: this line takes 6 least significant bits, encodes them as
|
||||
// 10xxxxxx and discards them so that the next byte can be encoded:
|
||||
out[1] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[0] = 0xC0 | code;
|
||||
}
|
||||
else if ( code < 0xFFFF )
|
||||
{
|
||||
out[3] = 0;
|
||||
out[2] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[1] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[0] = 0xE0 | code;
|
||||
}
|
||||
else if ( code <= 0x10FFFF )
|
||||
{
|
||||
out[4] = 0;
|
||||
out[3] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[2] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[1] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[0] = 0xF0 | code;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( _T("trying to encode undefined Unicode character") );
|
||||
out[0] = 0;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxUniChar wxUniCharRef::DecodeChar(wxStringImpl::const_iterator i)
|
||||
{
|
||||
wxASSERT( wxString::IsValidUtf8LeadByte(*i) ); // FIXME-UTF8: no "wxString::"
|
||||
|
||||
wxUniChar::value_type code = 0;
|
||||
size_t len = wxString::GetUtf8CharLength(*i);
|
||||
wxASSERT_MSG( len <= 4, _T("invalid UTF-8 sequence length") );
|
||||
|
||||
// Char. number range | UTF-8 octet sequence
|
||||
// (hexadecimal) | (binary)
|
||||
// ----------------------+---------------------------------------------
|
||||
// 0000 0000 - 0000 007F | 0xxxxxxx
|
||||
// 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx
|
||||
// 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
//
|
||||
// Code point value is stored in bits marked with 'x', lowest-order bit
|
||||
// of the value on the right side in the diagram above.
|
||||
// (from RFC 3629)
|
||||
|
||||
// mask to extract lead byte's value ('x' bits above), by sequence's length:
|
||||
static const unsigned char s_leadValueMask[4] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
||||
#ifdef __WXDEBUG__
|
||||
// mask and value of lead byte's most significant bits, by length:
|
||||
static const unsigned char s_leadMarkerMask[4] = { 0x80, 0xE0, 0xF0, 0xF8 };
|
||||
static const unsigned char s_leadMarkerVal[4] = { 0x00, 0xC0, 0xE0, 0xF0 };
|
||||
#endif
|
||||
|
||||
// extract the lead byte's value bits:
|
||||
wxASSERT_MSG( ((unsigned char)*i & s_leadMarkerMask[len-1]) ==
|
||||
s_leadMarkerVal[len-1],
|
||||
_T("invalid UTF-8 lead byte") );
|
||||
code = (unsigned char)*i & s_leadValueMask[len-1];
|
||||
|
||||
// all remaining bytes, if any, are handled in the same way regardless of
|
||||
// sequence's length:
|
||||
for ( ++i ; len > 1; --len, ++i )
|
||||
{
|
||||
wxASSERT_MSG( ((unsigned char)*i & 0xC0) == 0x80,
|
||||
_T("invalid UTF-8 byte") );
|
||||
|
||||
code <<= 6;
|
||||
code |= (unsigned char)*i & 0x3F;
|
||||
}
|
||||
|
||||
return wxUniChar(code);
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxCharBuffer wxString::EncodeNChars(size_t n, wxUniChar ch)
|
||||
{
|
||||
Utf8CharBuffer once(EncodeChar(ch));
|
||||
// the IncIter() table can be used to determine the length of ch's encoding:
|
||||
size_t len = ms_utf8IterTable[(unsigned char)once.data[0]];
|
||||
|
||||
wxCharBuffer buf(n * len);
|
||||
char *ptr = buf.data();
|
||||
for ( size_t i = 0; i < n; i++, ptr += len )
|
||||
{
|
||||
memcpy(ptr, once.data, len);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void wxString::PosLenToImpl(size_t pos, size_t len,
|
||||
size_t *implPos, size_t *implLen) const
|
||||
{
|
||||
|
306
src/common/stringops.cpp
Normal file
306
src/common/stringops.cpp
Normal file
@ -0,0 +1,306 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/common/stringops.cpp
|
||||
// Purpose: implementation of wxString primitive operations
|
||||
// Author: Vaclav Slavik
|
||||
// Modified by:
|
||||
// Created: 2007-04-16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2007 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// headers
|
||||
// ===========================================================================
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/stringops.h"
|
||||
#endif
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UTF-8 sequences lengths
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
unsigned char wxStringOperationsUtf8::ms_utf8IterTable[256] = {
|
||||
// single-byte sequences (ASCII):
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00..0F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10..1F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 20..2F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 30..3F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40..4F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 50..5F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60..6F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70..7F
|
||||
|
||||
// these are invalid, we use step 1 to skip
|
||||
// over them (should never happen):
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80..8F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90..9F
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A0..AF
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B0..BF
|
||||
1, 1, // C0,C1
|
||||
|
||||
// two-byte sequences:
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C2..CF
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D0..DF
|
||||
|
||||
// three-byte sequences:
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E0..EF
|
||||
|
||||
// four-byte sequences:
|
||||
4, 4, 4, 4, 4, // F0..F4
|
||||
|
||||
// these are invalid again (5- or 6-byte
|
||||
// sequences and sequences for code points
|
||||
// above U+10FFFF, as restricted by RFC 3629):
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F5..FF
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UTF-8 operations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Table 3.1B from Unicode spec: Legal UTF-8 Byte Sequences
|
||||
//
|
||||
// Code Points | 1st Byte | 2nd Byte | 3rd Byte | 4th Byte |
|
||||
// -------------------+----------+----------+----------+----------+
|
||||
// U+0000..U+007F | 00..7F | | | |
|
||||
// U+0080..U+07FF | C2..DF | 80..BF | | |
|
||||
// U+0800..U+0FFF | E0 | A0..BF | 80..BF | |
|
||||
// U+1000..U+FFFF | E1..EF | 80..BF | 80..BF | |
|
||||
// U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF |
|
||||
// U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF |
|
||||
// U+100000..U+10FFFF | F4 | 80..8F | 80..BF | 80..BF |
|
||||
// -------------------+----------+----------+----------+----------+
|
||||
|
||||
bool wxStringOperationsUtf8::IsValidUtf8String(const char *str)
|
||||
{
|
||||
if ( !str )
|
||||
return true; // empty string is UTF8 string
|
||||
|
||||
const unsigned char *c = (const unsigned char*)str;
|
||||
|
||||
for ( ; *c; ++c )
|
||||
{
|
||||
unsigned char b = *c;
|
||||
|
||||
if ( b <= 0x7F ) // 00..7F
|
||||
continue;
|
||||
|
||||
else if ( b < 0xC2 ) // invalid lead bytes: 80..C1
|
||||
return false;
|
||||
|
||||
// two-byte sequences:
|
||||
else if ( b <= 0xDF ) // C2..DF
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// three-byte sequences:
|
||||
else if ( b == 0xE0 )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0xA0 && b <= 0xBF ) )
|
||||
return false;
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
else if ( b <= 0xEF ) // E1..EF
|
||||
{
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// four-byte sequences:
|
||||
else if ( b == 0xF0 )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x90 && b <= 0xBF ) )
|
||||
return false;
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( b <= 0xF3 ) // F1..F3
|
||||
{
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( b == 0xF4 )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0x8F ) )
|
||||
return false;
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
b = *(++c);
|
||||
if ( !(b >= 0x80 && b <= 0xBF ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // otherwise, it's invalid lead byte
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
bool wxStringOperationsUtf8::IsValidUtf8LeadByte(unsigned char c)
|
||||
{
|
||||
return (c <= 0x7F) || (c >= 0xC2 && c <= 0xF4);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
wxStringOperationsUtf8::Utf8CharBuffer
|
||||
wxStringOperationsUtf8::EncodeChar(const wxUniChar& ch)
|
||||
{
|
||||
Utf8CharBuffer buf;
|
||||
char *out = buf.data;
|
||||
|
||||
wxUniChar::value_type code = ch.GetValue();
|
||||
|
||||
// Char. number range | UTF-8 octet sequence
|
||||
// (hexadecimal) | (binary)
|
||||
// ----------------------+---------------------------------------------
|
||||
// 0000 0000 - 0000 007F | 0xxxxxxx
|
||||
// 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx
|
||||
// 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
//
|
||||
// Code point value is stored in bits marked with 'x', lowest-order bit
|
||||
// of the value on the right side in the diagram above.
|
||||
// (from RFC 3629)
|
||||
|
||||
if ( code <= 0x7F )
|
||||
{
|
||||
out[1] = 0;
|
||||
out[0] = (char)code;
|
||||
}
|
||||
else if ( code <= 0x07FF )
|
||||
{
|
||||
out[2] = 0;
|
||||
// NB: this line takes 6 least significant bits, encodes them as
|
||||
// 10xxxxxx and discards them so that the next byte can be encoded:
|
||||
out[1] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[0] = 0xC0 | code;
|
||||
}
|
||||
else if ( code < 0xFFFF )
|
||||
{
|
||||
out[3] = 0;
|
||||
out[2] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[1] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[0] = 0xE0 | code;
|
||||
}
|
||||
else if ( code <= 0x10FFFF )
|
||||
{
|
||||
out[4] = 0;
|
||||
out[3] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[2] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[1] = 0x80 | (code & 0x3F); code >>= 6;
|
||||
out[0] = 0xF0 | code;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( _T("trying to encode undefined Unicode character") );
|
||||
out[0] = 0;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
wxUniChar
|
||||
wxStringOperationsUtf8::DecodeChar(wxStringImpl::const_iterator i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
|
||||
wxUniChar::value_type code = 0;
|
||||
size_t len = GetUtf8CharLength(*i);
|
||||
wxASSERT_MSG( len <= 4, _T("invalid UTF-8 sequence length") );
|
||||
|
||||
// Char. number range | UTF-8 octet sequence
|
||||
// (hexadecimal) | (binary)
|
||||
// ----------------------+---------------------------------------------
|
||||
// 0000 0000 - 0000 007F | 0xxxxxxx
|
||||
// 0000 0080 - 0000 07FF | 110xxxxx 10xxxxxx
|
||||
// 0000 0800 - 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// 0001 0000 - 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
//
|
||||
// Code point value is stored in bits marked with 'x', lowest-order bit
|
||||
// of the value on the right side in the diagram above.
|
||||
// (from RFC 3629)
|
||||
|
||||
// mask to extract lead byte's value ('x' bits above), by sequence's length:
|
||||
static const unsigned char s_leadValueMask[4] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
||||
#ifdef __WXDEBUG__
|
||||
// mask and value of lead byte's most significant bits, by length:
|
||||
static const unsigned char s_leadMarkerMask[4] = { 0x80, 0xE0, 0xF0, 0xF8 };
|
||||
static const unsigned char s_leadMarkerVal[4] = { 0x00, 0xC0, 0xE0, 0xF0 };
|
||||
#endif
|
||||
|
||||
// extract the lead byte's value bits:
|
||||
wxASSERT_MSG( ((unsigned char)*i & s_leadMarkerMask[len-1]) ==
|
||||
s_leadMarkerVal[len-1],
|
||||
_T("invalid UTF-8 lead byte") );
|
||||
code = (unsigned char)*i & s_leadValueMask[len-1];
|
||||
|
||||
// all remaining bytes, if any, are handled in the same way regardless of
|
||||
// sequence's length:
|
||||
for ( ++i ; len > 1; --len, ++i )
|
||||
{
|
||||
wxASSERT_MSG( ((unsigned char)*i & 0xC0) == 0x80,
|
||||
_T("invalid UTF-8 byte") );
|
||||
|
||||
code <<= 6;
|
||||
code |= (unsigned char)*i & 0x3F;
|
||||
}
|
||||
|
||||
return wxUniChar(code);
|
||||
}
|
||||
|
||||
wxCharBuffer wxStringOperationsUtf8::EncodeNChars(size_t n, const wxUniChar& ch)
|
||||
{
|
||||
Utf8CharBuffer once(EncodeChar(ch));
|
||||
// the IncIter() table can be used to determine the length of ch's encoding:
|
||||
size_t len = ms_utf8IterTable[(unsigned char)once.data[0]];
|
||||
|
||||
wxCharBuffer buf(n * len);
|
||||
char *ptr = buf.data();
|
||||
for ( size_t i = 0; i < n; i++, ptr += len )
|
||||
{
|
||||
memcpy(ptr, once.data, len);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif // wxUSE_UNICODE_UTF8
|
@ -24,9 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/unichar.h"
|
||||
|
||||
// FIXME-UTF8: remove once UTF-8 functions moved outside
|
||||
#include "wx/string.h"
|
||||
#include "wx/stringops.h"
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
@ -69,11 +67,16 @@ char wxUniChar::To8bit(wxUniChar::value_type c)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
wxUniChar wxUniCharRef::UniChar() const
|
||||
{
|
||||
return wxStringOperations::DecodeChar(m_pos);
|
||||
}
|
||||
|
||||
wxUniCharRef& wxUniCharRef::operator=(const wxUniChar& c)
|
||||
{
|
||||
wxString::Utf8CharBuffer utf(wxString::EncodeChar(c));
|
||||
size_t lenOld = wxString::GetUtf8CharLength(*m_pos);
|
||||
size_t lenNew = wxString::GetUtf8CharLength(utf[0]);
|
||||
wxStringOperations::Utf8CharBuffer utf(wxStringOperations::EncodeChar(c));
|
||||
size_t lenOld = wxStringOperations::GetUtf8CharLength(*m_pos);
|
||||
size_t lenNew = wxStringOperations::GetUtf8CharLength(utf[0]);
|
||||
|
||||
if ( lenNew == lenOld )
|
||||
{
|
||||
|
@ -298,6 +298,7 @@ wx/strconv.h
|
||||
wx/stream.h
|
||||
wx/string.h
|
||||
wx/stringimpl.h
|
||||
wx/stringops.h
|
||||
wx/strvararg.h
|
||||
wx/sysopt.h
|
||||
wx/tarstrm.h
|
||||
|
@ -201,6 +201,7 @@ wx/strconv.h
|
||||
wx/stream.h
|
||||
wx/string.h
|
||||
wx/stringimpl.h
|
||||
wx/stringops.h
|
||||
wx/strvararg.h
|
||||
wx/sysopt.h
|
||||
wx/tarstrm.h
|
||||
|
@ -226,6 +226,7 @@ wx/strconv.h
|
||||
wx/stream.h
|
||||
wx/string.h
|
||||
wx/stringimpl.h
|
||||
wx/stringops.h
|
||||
wx/strvararg.h
|
||||
wx/sysopt.h
|
||||
wx/tarstrm.h
|
||||
|
Loading…
Reference in New Issue
Block a user