| 1 | ' Classes/System/String.ab
|
|---|
| 2 |
|
|---|
| 3 | #require <basic/function.sbp>
|
|---|
| 4 |
|
|---|
| 5 | Class String
|
|---|
| 6 | m_Length As Long
|
|---|
| 7 | Public
|
|---|
| 8 | Chars As *Char
|
|---|
| 9 |
|
|---|
| 10 | Sub String()
|
|---|
| 11 | Chars = _System_calloc(SizeOf (Char) * 1)
|
|---|
| 12 | m_Length = 0
|
|---|
| 13 | End Sub
|
|---|
| 14 |
|
|---|
| 15 | Sub String(initStr As *Char)
|
|---|
| 16 | String()
|
|---|
| 17 | Assign(initStr)
|
|---|
| 18 | End Sub
|
|---|
| 19 |
|
|---|
| 20 | Sub String(initStr As *Char, length As Long)
|
|---|
| 21 | String()
|
|---|
| 22 | Assign(initStr, length)
|
|---|
| 23 | End Sub
|
|---|
| 24 |
|
|---|
| 25 | Sub String(ByRef initStr As String)
|
|---|
| 26 | String()
|
|---|
| 27 | Assign(initStr)
|
|---|
| 28 | End Sub
|
|---|
| 29 |
|
|---|
| 30 | Sub String(length As Long)
|
|---|
| 31 | String()
|
|---|
| 32 | ReSize(length)
|
|---|
| 33 | End Sub
|
|---|
| 34 |
|
|---|
| 35 | Sub String(initChar As Char, length As Long)
|
|---|
| 36 | ReSize(length, initChar)
|
|---|
| 37 | End Sub
|
|---|
| 38 |
|
|---|
| 39 | Sub ~String()
|
|---|
| 40 | _System_free(Chars)
|
|---|
| 41 | Chars = 0
|
|---|
| 42 | #ifdef _DEBUG
|
|---|
| 43 | m_Length = 0
|
|---|
| 44 | #endif
|
|---|
| 45 | End Sub
|
|---|
| 46 |
|
|---|
| 47 | Const Function Length() As Long
|
|---|
| 48 | Return m_Length
|
|---|
| 49 | End Function
|
|---|
| 50 |
|
|---|
| 51 | Function Operator() As *Char
|
|---|
| 52 | Return Chars
|
|---|
| 53 | End Function
|
|---|
| 54 |
|
|---|
| 55 | Sub Operator = (ByRef objString As String)
|
|---|
| 56 | Assign(objString.Chars, objString.m_Length)
|
|---|
| 57 | End Sub
|
|---|
| 58 |
|
|---|
| 59 | Sub Operator = (text As *Char)
|
|---|
| 60 | Assign(text)
|
|---|
| 61 | End Sub
|
|---|
| 62 |
|
|---|
| 63 | Const Function Operator [] (n As Long) As Char
|
|---|
| 64 | Return Chars[n]
|
|---|
| 65 | End Function
|
|---|
| 66 |
|
|---|
| 67 | Sub Operator []= (n As Long, c As Char)
|
|---|
| 68 | Chars[n] = c
|
|---|
| 69 | End Sub
|
|---|
| 70 |
|
|---|
| 71 | Const Function Operator + (pszText As *Char) As String
|
|---|
| 72 | Return Concat(pszText, lstrlen(pszText))
|
|---|
| 73 | End Function
|
|---|
| 74 |
|
|---|
| 75 | Const Function Operator + (ByRef objString As String) As String
|
|---|
| 76 | Return Concat(objString, objString.m_Length)
|
|---|
| 77 | End Function
|
|---|
| 78 |
|
|---|
| 79 | Const Function Operator & (pszText As *Char) As String
|
|---|
| 80 | Dim tempString = This + pszText
|
|---|
| 81 | Return tempString
|
|---|
| 82 | End Function
|
|---|
| 83 |
|
|---|
| 84 | Const Function Operator & (ByRef objString As String) As String
|
|---|
| 85 | Dim tempString = This + objString
|
|---|
| 86 | Return tempString
|
|---|
| 87 | End Function
|
|---|
| 88 |
|
|---|
| 89 | Const Function Operator == (ByRef objString As String) As Boolean
|
|---|
| 90 | Return _System_StrCmp(This, objString) = 0
|
|---|
| 91 | End Function
|
|---|
| 92 |
|
|---|
| 93 | Const Function Operator == (text As *Char) As Long
|
|---|
| 94 | Return _System_StrCmp(This, text) = 0
|
|---|
| 95 | End Function
|
|---|
| 96 |
|
|---|
| 97 | Const Function Operator <> (ByRef objString As String) As Boolean
|
|---|
| 98 | Return _System_StrCmp(This, objString)
|
|---|
| 99 | End Function
|
|---|
| 100 |
|
|---|
| 101 | Const Function Operator <> (text As *Char) As Boolean
|
|---|
| 102 | Return _System_StrCmp(This, text)
|
|---|
| 103 | End Function
|
|---|
| 104 |
|
|---|
| 105 | Const Function Operator < (ByRef objString As String) As Boolean
|
|---|
| 106 | Return _System_StrCmp(This, objString) < 0
|
|---|
| 107 | End Function
|
|---|
| 108 |
|
|---|
| 109 | Const Function Operator < (text As *Char) As Boolean
|
|---|
| 110 | Return _System_StrCmp(This, text) < 0
|
|---|
| 111 | End Function
|
|---|
| 112 |
|
|---|
| 113 | Const Function Operator > (ByRef objString As String) As Boolean
|
|---|
| 114 | Return _System_StrCmp(This, objString) > 0
|
|---|
| 115 | End Function
|
|---|
| 116 |
|
|---|
| 117 | Const Function Operator > (text As *Char) As Boolean
|
|---|
| 118 | Return _System_StrCmp(This, text) > 0
|
|---|
| 119 | End Function
|
|---|
| 120 |
|
|---|
| 121 | Const Function Operator <= (ByRef objString As String) As Boolean
|
|---|
| 122 | Return _System_StrCmp(This, objString) <= 0
|
|---|
| 123 | End Function
|
|---|
| 124 |
|
|---|
| 125 | Const Function Operator <= (text As *Char) As Boolean
|
|---|
| 126 | Return _System_StrCmp(This, text) <= 0
|
|---|
| 127 | End Function
|
|---|
| 128 |
|
|---|
| 129 | Const Function Operator >= (ByRef objString As String) As Boolean
|
|---|
| 130 | Return _System_StrCmp(This, objString) => 0
|
|---|
| 131 | End Function
|
|---|
| 132 |
|
|---|
| 133 | Const Function Operator >= (text As *Char) As Boolean
|
|---|
| 134 | Return _System_StrCmp(This, text) => 0
|
|---|
| 135 | End Function
|
|---|
| 136 |
|
|---|
| 137 | Const Function StrPtr() As *Char
|
|---|
| 138 | Return Chars
|
|---|
| 139 | End Function
|
|---|
| 140 |
|
|---|
| 141 | Sub ReSize(allocLength As Long)
|
|---|
| 142 | If allocLength < 0 Then Exit Sub
|
|---|
| 143 | If allocLength > m_Length Then
|
|---|
| 144 | Dim oldLength As Long
|
|---|
| 145 | oldLength = m_Length
|
|---|
| 146 | If AllocStringBuffer(allocLength) <> 0 Then
|
|---|
| 147 | ZeroMemory(VarPtr(Chars[oldLength]), SizeOf (Char) * (m_Length - oldLength + 1))
|
|---|
| 148 | End If
|
|---|
| 149 | Else
|
|---|
| 150 | m_Length = allocLength
|
|---|
| 151 | Chars[m_Length] = 0
|
|---|
| 152 | End If
|
|---|
| 153 | End Sub
|
|---|
| 154 |
|
|---|
| 155 | Sub ReSize(allocLength As Long, c As Char)
|
|---|
| 156 | If allocLength < 0 Then
|
|---|
| 157 | Exit Sub
|
|---|
| 158 | ElseIf allocLength > m_Length Then
|
|---|
| 159 | Dim oldLength As Long
|
|---|
| 160 | oldLength = m_Length
|
|---|
| 161 | If AllocStringBuffer(allocLength) <> 0 Then
|
|---|
| 162 | Dim p = VarPtr(Chars[oldLength]) As *Char
|
|---|
| 163 | Dim fillLen = m_Length - oldLength
|
|---|
| 164 | Dim i As Long
|
|---|
| 165 | For i = 0 To ELM(fillLen)
|
|---|
| 166 | p[i] = c
|
|---|
| 167 | Next
|
|---|
| 168 | End If
|
|---|
| 169 | Else
|
|---|
| 170 | m_Length = allocLength
|
|---|
| 171 | End If
|
|---|
| 172 | Chars[m_Length] = 0
|
|---|
| 173 | End Sub
|
|---|
| 174 |
|
|---|
| 175 | Sub Assign(text As *Char, textLength As Long)
|
|---|
| 176 | If text = Chars Then Exit Sub
|
|---|
| 177 | If AllocStringBuffer(textLength) <> 0 Then
|
|---|
| 178 | memcpy(Chars, text, SizeOf (Char) * textLength)
|
|---|
| 179 | Chars[m_Length] = 0
|
|---|
| 180 | End If
|
|---|
| 181 | End Sub
|
|---|
| 182 |
|
|---|
| 183 | Sub Assign(ByRef objString As String)
|
|---|
| 184 | Assign(objString.Chars, objString.m_Length)
|
|---|
| 185 | End Sub
|
|---|
| 186 |
|
|---|
| 187 | Sub Assign(text As *Char)
|
|---|
| 188 | If text Then
|
|---|
| 189 | Assign(text, lstrlen(text))
|
|---|
| 190 | Else
|
|---|
| 191 | 'Chars=_System_realloc(Chars,1)
|
|---|
| 192 | Chars[0] = 0
|
|---|
| 193 | m_Length = 0
|
|---|
| 194 | End If
|
|---|
| 195 | End Sub
|
|---|
| 196 |
|
|---|
| 197 | Sub Append(text As *Char, textLength As Long)
|
|---|
| 198 | Dim prevLen As Long
|
|---|
| 199 | prevLen = m_Length
|
|---|
| 200 | If AllocStringBuffer(m_Length + textLength) <> 0 Then
|
|---|
| 201 | memcpy(VarPtr(Chars[prevLen]), text, SizeOf (Char) * textLength)
|
|---|
| 202 | Chars[m_Length] = 0
|
|---|
| 203 | End If
|
|---|
| 204 | End Sub
|
|---|
| 205 |
|
|---|
| 206 | Sub Append(text As *Char)
|
|---|
| 207 | Append(text, lstrlen(text))
|
|---|
| 208 | End Sub
|
|---|
| 209 |
|
|---|
| 210 | Sub Append(ByRef str As String)
|
|---|
| 211 | Append(str.Chars, str.m_Length)
|
|---|
| 212 | End Sub
|
|---|
| 213 |
|
|---|
| 214 | Const Function Clone() As String
|
|---|
| 215 | Return This
|
|---|
| 216 | End Function
|
|---|
| 217 |
|
|---|
| 218 | Const Function Concat(lpszText As *Char, textLength As Long) As String
|
|---|
| 219 | Dim tempString As String
|
|---|
| 220 | With tempString
|
|---|
| 221 | .AllocStringBuffer(This.m_Length + textLength)
|
|---|
| 222 | memcpy(.Chars, This.Chars, SizeOf (Char) * This.m_Length)
|
|---|
| 223 | memcpy(VarPtr(.Chars[This.m_Length]), lpszText, SizeOf (Char) * textLength)
|
|---|
| 224 | .Chars[.m_Length] = 0
|
|---|
| 225 | End With
|
|---|
| 226 | Return tempString
|
|---|
| 227 | End Function
|
|---|
| 228 |
|
|---|
| 229 | Const Function Contains(ByRef objString As String) As Boolean
|
|---|
| 230 | Return IndexOf(objString, 0, m_Length) >= 0
|
|---|
| 231 | End Function
|
|---|
| 232 |
|
|---|
| 233 | Const Function Contains(lpszText As *Char) As Boolean
|
|---|
| 234 | Return IndexOf(lpszText, 0, m_Length) >= 0
|
|---|
| 235 | End Function
|
|---|
| 236 |
|
|---|
| 237 | Const Function IndexOf(lpszText As *Char) As Long
|
|---|
| 238 | Return IndexOf(lpszText, 0, m_Length)
|
|---|
| 239 | End Function
|
|---|
| 240 |
|
|---|
| 241 | Const Function IndexOf(lpszText As *Char, startIndex As Long) As Long
|
|---|
| 242 | Return IndexOf(lpszText, startIndex, m_Length - startIndex)
|
|---|
| 243 | End Function
|
|---|
| 244 |
|
|---|
| 245 | Const Function IndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long
|
|---|
| 246 | Dim length = lstrlen(lpszText)
|
|---|
| 247 |
|
|---|
| 248 | If startIndex < 0 Then Return -1
|
|---|
| 249 | If count < 1 Or count + startIndex > m_Length Then Return -1
|
|---|
| 250 | If length > m_Length Then Return -1
|
|---|
| 251 |
|
|---|
| 252 | If length = 0 Then Return startIndex
|
|---|
| 253 |
|
|---|
| 254 | Dim i As Long, j As Long
|
|---|
| 255 | For i = startIndex To startIndex + count - 1
|
|---|
| 256 | For j = 0 To length - 1
|
|---|
| 257 | If Chars[i + j] = lpszText[j] Then
|
|---|
| 258 | If j = length - 1 Then Return i
|
|---|
| 259 | Else
|
|---|
| 260 | Exit For
|
|---|
| 261 | End If
|
|---|
| 262 | Next
|
|---|
| 263 | Next
|
|---|
| 264 | Return -1
|
|---|
| 265 | End Function
|
|---|
| 266 |
|
|---|
| 267 | Const Function LastIndexOf(lpszText As *Char) As Long
|
|---|
| 268 | Return LastIndexOf(lpszText, m_Length - 1, m_Length)
|
|---|
| 269 | End Function
|
|---|
| 270 |
|
|---|
| 271 | Const Function LastIndexOf(lpszText As *Char, startIndex As Long) As Long
|
|---|
| 272 | Return LastIndexOf(lpszText As *Char, startIndex, startIndex + 1)
|
|---|
| 273 | End Function
|
|---|
| 274 |
|
|---|
| 275 | Const Function LastIndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long
|
|---|
| 276 | Dim length = lstrlen(lpszText)
|
|---|
| 277 |
|
|---|
| 278 | If startIndex < 0 Or startIndex > m_Length - 1 Then Return -1
|
|---|
| 279 | If count < 1 Or count > startIndex + 2 Then Return -1
|
|---|
| 280 | If length > m_Length Then Return -1
|
|---|
| 281 |
|
|---|
| 282 | If length = 0 Then Return startIndex
|
|---|
| 283 |
|
|---|
| 284 | Dim i As Long, j As Long
|
|---|
| 285 | For i = startIndex To startIndex - count + 1 Step -1
|
|---|
| 286 | For j = length - 1 To 0 Step -1
|
|---|
| 287 | If Chars[i + j] = lpszText[j] Then
|
|---|
| 288 | If j = 0 Then Return i
|
|---|
| 289 | Else
|
|---|
| 290 | Exit For
|
|---|
| 291 | End If
|
|---|
| 292 | Next
|
|---|
| 293 | Next
|
|---|
| 294 | Return -1
|
|---|
| 295 | End Function
|
|---|
| 296 |
|
|---|
| 297 | Const Function StartsWith(lpszText As *Char) As Boolean
|
|---|
| 298 | Return IndexOf(lpszText) = 0
|
|---|
| 299 | End Function
|
|---|
| 300 |
|
|---|
| 301 | Const Function EndsWith(lpszText As *Char) As Boolean
|
|---|
| 302 | Return LastIndexOf(lpszText) = m_Length - lstrlen(lpszText)
|
|---|
| 303 | End Function
|
|---|
| 304 |
|
|---|
| 305 | Const Function Insert(startIndex As Long, text As String) As String
|
|---|
| 306 | Return Insert(startIndex, text.Chars, text.Length)
|
|---|
| 307 | End Function
|
|---|
| 308 |
|
|---|
| 309 | Const Function Insert(startIndex As Long, text As *Char) As String
|
|---|
| 310 | Return Insert(startIndex, text, lstrlen(text))
|
|---|
| 311 | End Function
|
|---|
| 312 |
|
|---|
| 313 | Const Function Insert(startIndex As Long, text As *Char, length As Long) As String
|
|---|
| 314 | If startIndex < 0 Or startIndex > m_Length Or length < 0 Then
|
|---|
| 315 | Debug 'ArgumentOutOfRangeException
|
|---|
| 316 |
|
|---|
| 317 | End If
|
|---|
| 318 | Insert.ReSize(m_Length + length)
|
|---|
| 319 | memcpy(Insert.Chars, Chars, SizeOf (Char) * startIndex)
|
|---|
| 320 | memcpy(VarPtr(Insert.Chars[startIndex]), text, SizeOf (Char) * length)
|
|---|
| 321 | memcpy(VarPtr(Insert.Chars[startIndex + length]), VarPtr(Chars[startIndex]), SizeOf (Char) * (m_Length - startIndex + 1))
|
|---|
| 322 | End Function
|
|---|
| 323 |
|
|---|
| 324 | Const Function SubString(startIndex As Long) As String
|
|---|
| 325 | Return SubString(startIndex, m_Length - startIndex)
|
|---|
| 326 | End Function
|
|---|
| 327 |
|
|---|
| 328 | Const Function SubString(startIndex As Long, length As Long) As String
|
|---|
| 329 | If startIndex < 0 Or length <= 0 Then Return ""
|
|---|
| 330 | If startIndex + length > m_Length Then Return ""
|
|---|
| 331 |
|
|---|
| 332 | Dim temp As String
|
|---|
| 333 | temp.AllocStringBuffer(length)
|
|---|
| 334 | memcpy(temp.Chars, VarPtr(Chars[startIndex]), SizeOf (Char) * length)
|
|---|
| 335 | Chars[m_Length] = 0
|
|---|
| 336 | Return temp
|
|---|
| 337 | End Function
|
|---|
| 338 |
|
|---|
| 339 | Const Function Remove(startIndex As Long) As String
|
|---|
| 340 | Remove.ReSize(startIndex)
|
|---|
| 341 | memcpy(Remove.Chars, This.Chars, SizeOf (Char) * startIndex)
|
|---|
| 342 | End Function
|
|---|
| 343 |
|
|---|
| 344 | Const Function Remove(startIndex As Long, count As Long) As String
|
|---|
| 345 | Remove.ReSize(m_Length - count)
|
|---|
| 346 | memcpy(Remove.Chars, This.Chars, SizeOf (Char) * startIndex)
|
|---|
| 347 | memcpy(VarPtr(Remove.Chars[startIndex]), VarPtr(This.Chars[startIndex + count]), SizeOf (Char) * startIndex)
|
|---|
| 348 | End Function
|
|---|
| 349 | /*
|
|---|
| 350 | Static Function IsNullOrEmpty(s As String) As Boolean
|
|---|
| 351 | If s <> Nothing Then
|
|---|
| 352 | If s.m_Length > 0 Then
|
|---|
| 353 | Return True
|
|---|
| 354 | End If
|
|---|
| 355 | End If
|
|---|
| 356 | Return False
|
|---|
| 357 | End Function
|
|---|
| 358 | */
|
|---|
| 359 | Const Function Replace(oldChar As Char, newChar As Char) As String
|
|---|
| 360 | Replace = Copy(This)
|
|---|
| 361 | With Replace
|
|---|
| 362 | Dim i As Long
|
|---|
| 363 | For i = 0 To ELM(.m_Length)
|
|---|
| 364 | If .Chars[i] = .oldChar Then
|
|---|
| 365 | .Chars[i] = .newChar
|
|---|
| 366 | End If
|
|---|
| 367 | Next
|
|---|
| 368 | End With
|
|---|
| 369 | End Function
|
|---|
| 370 |
|
|---|
| 371 | Const Function Replace(ByRef oldStr As String, ByRef newStr As String) As String
|
|---|
| 372 | ' If oldStr = Nothing Then Throw ArgumentNullException
|
|---|
| 373 | '
|
|---|
| 374 | ' If newStr = Nothing Then
|
|---|
| 375 | ' Return ReplaceCore(oldStr, oldStr.m_Length, "", 0)
|
|---|
| 376 | ' Else
|
|---|
| 377 | Return ReplaceCore(oldStr, oldStr.m_Length, newStr, newStr.m_Length)
|
|---|
| 378 | ' End If
|
|---|
| 379 | End Function
|
|---|
| 380 |
|
|---|
| 381 | Const Function Replace(oldStr As *Char, newStr As *Char)
|
|---|
| 382 | If oldStr = 0 Then Debug 'Throw ArgumentNullException
|
|---|
| 383 | If newStr = 0 Then newStr = ""
|
|---|
| 384 | Return ReplaceCore(oldStr, lstrlen(oldStr), newStr, lstrlen(newStr)) As String
|
|---|
| 385 | End Function
|
|---|
| 386 |
|
|---|
| 387 | Const Function Replace(oldStr As *Char, oldLen As Long, newStr As *Char, newLen As Long) As String
|
|---|
| 388 | If oldStr = 0 Then Debug 'Throw ArgumentNullException
|
|---|
| 389 | If newStr = 0 Then
|
|---|
| 390 | newStr = ""
|
|---|
| 391 | newLen = 0
|
|---|
| 392 | End If
|
|---|
| 393 | Return ReplaceCore(oldStr, oldLen, newStr, newLen)
|
|---|
| 394 | End Function
|
|---|
| 395 |
|
|---|
| 396 | Sub ToLower()
|
|---|
| 397 | Dim i As Long
|
|---|
| 398 | For i = 0 To m_Length
|
|---|
| 399 | Chars[i] = _System_ASCII_ToLower(Chars[i])
|
|---|
| 400 | Next
|
|---|
| 401 | End Sub
|
|---|
| 402 |
|
|---|
| 403 | Sub ToUpper()
|
|---|
| 404 | Dim i As Long
|
|---|
| 405 | For i = 0 To m_Length
|
|---|
| 406 | Chars[i] = _System_ASCII_ToUpper(Chars[i])
|
|---|
| 407 | Next
|
|---|
| 408 | End Sub
|
|---|
| 409 |
|
|---|
| 410 | Sub Swap(ByRef x As String)
|
|---|
| 411 | Dim tempLen As Long
|
|---|
| 412 | Dim tempChars As *Char
|
|---|
| 413 | tempLen = x.m_Length
|
|---|
| 414 | tempChars = x.Chars
|
|---|
| 415 | x.m_Length = This.m_Length
|
|---|
| 416 | x.Chars = This.Chars
|
|---|
| 417 | This.m_Length = tempLen
|
|---|
| 418 | This.Chars = tempChars
|
|---|
| 419 | End Sub
|
|---|
| 420 |
|
|---|
| 421 | Override Function ToString() As String
|
|---|
| 422 | Return This
|
|---|
| 423 | End Function
|
|---|
| 424 |
|
|---|
| 425 | Static Function Copy(s As String) As String
|
|---|
| 426 | Copy.Resize(s.m_Length)
|
|---|
| 427 | memcpy(Copy.Chars, This.Chars, SizeOf (Char) * m_Length)
|
|---|
| 428 | End Function
|
|---|
| 429 |
|
|---|
| 430 | Private
|
|---|
| 431 | ' メモリ確保に失敗すると元の文字列は失われない。(例外安全でいう強い保障)
|
|---|
| 432 | Function AllocStringBuffer(textLength As Long) As *Char
|
|---|
| 433 | If textLength < 0 Then
|
|---|
| 434 | Return 0
|
|---|
| 435 | ElseIf textLength > m_Length Then
|
|---|
| 436 | AllocStringBuffer = _System_realloc(Chars, SizeOf(Char) * (textLength + 1))
|
|---|
| 437 | If AllocStringBuffer <> 0 Then
|
|---|
| 438 | m_Length = textLength
|
|---|
| 439 | Chars = AllocStringBuffer
|
|---|
| 440 | End If
|
|---|
| 441 | Else
|
|---|
| 442 | m_Length = textLength
|
|---|
| 443 | AllocStringBuffer = Chars
|
|---|
| 444 | End If
|
|---|
| 445 | End Function
|
|---|
| 446 |
|
|---|
| 447 | Function ReplaceCore(oldStr As *Char, oldLen As Long, newStr As *Char, newLen As Long) As String
|
|---|
| 448 | If oldLen = 0 Then
|
|---|
| 449 | Debug 'Throw ArgumentException
|
|---|
| 450 | End If
|
|---|
| 451 | Dim tmp As String
|
|---|
| 452 | With tmp
|
|---|
| 453 | Dim current = 0 As Long
|
|---|
| 454 | Do
|
|---|
| 455 | Dim pos = IndexOf(oldStr, current)
|
|---|
| 456 | If pos = -1 Then
|
|---|
| 457 | Exit Do
|
|---|
| 458 | End If
|
|---|
| 459 | .Append(VarPtr(Chars[current]), pos - current)
|
|---|
| 460 | .Append(newStr, newLen)
|
|---|
| 461 | current = pos + oldLen
|
|---|
| 462 | Loop
|
|---|
| 463 | .Append(VarPtr(Chars[current]), m_Length - current)
|
|---|
| 464 | End With
|
|---|
| 465 | Return tmp
|
|---|
| 466 | End Function
|
|---|
| 467 |
|
|---|
| 468 | End Class
|
|---|
| 469 |
|
|---|