Changeset 203 for Include/Classes/System/String.ab
- Timestamp:
- Apr 4, 2007, 6:53:48 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/String.ab
r193 r203 16 16 17 17 Class String 18 ' Inherits IComparable, ICloneable, IConvertible, IEnumerable 19 18 20 m_Length As Long 19 21 Public … … 21 23 22 24 Sub String() 23 Chars = _System_malloc(SizeOf (StrChar)) '025 Chars = _System_malloc(SizeOf (StrChar)) 24 26 Chars[0] = 0 25 27 m_Length = 0 … … 129 131 End Function 130 132 131 Const Function Operator + ( ByRefobjString As String) As String133 Const Function Operator + (objString As String) As String 132 134 Return Concat(objString.Chars, objString.m_Length) 133 135 End Function … … 143 145 End Function 144 146 145 Const Function Operator & ( ByRefobjString As String) As String147 Const Function Operator & (objString As String) As String 146 148 Dim tempString = This + objString 147 149 Return tempString 148 150 End Function 149 151 150 Const Function Operator == ( ByRefobjString As String) As Boolean151 Return _System_StrCmp(This.Chars, objString.Chars) = 0152 Const Function Operator == (objString As String) As Boolean 153 Return String.Compare(This, objString) = 0 152 154 End Function 153 155 … … 156 158 End Function 157 159 158 Const Function Operator <> ( ByRefobjString As String) As Boolean159 Return _System_StrCmp(This.Chars, objString.Chars) <> 0160 Const Function Operator <> (objString As String) As Boolean 161 Return String.Compare(This, objString) <> 0 160 162 End Function 161 163 … … 164 166 End Function 165 167 166 Const Function Operator < ( ByRefobjString As String) As Boolean167 Return _System_StrCmp(This.Chars, objString.Chars) < 0168 Const Function Operator < (objString As String) As Boolean 169 Return String.Compare(This, objString) < 0 168 170 End Function 169 171 … … 172 174 End Function 173 175 174 Const Function Operator > ( ByRefobjString As String) As Boolean175 Return _System_StrCmp(This.Chars, objString.Chars) > 0176 Const Function Operator > (objString As String) As Boolean 177 Return String.Compare(This, objString) > 0 176 178 End Function 177 179 … … 180 182 End Function 181 183 182 Const Function Operator <= ( ByRefobjString As String) As Boolean183 Return _System_StrCmp(This.Chars, objString.Chars) <= 0184 Const Function Operator <= (objString As String) As Boolean 185 Return String.Compare(This, objString) <= 0 184 186 End Function 185 187 … … 188 190 End Function 189 191 190 Const Function Operator >= ( ByRefobjString As String) As Boolean191 Return _System_StrCmp(This.Chars, objString.Chars) >= 0192 Const Function Operator >= (objString As String) As Boolean 193 Return String.Compare(This, objString) >= 0 192 194 End Function 193 195 194 196 Const Function Operator >= (text As *StrChar) As Boolean 195 197 Return _System_StrCmp(This.Chars, text) >= 0 198 End Function 199 200 Static Function Compare(x As String, y As String) As Long 201 Return CompareOrdinal(x, y) 202 End Function 203 204 Static Function Compare(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long 205 Return CompareOrdinal(x, indexX, y, indexY, length) 206 End Function 207 208 Static Function CompareOrdinal(x As String, y As String) As Long 209 Return _System_StrCmp(x.Chars, y.Chars) 210 End Function 211 212 Static Function CompareOrdinal(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long 213 If x = Nothing Then 214 If y = Nothing Then 215 Return 0 216 Else 217 Return -1 218 End If 219 ElseIf y = Nothing Then 220 Return 1 221 End If 222 Return _System_StrCmpN(VarPtr(x.Chars[indexX]), VarPtr(y.Chars[indexY]), length) 223 End Function 224 225 Function CompareTo(y As String) As Long 226 Return String.Compare(This, y) 227 End Function 228 229 Function CompareTo(y As Object) As Long 230 Dim s = y As String 231 ' If y is not String Then 232 ' Throw New ArgumentException 233 ' End If 234 Return CompareTo(y) 196 235 End Function 197 236 … … 341 380 #endif 342 381 End Function 343 Const Function Contains(ByRef objString As String) As Boolean 382 383 Static Function Concat(x As String, y As String) As String 384 If x = Nothing Then 385 Return y 386 Else 387 Return x.Concat(objString.Chars, objString.m_Length) 388 End If 389 End Function 390 391 Static Function Concat(x As Object, y As Object) As String 392 Return String.Concat(x.ToString, y.ToString) 393 End Function 394 395 Const Function Contains(objString As String) As Boolean 344 396 Return IndexOf(objString, 0, m_Length) >= 0 345 397 End Function
Note:
See TracChangeset
for help on using the changeset viewer.