Merge pull request #10148 from leezh/pcre2

Replacement of internal RegEx with PCRE2
This commit is contained in:
Rémi Verschelde 2017-08-31 11:56:19 +02:00 committed by GitHub
commit 0cee288c11
63 changed files with 88352 additions and 1411 deletions

View file

@ -31,59 +31,53 @@
#ifndef REGEX_H
#define REGEX_H
#include "core/array.h"
#include "core/dictionary.h"
#include "core/map.h"
#include "core/reference.h"
#include "core/resource.h"
#include "core/ustring.h"
#include "core/vector.h"
class RegExNode;
class RegExMatch : public Reference {
GDCLASS(RegExMatch, Reference);
struct Group {
Variant name;
struct Range {
int start;
int length;
int end;
};
Vector<Group> captures;
String string;
String subject;
Vector<Range> data;
Map<String, int> names;
friend class RegEx;
friend class RegExSearch;
friend class RegExNodeCapturing;
friend class RegExNodeBackReference;
protected:
static void _bind_methods();
int _find(const Variant &p_name) const;
public:
String expand(const String &p_template) const;
String get_subject() const;
int get_group_count() const;
Array get_group_array() const;
Array get_names() const;
Dictionary get_name_dict() const;
Dictionary get_names() const;
Array get_strings() const;
String get_string(const Variant &p_name) const;
int get_start(const Variant &p_name) const;
int get_end(const Variant &p_name) const;
RegExMatch();
};
class RegEx : public Resource {
class RegEx : public Reference {
GDCLASS(RegEx, Resource);
GDCLASS(RegEx, Reference);
RegExNode *root;
Vector<Variant> group_names;
void *general_ctx;
void *code;
String pattern;
int lookahead_depth;
void _pattern_info(uint32_t what, void *where) const;
protected:
static void _bind_methods();
@ -91,9 +85,10 @@ protected:
public:
void clear();
Error compile(const String &p_pattern);
void _init(const String &p_pattern = "");
Ref<RegExMatch> search(const String &p_text, int p_start = 0, int p_end = -1) const;
String sub(const String &p_text, const String &p_replacement, bool p_all = false, int p_start = 0, int p_end = -1) const;
Ref<RegExMatch> search(const String &p_subject, int offset = 0, int end = -1) const;
String sub(const String &p_subject, const String &p_replacement, bool p_all = false, int p_start = 0, int p_end = -1) const;
bool is_valid() const;
String get_pattern() const;