diff options
Diffstat (limited to 'modules/regex/regex.h')
-rw-r--r-- | modules/regex/regex.h | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/modules/regex/regex.h b/modules/regex/regex.h index 106d2649a5..0d97bcce54 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -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(); -public: - String expand(const String &p_template) const; + int _find(const Variant &p_name) const; +public: + 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; |