From: Vadim Zeitlin Date: Sun, 28 Feb 2010 11:09:11 +0000 (+0000) Subject: Fix for wxStringCheck compilation under IRIX using mipsPro. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3e026ad22ef21bf59b87c0933194535227c9ce2e Fix for wxStringCheck compilation under IRIX using mipsPro. IRIX mipsPro 7.4 refuses to instantiate a template with an inline function as parameter. Work around this by using a function taking a function pointer instead of using template wxStringCheck with inline wxIs{alpha,alnum,digit}. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 48b8bf3e32..ebd0c3cefc 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -201,17 +201,38 @@ bool wxTextValidator::TransferFromWindow() return true; } +// IRIX mipsPro refuses to compile wxStringCheck() if func is inline so +// let's work around this by using this non-template function instead of +// wxStringCheck(). And while this might be fractionally less efficient because +// the function call won't be inlined like this, we don't care enough about +// this to add extra #ifs for non-IRIX case. +namespace +{ + +bool CheckString(bool (*func)(const wxUniChar&), const wxString& str) +{ + for ( wxString::const_iterator i = str.begin(); i != str.end(); ++i ) + { + if ( !func(*i) ) + return false; + } + + return true; +} + +} // anonymous namespace + wxString wxTextValidator::IsValid(const wxString& val) const { // wxFILTER_EMPTY is checked for in wxTextValidator::Validate if ( HasFlag(wxFILTER_ASCII) && !val.IsAscii() ) return _("'%s' should only contain ASCII characters."); - if ( HasFlag(wxFILTER_ALPHA) && !wxStringCheck(val) ) + if ( HasFlag(wxFILTER_ALPHA) && !CheckString(wxIsalpha, val) ) return _("'%s' should only contain alphabetic characters."); - if ( HasFlag(wxFILTER_ALPHANUMERIC) && !wxStringCheck(val) ) + if ( HasFlag(wxFILTER_ALPHANUMERIC) && !CheckString(wxIsalnum, val) ) return _("'%s' should only contain alphabetic or numeric characters."); - if ( HasFlag(wxFILTER_DIGITS) && !wxStringCheck(val) ) + if ( HasFlag(wxFILTER_DIGITS) && CheckString(wxIsdigit, val) ) return _("'%s' should only contain digits."); if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) ) return _("'%s' should be numeric.");