ADTF
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/regularexpression.h
Go to the documentation of this file.
1 
7 #ifndef _REGULAR_EXPRESSION_CLASS_HEADER_
8 #define _REGULAR_EXPRESSION_CLASS_HEADER_
9 
10 namespace A_UTILS_NS
11 {
12 
18 class DOEXPORT cRegularExpression
19 {
21 
22  public:
24  typedef enum
25  {
26  AT_Unanchored, // No anchoring
27  AT_Start, // Anchor at start only
28  AT_Both // Anchor at start and end
29  } tAnchorType;
30 
31  public:
33 
34  public:
39 
45 
50  cRegularExpression(const cString& strExpression);
51 
57  cRegularExpression(const tChar* strExpression, tBool bCaseSensitive = tTrue);
58 
63 
70  tResult Set(const cString& strExpression, tBool bCaseSensitive = tTrue);
71 
78  tResult Set(const tChar* strExpression, tBool bCaseSensitive = tTrue);
79 
85 
90  cString GetError() const;
98  tBool Replace(const cStringPiece& rewrite, cString *str) const;
108  tInt GlobalReplace(const cStringPiece& rewrite, cString *str) const;
116  tBool Extract(const cStringPiece &rewrite, const cStringPiece &text, cString *out) const;
117 
126 
137  tBool DoMatch(const cStringPiece& text, tAnchorType anchor, tInt* consumed,
138  const cRegularExpressionArg* args, tInt n) const;
139 
164  const cRegularExpressionArg& ptr1 = oNoArg,
165  const cRegularExpressionArg& ptr2 = oNoArg,
166  const cRegularExpressionArg& ptr3 = oNoArg,
167  const cRegularExpressionArg& ptr4 = oNoArg,
168  const cRegularExpressionArg& ptr5 = oNoArg,
169  const cRegularExpressionArg& ptr6 = oNoArg,
170  const cRegularExpressionArg& ptr7 = oNoArg,
171  const cRegularExpressionArg& ptr8 = oNoArg,
172  const cRegularExpressionArg& ptr9 = oNoArg,
173  const cRegularExpressionArg& ptr10 = oNoArg,
174  const cRegularExpressionArg& ptr11 = oNoArg,
175  const cRegularExpressionArg& ptr12 = oNoArg,
176  const cRegularExpressionArg& ptr13 = oNoArg,
177  const cRegularExpressionArg& ptr14 = oNoArg,
178  const cRegularExpressionArg& ptr15 = oNoArg,
179  const cRegularExpressionArg& ptr16 = oNoArg) const;
180 
205  const cRegularExpressionArg& ptr1 = oNoArg,
206  const cRegularExpressionArg& ptr2 = oNoArg,
207  const cRegularExpressionArg& ptr3 = oNoArg,
208  const cRegularExpressionArg& ptr4 = oNoArg,
209  const cRegularExpressionArg& ptr5 = oNoArg,
210  const cRegularExpressionArg& ptr6 = oNoArg,
211  const cRegularExpressionArg& ptr7 = oNoArg,
212  const cRegularExpressionArg& ptr8 = oNoArg,
213  const cRegularExpressionArg& ptr9 = oNoArg,
214  const cRegularExpressionArg& ptr10 = oNoArg,
215  const cRegularExpressionArg& ptr11 = oNoArg,
216  const cRegularExpressionArg& ptr12 = oNoArg,
217  const cRegularExpressionArg& ptr13 = oNoArg,
218  const cRegularExpressionArg& ptr14 = oNoArg,
219  const cRegularExpressionArg& ptr15 = oNoArg,
220  const cRegularExpressionArg& ptr16 = oNoArg) const;
221 
246  const cRegularExpressionArg& ptr1 = oNoArg,
247  const cRegularExpressionArg& ptr2 = oNoArg,
248  const cRegularExpressionArg& ptr3 = oNoArg,
249  const cRegularExpressionArg& ptr4 = oNoArg,
250  const cRegularExpressionArg& ptr5 = oNoArg,
251  const cRegularExpressionArg& ptr6 = oNoArg,
252  const cRegularExpressionArg& ptr7 = oNoArg,
253  const cRegularExpressionArg& ptr8 = oNoArg,
254  const cRegularExpressionArg& ptr9 = oNoArg,
255  const cRegularExpressionArg& ptr10 = oNoArg,
256  const cRegularExpressionArg& ptr11 = oNoArg,
257  const cRegularExpressionArg& ptr12 = oNoArg,
258  const cRegularExpressionArg& ptr13 = oNoArg,
259  const cRegularExpressionArg& ptr14 = oNoArg,
260  const cRegularExpressionArg& ptr15 = oNoArg,
261  const cRegularExpressionArg& ptr16 = oNoArg) const;
262 
289  const cRegularExpressionArg& ptr1 = oNoArg,
290  const cRegularExpressionArg& ptr2 = oNoArg,
291  const cRegularExpressionArg& ptr3 = oNoArg,
292  const cRegularExpressionArg& ptr4 = oNoArg,
293  const cRegularExpressionArg& ptr5 = oNoArg,
294  const cRegularExpressionArg& ptr6 = oNoArg,
295  const cRegularExpressionArg& ptr7 = oNoArg,
296  const cRegularExpressionArg& ptr8 = oNoArg,
297  const cRegularExpressionArg& ptr9 = oNoArg,
298  const cRegularExpressionArg& ptr10 = oNoArg,
299  const cRegularExpressionArg& ptr11 = oNoArg,
300  const cRegularExpressionArg& ptr12 = oNoArg,
301  const cRegularExpressionArg& ptr13 = oNoArg,
302  const cRegularExpressionArg& ptr14 = oNoArg,
303  const cRegularExpressionArg& ptr15 = oNoArg,
304  const cRegularExpressionArg& ptr16 = oNoArg) const;
305 
306  private:
307  tVoid* m_pInternalObj;
308  tBool m_bIsCaseSensitive;
309 };
310 
311 } // namespace A_UTILS_NS
312 
313 #endif // _REGULAR_EXPRESSION_CLASS_HEADER_
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
void tVoid
The tVoid is always the definition for the void (non-type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
Regular expression argument class.
tBool FullMatch(const cStringPiece &text, const cRegularExpressionArg &ptr1=oNoArg, const cRegularExpressionArg &ptr2=oNoArg, const cRegularExpressionArg &ptr3=oNoArg, const cRegularExpressionArg &ptr4=oNoArg, const cRegularExpressionArg &ptr5=oNoArg, const cRegularExpressionArg &ptr6=oNoArg, const cRegularExpressionArg &ptr7=oNoArg, const cRegularExpressionArg &ptr8=oNoArg, const cRegularExpressionArg &ptr9=oNoArg, const cRegularExpressionArg &ptr10=oNoArg, const cRegularExpressionArg &ptr11=oNoArg, const cRegularExpressionArg &ptr12=oNoArg, const cRegularExpressionArg &ptr13=oNoArg, const cRegularExpressionArg &ptr14=oNoArg, const cRegularExpressionArg &ptr15=oNoArg, const cRegularExpressionArg &ptr16=oNoArg) const
Checks if the whole string matches.
tResult Set(const tChar *strExpression, tBool bCaseSensitive=tTrue)
Sets the regular expression string.
tInt GetNumberOfCapturingGroups() const
Returns the number of capturing groups.
cRegularExpression(const tChar *strExpression, tBool bCaseSensitive=tTrue)
Constructor with preset expression.
cRegularExpression(const cString &strExpression)
Constructor with preset expression.
cRegularExpression()
Default constructor.
tBool Consume(cStringPiece &input, const cRegularExpressionArg &ptr1=oNoArg, const cRegularExpressionArg &ptr2=oNoArg, const cRegularExpressionArg &ptr3=oNoArg, const cRegularExpressionArg &ptr4=oNoArg, const cRegularExpressionArg &ptr5=oNoArg, const cRegularExpressionArg &ptr6=oNoArg, const cRegularExpressionArg &ptr7=oNoArg, const cRegularExpressionArg &ptr8=oNoArg, const cRegularExpressionArg &ptr9=oNoArg, const cRegularExpressionArg &ptr10=oNoArg, const cRegularExpressionArg &ptr11=oNoArg, const cRegularExpressionArg &ptr12=oNoArg, const cRegularExpressionArg &ptr13=oNoArg, const cRegularExpressionArg &ptr14=oNoArg, const cRegularExpressionArg &ptr15=oNoArg, const cRegularExpressionArg &ptr16=oNoArg) const
Repeatedly match the front of a string.
tBool Replace(const cStringPiece &rewrite, cString *str) const
Replaces the first match of str with rewrite.
tResult Set(const cString &strExpression, tBool bCaseSensitive=tTrue)
Sets the regular expression string.
virtual ~cRegularExpression()
Destructor.
tInt GlobalReplace(const cStringPiece &rewrite, cString *str) const
Replaces all matches of str with rewrite.
tBool PartialMatch(const cStringPiece &text, const cRegularExpressionArg &ptr1=oNoArg, const cRegularExpressionArg &ptr2=oNoArg, const cRegularExpressionArg &ptr3=oNoArg, const cRegularExpressionArg &ptr4=oNoArg, const cRegularExpressionArg &ptr5=oNoArg, const cRegularExpressionArg &ptr6=oNoArg, const cRegularExpressionArg &ptr7=oNoArg, const cRegularExpressionArg &ptr8=oNoArg, const cRegularExpressionArg &ptr9=oNoArg, const cRegularExpressionArg &ptr10=oNoArg, const cRegularExpressionArg &ptr11=oNoArg, const cRegularExpressionArg &ptr12=oNoArg, const cRegularExpressionArg &ptr13=oNoArg, const cRegularExpressionArg &ptr14=oNoArg, const cRegularExpressionArg &ptr15=oNoArg, const cRegularExpressionArg &ptr16=oNoArg) const
Checks if any substring matches.
cString GetPattern() const
Returns the current pattern (expression).
cString GetError() const
Returns a string representation of the last error (if any).
cRegularExpression(const cRegularExpression &oRegExp)
Copy constructor.
tBool FindAndConsume(cStringPiece &input, const cRegularExpressionArg &ptr1=oNoArg, const cRegularExpressionArg &ptr2=oNoArg, const cRegularExpressionArg &ptr3=oNoArg, const cRegularExpressionArg &ptr4=oNoArg, const cRegularExpressionArg &ptr5=oNoArg, const cRegularExpressionArg &ptr6=oNoArg, const cRegularExpressionArg &ptr7=oNoArg, const cRegularExpressionArg &ptr8=oNoArg, const cRegularExpressionArg &ptr9=oNoArg, const cRegularExpressionArg &ptr10=oNoArg, const cRegularExpressionArg &ptr11=oNoArg, const cRegularExpressionArg &ptr12=oNoArg, const cRegularExpressionArg &ptr13=oNoArg, const cRegularExpressionArg &ptr14=oNoArg, const cRegularExpressionArg &ptr15=oNoArg, const cRegularExpressionArg &ptr16=oNoArg) const
Repeatedly match a string.
tBool Extract(const cStringPiece &rewrite, const cStringPiece &text, cString *out) const
Extracts all replaced matches of text into out.
tBool DoMatch(const cStringPiece &text, tAnchorType anchor, tInt *consumed, const cRegularExpressionArg *args, tInt n) const
Matches a string.
Class that represents string pieces.
#define tTrue
Value for tBool.
Definition: constants.h:62
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11