case insensitive find() in wxString

Francesco Montorsi f18m_cpp217828 at yahoo.it
Wed Aug 2 01:10:12 PDT 2006


Vadim Zeitlin ha scritto:
> On Tue, 01 Aug 2006 12:24:56 +0200 Francesco Montorsi <f18m_cpp217828 at yahoo.it> wrote:
> 
> FM>     I'd like to know if you would accept patches which adds a "bool
> FM> caseSensitive = true" argument (or rather a "caseCompare cmp = exact"
> FM> argument) to the wxString::Find() function.
> 
>  If we were to do it, I'd rather have something like
> 
> 	enum { Case_Exact, Case_Ignore };
> 	enum { Find_Start = 0, Find_End = 0x8000 };
> 	Find(wxChar ch, int flags = Case_Exact | Find_Start);
> 
> i.e. use bit flags instead of the existing boolean parameter as well.
ok


> FM> This patch would allow to append the "caseCompare cmp = exact" argument 
> FM> to various functions (e.g. Contains, Replace, After/Before First/Last, 
> FM> StartsWith / EndsWith). Specially for wxString::Contains and Replace() 
> FM> that would be very useful IMO.
> ....
> FM> What's your opinion ?
> 
>  To be honest, I'm undecided. On one hand, I do see how could this be
> useful. OTOH we plan to switch to std::string at some moment in the future
> and adding yet more features which the standard class doesn't have is going
> to make switching even more difficult.
BTW, why should we switch to std::string in future ?
Also, there are already various functions in wxString which do not exist 
in std::string, isn't it?

> Does the convenience of writing
> Find('x', Case_Ignore) instead of find_first_of("xX") really outweigh this?
besides being (slightly) more readable the first form :), (AFAIK) you 
can't currently do e.g.:

    wxString str("  Hello World!");
    str.Find("hElLo WoRlD", Case_Ignore)		//  1 match!

and the same with all other functions which could get the additional 
"Case_Ignore" parameter...

Francesco







More information about the wx-dev mailing list