summaryrefslogtreecommitdiff
path: root/Ivy/Regexp.h
blob: 326556159abbd90ccdea1f3cfa8e118480dbf8e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef __REGEXP_H__
#define __REGEXP_H__


class regexp;

class Regexp
{
public:
	enum { NSUBEXP = 20 };

	Regexp();
	Regexp( const char * exp, bool iCase = 0 );
	Regexp( const Regexp &r );
	~Regexp();
	const Regexp & operator=( const Regexp & r );

	bool Match( const char * s );
	int SubStrings() const;
	
	const String operator[]( unsigned int i ) const;
	int SubStart( unsigned int i ) const;
	int SubLength( unsigned int i ) const;

	String GetReplaceString( const char * source ) const;

	String GetErrorString() const;
	bool CompiledOK() const;

#if defined( _RE_DEBUG )
	void Dump();
#endif
private:
	const char * str;	/* used to return substring offsets only */
	mutable String m_szError;
	regexp * rc;

	void ClearErrorString() const;
	int safeIndex( unsigned int i ) const;

};

#endif