Home » Developing U++ » U++ Developers corner » why no virtual destructor for RegExp?
Re: why no virtual destructor for RegExp? [message #38887 is a reply to message #38795] |
Fri, 25 January 2013 14:58   |
navi
Messages: 107 Registered: February 2012 Location: Sydney, Australia
|
Experienced Member |
|
|
Hi All,
Just an update what I am up to so far. I manage to code a replica of preg_replace of php. due to the difference in nature of variable type, I had to almost 4 overloaded function to match all the things "preg_replace" can do in a single function definition.
//===================================================================================
// My Extension to RegExp
//===================================================================================
protected:
bool ReplacePos(String& t, int p, int q, const String r);
int Replace0(String& t, Vector<String>& rv, const int& rv_count, int& offset);
Vector<String> ResolveBackRef(Vector<String>& rv);
Vector<String> Make_rv(const String& r);
public:
int ReplaceGlobal(String& t, Vector<String>& rv, const String pattern=Null, bool backref=false); //DONE
int ReplaceGlobal(String& t, Vector<String>& rv, int offset, const String pattern=Null, bool backref=false); //DONE
int ReplaceGlobal(String& t, const String r, const String pattern=Null, bool backref=false); //DONE
int ReplaceGlobal(String& t, const String r, int offset, const String pattern=Null, bool backref=false); //DONE
int ReplaceGlobal(String& t, Callback cbr, const String pattern=Null, bool backref=false); // NOT YET
int ReplaceGlobal(String& t, Callback cbr, int offset, const String pattern=Null, bool backref=false); //NOT YET
My plan is to implement 6 flavor of ReplaceGlobal() and 6 flavor of Replace(). all based on how replace text or callback function are given.
replace text can either be given as single String in Parentheses format just like a regular expression. ie (replace_a)(replace_b)(replace_c). Or can be given a vector containing three Strings. Also callback function can be passed in place of replace texts.
regexp pattern can also be given as argument. instead of setting it using SetPattern()
backref = is a on/off switch for resolving/expanding back reference given in replace text as /1, /2, /3 etc. where the number is the number of the match string cough by the regexp pattern.
Thanks & Regards
Navi
[Updated on: Mon, 28 January 2013 06:52] 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 17:18:33 CEST 2025
Total time taken to generate the page: 0.01106 seconds
|