Home » Developing U++ » U++ Developers corner » why no virtual destructor for RegExp?
Re: why no virtual destructor for RegExp? [message #38891 is a reply to message #38889] |
Fri, 25 January 2013 17:37   |
navi
Messages: 107 Registered: February 2012 Location: Sydney, Australia
|
Experienced Member |
|
|
Quote: | IMHO the pattern parameter should not be there, it is kind of confusing and against the whole idea that RegExp object represents the regexp pattern. If you want to have a chance to specify the replace pattern a separate global function might be better for this... It could use the RegExp object internally, so it's not much work for you
|
You are right. I think its best to get rid of pattern from arguments. Actually I was trying to match preg_replace style. which is not particularly suited for regexp class.
Quote: | Why not simply
int ReplaceGlobal(String& t, const String r, offset=0, bool backref=false);
|
well you see, the functions Match() and GlobalMatch() has no option for offset. in order for offset to work I had to device my own function using Execute(). however then I realize if written using GlobalMatch() even-though no option for offset, but it is much more solid and more compatible then to my own version with offset. now I wanted to have the best of both hence two different function and not option=0 as default value. I believe we can still mimic the default value effect if we write the following:
int ReplaceGlobal(String& t, const String r, bool backref=false);
int ReplaceGlobal(String& t, const String r, offset, bool backref=false);
essentially if offset is not given then the function using GlobalMatch() will be called. if offset given, then the version using Execute() will be called instead. or perhaps drop the whole idea of starting offset, like the author of Match() and GlobalMatch()? I cant get my head around function GlobalMatch(). if I could understand it fully, then I can rewrite the exact thing using Execute() alone and we then could have one function for like you pointed out.
Quote: | PS: I forgot... About the returning, I think it is okay to modify the referenced string. If necessary it should be simple to add a another method with separate string for output, that would not modify the input.
|
I agree, I have no problem doing either way. the only issue being if we wish to return the output text then, we will have 2 return values, 1: the replace count, 2: the output text. one of which have to go, or go in to function argument as reference variable.
Thanks for all your help & pointers.
Regards
Navi
[Updated on: Fri, 25 January 2013 21:09] Report message to a moderator
|
|
|
 |
|
why no virtual destructor for RegExp?
By: navi on Sat, 19 January 2013 06:22
|
 |
|
Re: why no virtual destructor for RegExp?
By: mirek on Sat, 19 January 2013 12:03
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Sat, 19 January 2013 12:30
|
 |
|
Re: why no virtual destructor for RegExp?
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Sat, 19 January 2013 13:26
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Fri, 25 January 2013 14:58
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Fri, 25 January 2013 15:01
|
 |
|
Re: why no virtual destructor for RegExp?
|
 |
|
Re: why no virtual destructor for RegExp?
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Fri, 25 January 2013 17:37
|
 |
|
Re: why no virtual destructor for RegExp?
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Mon, 28 January 2013 07:11
|
 |
|
Re: why no virtual destructor for RegExp?
By: mirek on Tue, 19 February 2013 17:15
|
 |
|
Re: why no virtual destructor for RegExp?
By: navi on Wed, 20 February 2013 00:23
|
Goto Forum:
Current Time: Mon Jun 09 07:05:29 CEST 2025
Total time taken to generate the page: 0.05938 seconds
|