From b2e04188bd940ce8933394fee71790c9887ba32c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Oct 2010 23:06:11 +0000 Subject: [PATCH 1/1] Make wxUString compilable with VC6. Provide replacements for std::basic_string functionality missing from this compiler standard library. Closes #12357. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/ustring.h | 74 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/include/wx/ustring.h b/include/wx/ustring.h index e12c1dfeac..0c00b6f9df 100644 --- a/include/wx/ustring.h +++ b/include/wx/ustring.h @@ -200,17 +200,43 @@ public: return (wxUString &) base->assign( str, pos, n ); } - wxUString &assign( wxChar32 ch ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( (size_type) 1, ch ); - } + // FIXME-VC6: VC 6.0 stl does not support all types of assign functions + #ifdef __VISUALC6__ + wxUString &assign( wxChar32 ch ) + { + wxChar32 chh[1]; + chh[0] = ch; + std::basic_string *base = this; + return (wxUString &)base->assign(chh); + } - wxUString &assign( size_type n, wxChar32 ch ) - { - std::basic_string *base = this; - return (wxUString &) base->assign( n, ch ); - } + wxUString &assign( size_type n, wxChar32 ch ) + { + wxU32CharBuffer buffer(n); + wxChar32 *p = buffer.data(); + size_type i; + for (i = 0; i < n; i++) + { + *p = ch; + p++; + } + + std::basic_string *base = this; + return (wxUString &)base->assign(buffer.data()); + } + #else + wxUString &assign( wxChar32 ch ) + { + std::basic_string *base = this; + return (wxUString &) base->assign( (size_type) 1, ch ); + } + + wxUString &assign( size_type n, wxChar32 ch ) + { + std::basic_string *base = this; + return (wxUString &) base->assign( n, ch ); + } + #endif // __VISUALC6__ wxUString &assign( const wxScopedU32CharBuffer &buf ) { @@ -357,11 +383,29 @@ public: return (wxUString &) base->append( s, n ); } - wxUString &append( size_type n, wxChar32 c ) - { - std::basic_string *base = this; - return (wxUString &) base->append( n, c ); - } + // FIXME-VC6: VC 6.0 stl does not support all types of append functions + #ifdef __VISUALC6__ + wxUString &append( size_type n, wxChar32 c ) + { + wxU32CharBuffer buffer(n); + wxChar32 *p = buffer.data(); + size_type i; + for (i = 0; i < n; i++) + { + *p = c; + p++; + } + + std::basic_string *base = this; + return (wxUString &) base->append(buffer.data()); + } + #else + wxUString &append( size_type n, wxChar32 c ) + { + std::basic_string *base = this; + return (wxUString &) base->append( n, c ); + } + #endif // __VISUALC6__ wxUString &append( wxChar32 c ) { -- 2.45.2