1 module gherkin.step; 2 3 import std.array : replace; 4 import std.typecons : Nullable; 5 6 import asdf : serializationIgnore, serializationIgnoreOut, serializationIgnoreOutIf; 7 import gherkin.comment : Comment; 8 import gherkin.datatable : DataTable; 9 import gherkin.docstring : DocString; 10 import gherkin.location : Location; 11 12 /// 13 struct Step 14 { 15 /// 16 string keyword; 17 /// 18 string text; 19 /// 20 Location location; 21 /// 22 @serializationIgnore string uri; 23 /// 24 string id; 25 /// 26 @serializationIgnoreOutIf!`a.isNull` Nullable!DocString docString; 27 /// 28 @serializationIgnoreOutIf!`a.empty` DataTable dataTable; 29 /// 30 @serializationIgnoreOut Comment[] comments; 31 /// 32 @serializationIgnore bool isScenarioOutline; 33 34 /// 35 void replace(string from, string to) 36 { 37 this.text = this.text.replace(from, to); 38 if (!this.dataTable.empty) 39 { 40 this.dataTable.replace(from, to); 41 } 42 if (!this.docString.isNull) 43 { 44 this.docString.get.replace(from, to); 45 } 46 } 47 48 /// 49 this(ref return scope inout Step rhs) inout 50 { 51 foreach (i, ref inout field; rhs.tupleof) 52 { 53 this.tupleof[i] = field; 54 } 55 } 56 57 /// 58 this(ref return scope Step rhs) 59 { 60 foreach (i, ref field; rhs.tupleof) 61 { 62 this.tupleof[i] = field; 63 } 64 } 65 66 /// 67 this(string keyword, string text, Location location, string uri, ref Comment[] comments) 68 { 69 this.keyword = keyword; 70 this.text = text; 71 this.location = location; 72 this.uri = uri; 73 this.comments = comments.dup; 74 comments = []; 75 } 76 }