Changeset 385 for trunk/Include/Classes/System
- Timestamp:
- Nov 20, 2007, 12:04:07 AM (17 years ago)
- Location:
- trunk/Include/Classes/System
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/Text/StringBuilder.ab
r383 r385 120 120 121 121 Function Append(s As String, startIndex As Long, count As Long) As StringBuilder 122 If s = 0 Then 123 If startIndex = 0 And count = 0 Then 124 Return This 125 Else 126 'Throw ArgumentNullException 127 End If 128 End If 129 StringBuilder.rangeCheck2(s.Length, startIndex, count) 130 appendCore(s, startIndex, count) 131 Return This 122 Return Append(StrPtr(s), startIndex, count) 132 123 End Function 133 124 … … 137 128 Return This 138 129 Else 139 'Throw ArgumentNullException130 Throw New ArgumentNullException("StringBuilder.Append: An argument was null", "s") 140 131 End If 141 132 ElseIf startIndex < 0 Or count < 0 Then 142 'Throw ArgumentOutOfRangeException133 Throw New ArgumentOutOfRangeException("StringBuilder.Append: One or more arguments have out of range value.", "startIndex or count or both") 143 134 End If 144 135 appendCore(s, startIndex, count) … … 178 169 Const Sub CopyTo(sourceIndex As Long, ByRef dest[] As StrChar, destIndex As Long, count As Long) 179 170 If dest = 0 Then 180 'Throw ArgumentNullException171 Throw New ArgumentNullException("StringBuilder.CopyTo: An argument was null", "sourceIndex") 181 172 ElseIf size < sourceIndex + count Or sourceIndex < 0 Or destIndex < 0 Or count < 0 Then 182 'Throw ArgumentOutOfRangeException173 Throw New ArgumentOutOfRangeException("StringBuilder.CopyTo: One or more arguments have out of range value.", "startIndex or count or both") 183 174 End If 184 175 … … 188 179 Function EnsureCapacity(c As Long) As Long 189 180 If c < 0 Or c > MaxCapacity Then 190 'Throw ArgumentOutOfRangeException181 Throw New ArgumentOutOfRangeException("StringBuilder.Append: An argument was out of range value.", "c") 191 182 ElseIf c > Capacity Then 192 183 Dim p = GC_malloc_atomic((c + 1) * SizeOf (StrChar)) As *StrChar … … 300 291 rangeCheck(index) 301 292 If n < 0 Then 302 'Throw New ArgumentOutOfRangeException 303 Debug 293 Throw New ArgumentOutOfRangeException("StringBuilder.Insert: An argument was out of range value.", "n") 304 294 End If 305 295 Dim len = x.Length … … 308 298 EnsureCapacity(newSize) 309 299 separateBuffer() 310 311 ' TODO: fix me!(定義されていない変数iが使われています)312 'ActiveBasic.Strings.ChrMove(VarPtr(chars[i + lenTotal]), VarPtr(chars[i]), (size - index) As SIZE_T)313 300 314 301 Dim i As Long … … 320 307 End Function 321 308 322 323 309 Function Insert(i As Long, x As *StrChar, index As Long, count As Long) As StringBuilder 324 310 rangeCheck(i) 325 311 If x = 0 Then 326 'Throw New ArgumentNullException 327 Debug 312 Throw New ArgumentNullException("StringBuilder.Insert: An argument was null", "x") 328 313 ElseIf index < 0 Or count < 0 Then 329 'Throw New ArgumentNullException 330 Debug 314 Throw New ArgumentOutOfRangeException("StringBuilder.Append: One or more arguments have out of range value.", "index or count or both") 331 315 End If 332 316 … … 396 380 397 381 Sub replaceCore(oldStr As String, newStr As String, start As Long, count As Long) 398 If Object.ReferenceEquals(oldStr, Nothing) Then 399 'Throw ArgumentNullException 400 Debug 382 If ActiveBasic.IsNothing(oldStr) Then 383 Throw New ArgumentNullException("StringBuilder.Replace: An argument was null", "oldStr") 401 384 ElseIf oldStr.Length = 0 Then 402 'Throw ArgumentException 403 Debug 385 Throw New ArgumentException("StringBuilder.Replace: The argument 'oldStr' is empty string. ", "oldStr") 404 386 End If 405 387 … … 412 394 End If 413 395 414 s.appendCore(chars, curPos, nextPos )396 s.appendCore(chars, curPos, nextPos As Long) 415 397 s.Append(newStr) 416 curPos += nextPos + oldStr.Length398 curPos += nextPos As Long + oldStr.Length 417 399 Loop 418 400 chars = s.chars … … 446 428 Sub Capacity(c As Long) 447 429 If c < size Or c > MaxCapacity Then 'sizeとの比較でcが負の場合も対応 448 'Throw ArgumentOutOfRangeException430 Throw New ArgumentOutOfRangeException("StringBuilder.Append: An argument have out of range value.", "c") 449 431 End If 450 432 EnsureCapacity(c) … … 453 435 Const Function Chars(i As Long) As StrChar 454 436 If i >= Length Or i < 0 Then 455 'Throw IndexOutOfRangeException 456 Debug 437 Throw New IndexOutOfRangeException("StringBuilder.Chars: The index argument 'i' have out of range value.") 457 438 End If 458 439 Return chars[i] … … 461 442 Sub Chars(i As Long, c As StrChar) 462 443 If i >= Length Or i < 0 Then 463 'Throw ArgumentOutOfRangeException 464 Debug 444 Throw New ArgumentOutOfRangeException("StringBuilder.Chars: An argument have out of range value.", "i") 465 445 End If 466 446 chars[i] = c … … 494 474 Sub initialize(capacity As Long, maxCapacity = LONG_MAX As Long) 495 475 If capacity < 0 Or maxCapacity < 1 Or maxCapacity < capacity Then 496 'Throw ArgumentOutOfRangeException476 Throw New ArgumentOutOfRangeException("StringBuilder constructor: One or more arguments have out of range value.", "capacity or maxCapacity or both") 497 477 End If 498 478 … … 526 506 Sub rangeCheck(index As Long) 527 507 If index < 0 Or index > size Then 528 'Throw ArgumentOutOfRangeException 529 Debug 508 Throw New ArgumentOutOfRangeException("StringBuilder: Index argument has out of range value.") 530 509 End If 531 510 End Sub … … 538 517 'length < 0は判定に入っていないことに注意 539 518 If startIndex < 0 Or count < 0 Or startIndex + count > length Then 540 'Throw ArgumentOutOfRangeException 541 Debug 519 Throw New ArgumentOutOfRangeException("StringBuilder: One or more arguments have out of range value.", "startIndex or count or both") 542 520 End If 543 521 End Sub
Note:
See TracChangeset
for help on using the changeset viewer.