summaryrefslogtreecommitdiff
path: root/drivers/nrex/regex.h
blob: 4b063f0bf1830d02ba7a7595e3507d0bed187afa (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
45
46
47
48
/*************************************************/
/*  regex.h                                      */
/*************************************************/
/*            This file is part of:              */
/*                GODOT ENGINE                   */
/*************************************************/
/*       Source code within this file is:        */
/*  (c) 2007-2016 Juan Linietsky, Ariel Manzur   */
/*             All Rights Reserved.              */
/*************************************************/

#ifndef REGEX_H
#define REGEX_H

#include "ustring.h"
#include "vector.h"
#include "core/reference.h"
#include "nrex.hpp"

class RegEx : public Reference {

	OBJ_TYPE(RegEx, Reference);

	mutable String text;
	mutable Vector<nrex_result> captures;
	nrex exp;

protected:

	static void _bind_methods();
	StringArray _bind_get_captures() const;

public:

	void clear();
	bool is_valid() const;
	int get_capture_count() const;
	int get_capture_start(int capture) const;
	String get_capture(int capture) const;
	Error compile(const String& p_pattern, int capture = 9);
	int find(const String& p_text, int p_start = 0, int p_end = -1) const;

	RegEx();
	RegEx(const String& p_pattern);
	~RegEx();
};

#endif // REGEX_H