1 /**
2 Contains the results of a $(D RegEx) search.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.regexmatch;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.reference;
25 /**
26 Contains the results of a $(D RegEx) search.
27 
28 Contains the results of a single $(D RegEx) match returned by $(D RegEx.search) and $(D RegEx.searchAll). It can be used to find the position and range of the match and its capturing groups, and it can extract its substring for you.
29 */
30 @GodotBaseClass struct RegExMatch
31 {
32 	package(godot) enum string _GODOT_internal_name = "RegExMatch";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ Reference _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("get_end") GodotMethod!(long, Variant) getEnd;
43 		@GodotName("get_group_count") GodotMethod!(long) getGroupCount;
44 		@GodotName("get_names") GodotMethod!(Dictionary) getNames;
45 		@GodotName("get_start") GodotMethod!(long, Variant) getStart;
46 		@GodotName("get_string") GodotMethod!(String, Variant) getString;
47 		@GodotName("get_strings") GodotMethod!(Array) getStrings;
48 		@GodotName("get_subject") GodotMethod!(String) getSubject;
49 	}
50 	/// 
51 	pragma(inline, true) bool opEquals(in RegExMatch other) const
52 	{ return _godot_object.ptr is other._godot_object.ptr; }
53 	/// 
54 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
55 	{ _godot_object.ptr = n; return null; }
56 	/// 
57 	pragma(inline, true) bool opEquals(typeof(null) n) const
58 	{ return _godot_object.ptr is n; }
59 	/// 
60 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
61 	mixin baseCasts;
62 	/// Construct a new instance of RegExMatch.
63 	/// Note: use `memnew!RegExMatch` instead.
64 	static RegExMatch _new()
65 	{
66 		static godot_class_constructor constructor;
67 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("RegExMatch");
68 		if(constructor is null) return typeof(this).init;
69 		return cast(RegExMatch)(constructor());
70 	}
71 	@disable new(size_t s);
72 	/**
73 	Returns the end position of the match within the source string. The end position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.
74 	Returns -1 if the group did not match or doesn't exist.
75 	*/
76 	long getEnd(VariantArg0)(in VariantArg0 name = 0) const
77 	{
78 		checkClassBinding!(typeof(this))();
79 		return ptrcall!(long)(GDNativeClassBinding.getEnd, _godot_object, name);
80 	}
81 	/**
82 	Returns the number of capturing groups.
83 	*/
84 	long getGroupCount() const
85 	{
86 		checkClassBinding!(typeof(this))();
87 		return ptrcall!(long)(GDNativeClassBinding.getGroupCount, _godot_object);
88 	}
89 	/**
90 	
91 	*/
92 	Dictionary getNames() const
93 	{
94 		checkClassBinding!(typeof(this))();
95 		return ptrcall!(Dictionary)(GDNativeClassBinding.getNames, _godot_object);
96 	}
97 	/**
98 	Returns the starting position of the match within the source string. The starting position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.
99 	Returns -1 if the group did not match or doesn't exist.
100 	*/
101 	long getStart(VariantArg0)(in VariantArg0 name = 0) const
102 	{
103 		checkClassBinding!(typeof(this))();
104 		return ptrcall!(long)(GDNativeClassBinding.getStart, _godot_object, name);
105 	}
106 	/**
107 	Returns the substring of the match from the source string. Capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.
108 	Returns an empty string if the group did not match or doesn't exist.
109 	*/
110 	String getString(VariantArg0)(in VariantArg0 name = 0) const
111 	{
112 		checkClassBinding!(typeof(this))();
113 		return ptrcall!(String)(GDNativeClassBinding.getString, _godot_object, name);
114 	}
115 	/**
116 	
117 	*/
118 	Array getStrings() const
119 	{
120 		checkClassBinding!(typeof(this))();
121 		return ptrcall!(Array)(GDNativeClassBinding.getStrings, _godot_object);
122 	}
123 	/**
124 	
125 	*/
126 	String getSubject() const
127 	{
128 		checkClassBinding!(typeof(this))();
129 		return ptrcall!(String)(GDNativeClassBinding.getSubject, _godot_object);
130 	}
131 	/**
132 	A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
133 	*/
134 	@property Dictionary names()
135 	{
136 		return getNames();
137 	}
138 	/**
139 	An $(D Array) of the match and its capturing groups.
140 	*/
141 	@property Array strings()
142 	{
143 		return getStrings();
144 	}
145 	/**
146 	The source string used with the search pattern to find this matching result.
147 	*/
148 	@property String subject()
149 	{
150 		return getSubject();
151 	}
152 }