Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringInfo.cs
Go to the documentation of this file.
4
6
7public class StringInfo
8{
9 private string _str;
10
11 private int[] _indexes;
12
13 private int[]? Indexes
14 {
15 get
16 {
17 if (_indexes == null && String.Length > 0)
18 {
20 }
21 return _indexes;
22 }
23 }
24
25 public string String
26 {
27 get
28 {
29 return _str;
30 }
31 [MemberNotNull("_str")]
32 set
33 {
34 _str = value ?? throw new ArgumentNullException("value");
35 _indexes = null;
36 }
37 }
38
40 {
41 get
42 {
43 int[]? indexes = Indexes;
44 if (indexes == null)
45 {
46 return 0;
47 }
48 return indexes.Length;
49 }
50 }
51
52 public StringInfo()
54 {
55 }
56
57 public StringInfo(string value)
58 {
59 String = value;
60 }
61
62 public override bool Equals([NotNullWhen(true)] object? value)
63 {
65 {
66 return _str.Equals(stringInfo._str);
67 }
68 return false;
69 }
70
71 public override int GetHashCode()
72 {
73 return _str.GetHashCode();
74 }
75
77 {
78 int[]? indexes = Indexes;
80 }
81
83 {
84 int[] array = Indexes ?? Array.Empty<int>();
85 if ((uint)startingTextElement >= (uint)array.Length)
86 {
88 }
89 if ((uint)lengthInTextElements > (uint)(array.Length - startingTextElement))
90 {
92 }
93 int num = array[startingTextElement];
94 Index end = ^0;
95 if ((uint)(startingTextElement + lengthInTextElements) < (uint)array.Length)
96 {
98 }
99 return String[num..end];
100 }
101
102 public static string GetNextTextElement(string str)
103 {
104 return GetNextTextElement(str, 0);
105 }
106
107 public static string GetNextTextElement(string str, int index)
108 {
110 return str.Substring(index, nextTextElementLength);
111 }
112
113 public static int GetNextTextElementLength(string str)
114 {
115 return GetNextTextElementLength(str, 0);
116 }
117
118 public static int GetNextTextElementLength(string str, int index)
119 {
120 if (str == null)
121 {
123 }
124 if ((uint)index > (uint)str.Length)
125 {
127 }
128 return GetNextTextElementLength(str.AsSpan(index));
129 }
130
135
137 {
138 return GetTextElementEnumerator(str, 0);
139 }
140
142 {
143 if (str == null)
144 {
146 }
147 if ((uint)index > (uint)str.Length)
148 {
150 }
151 return new TextElementEnumerator(str, index);
152 }
153
154 public static int[] ParseCombiningCharacters(string str)
155 {
156 if (str == null)
157 {
159 }
163 while (!str2.IsEmpty)
164 {
165 valueListBuilder.Append(str.Length - str2.Length);
167 }
168 int[] result = valueListBuilder.AsSpan().ToArray();
169 valueListBuilder.Dispose();
170 return result;
171 }
172}
string SubstringByTextElements(int startingTextElement, int lengthInTextElements)
Definition StringInfo.cs:82
static int GetNextTextElementLength(ReadOnlySpan< char > str)
static int GetNextTextElementLength(string str, int index)
static string GetNextTextElement(string str, int index)
static TextElementEnumerator GetTextElementEnumerator(string str)
static int GetNextTextElementLength(string str)
static string GetNextTextElement(string str)
override bool Equals([NotNullWhen(true)] object? value)
Definition StringInfo.cs:62
static TextElementEnumerator GetTextElementEnumerator(string str, int index)
static int[] ParseCombiningCharacters(string str)
string SubstringByTextElements(int startingTextElement)
Definition StringInfo.cs:76
static string Arg_ArgumentOutOfRangeException
Definition SR.cs:68
Definition SR.cs:7
static int GetLengthOfFirstUtf16ExtendedGraphemeCluster(ReadOnlySpan< char > input)
static void ThrowArgumentOutOfRange_IndexException()
static void ThrowArgumentNullException(string name)