1 /** 2 Contains the results of a 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.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.reference; 24 /** 25 Contains the results of a regex search. 26 27 Contains the results of a single 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 sub-string for you. 28 */ 29 @GodotBaseClass struct RegExMatch 30 { 31 enum string _GODOT_internal_name = "RegExMatch"; 32 public: 33 @nogc nothrow: 34 union { godot_object _godot_object; Reference _GODOT_base; } 35 alias _GODOT_base this; 36 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 37 package(godot) __gshared bool _classBindingInitialized = false; 38 package(godot) static struct _classBinding 39 { 40 __gshared: 41 @GodotName("get_subject") GodotMethod!(String) getSubject; 42 @GodotName("get_group_count") GodotMethod!(long) getGroupCount; 43 @GodotName("get_names") GodotMethod!(Dictionary) getNames; 44 @GodotName("get_strings") GodotMethod!(Array) getStrings; 45 @GodotName("get_string") GodotMethod!(String, Variant) getString; 46 @GodotName("get_start") GodotMethod!(long, Variant) getStart; 47 @GodotName("get_end") GodotMethod!(long, Variant) getEnd; 48 } 49 bool opEquals(in RegExMatch other) const { return _godot_object.ptr is other._godot_object.ptr; } 50 RegExMatch opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 51 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 52 mixin baseCasts; 53 static RegExMatch _new() 54 { 55 static godot_class_constructor constructor; 56 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("RegExMatch"); 57 if(constructor is null) return typeof(this).init; 58 return cast(RegExMatch)(constructor()); 59 } 60 @disable new(size_t s); 61 /** 62 63 */ 64 String getSubject() const 65 { 66 checkClassBinding!(typeof(this))(); 67 return ptrcall!(String)(_classBinding.getSubject, _godot_object); 68 } 69 /** 70 Returns the number of capturing groups. 71 */ 72 long getGroupCount() const 73 { 74 checkClassBinding!(typeof(this))(); 75 return ptrcall!(long)(_classBinding.getGroupCount, _godot_object); 76 } 77 /** 78 79 */ 80 Dictionary getNames() const 81 { 82 checkClassBinding!(typeof(this))(); 83 return ptrcall!(Dictionary)(_classBinding.getNames, _godot_object); 84 } 85 /** 86 87 */ 88 Array getStrings() const 89 { 90 checkClassBinding!(typeof(this))(); 91 return ptrcall!(Array)(_classBinding.getStrings, _godot_object); 92 } 93 /** 94 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. 95 Returns an empty string if the group did not match or doesn't exist. 96 */ 97 String getString(VariantArg0)(in VariantArg0 name = 0) const 98 { 99 checkClassBinding!(typeof(this))(); 100 return ptrcall!(String)(_classBinding.getString, _godot_object, name); 101 } 102 /** 103 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. 104 Returns -1 if the group did not match or doesn't exist. 105 */ 106 long getStart(VariantArg0)(in VariantArg0 name = 0) const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(long)(_classBinding.getStart, _godot_object, name); 110 } 111 /** 112 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. 113 Returns -1 if the group did not match or doesn't exist. 114 */ 115 long getEnd(VariantArg0)(in VariantArg0 name = 0) const 116 { 117 checkClassBinding!(typeof(this))(); 118 return ptrcall!(long)(_classBinding.getEnd, _godot_object, name); 119 } 120 /** 121 The source string used with the search pattern to find this matching result. 122 */ 123 @property String subject() 124 { 125 return getSubject(); 126 } 127 /** 128 A dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one. 129 */ 130 @property Dictionary names() 131 { 132 return getNames(); 133 } 134 /** 135 An $(D Array) of the match and its capturing groups. 136 */ 137 @property Array strings() 138 { 139 return getStrings(); 140 } 141 }