case insensitive find() in wxString

Francesco Montorsi f18m_cpp217828 at yahoo.it
Wed Aug 2 06:53:24 PDT 2006


Jorgen Bodde ha scritto:
> The discussion was that if we introduce more functionality that is not 
> related to std::string, it will be hard to convert the wxString to 
> std::string in the future (which Vadim mentioned).
> 
> So instead of bloating wxString, take it out and keep it as seperate 
> class. 
well, as ABX pointed out looking at string.h it seems that wxStringBase 
is the std::string replacement when std::string is not usable and that 
wxString (which derives from wxStringBase) implements all 
wxString-specific methods which are not part of std::string.
So I think that the two layers are already there.
However I still do not understand why should we want to switch from 
wxString to std::string in future.... as far as wxString and std::string 
are "compatible" (i.e. it's easy to convert in both senses in projects 
which need to use both) I don't see any advantage from such switch.

>With advantages that it can be expanded with e.g.
> 
> - A parser component (wxStringUtils::PeekChar, wxStringUtils::PopChar, 
> wxStringUtils::ParseToken)
have you looked at wxStringTokenizer and wxStringTokenize(); maybe they 
already provide what you need ?

> - More comprehensive routines to generate e.g. a comma seperated list
I was going to propose a patch for these too :)
I.e. in my SoC project I'm currently doing a LOT of times things like:

     wxArrayString arr = ...
     wxString str;
     for (size_t i=0; i < max; i++)
	str += arr[i] + wxT(",");
     if (str.EndsWith(wxT(",")))
         str.RemoveLast();

I think that adding two functions like:

    wxString wxArrayString::Join(const wxString &sep = wxT(",")) const;

    wxArrayString wxString::Split(const wxString &sep = wxT(",")) const
	{ return ::wxStringTokenize(*this, sep); }

(which resemble python's join() and split() methods) would make the use 
of wxArrayString+wxString much more easier.


Francesco





More information about the wx-dev mailing list