Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AnalyzePattern()

string System.Data.LikeNode.AnalyzePattern ( string pat)
inlinepackage

Definition at line 77 of file LikeNode.cs.

78 {
79 int length = pat.Length;
80 char[] array = new char[length + 1];
81 pat.CopyTo(0, array, 0, length);
82 array[length] = '\0';
83 string text = null;
84 char[] array2 = new char[length + 1];
85 int num = 0;
86 int num2 = 0;
87 int i = 0;
88 while (i < length)
89 {
90 if (array[i] == '*' || array[i] == '%')
91 {
92 for (; (array[i] == '*' || array[i] == '%') && i < length; i++)
93 {
94 }
95 if ((i < length && num > 0) || num2 >= 2)
96 {
97 throw ExprException.InvalidPattern(pat);
98 }
99 num2++;
100 }
101 else if (array[i] == '[')
102 {
103 i++;
104 if (i >= length)
105 {
106 throw ExprException.InvalidPattern(pat);
107 }
108 array2[num++] = array[i++];
109 if (i >= length)
110 {
111 throw ExprException.InvalidPattern(pat);
112 }
113 if (array[i] != ']')
114 {
115 throw ExprException.InvalidPattern(pat);
116 }
117 i++;
118 }
119 else
120 {
121 array2[num++] = array[i];
122 i++;
123 }
124 }
125 text = new string(array2, 0, num);
126 if (num2 == 0)
127 {
128 _kind = 4;
129 }
130 else if (num > 0)
131 {
132 if (array[0] == '*' || array[0] == '%')
133 {
134 if (array[length - 1] == '*' || array[length - 1] == '%')
135 {
136 _kind = 3;
137 }
138 else
139 {
140 _kind = 2;
141 }
142 }
143 else
144 {
145 _kind = 1;
146 }
147 }
148 else
149 {
150 _kind = 5;
151 }
152 return text;
153 }

References System.Data.LikeNode._kind, System.array, System.Data.ExprException.InvalidPattern(), System.length, and System.text.

Referenced by System.Data.LikeNode.Eval().