Changeset 468 for trunk/Include/Classes/System/Text
- Timestamp:
- Mar 9, 2008, 12:00:01 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/Text/StringBuilder.ab
r457 r468 40 40 End Function 41 41 42 Function Append(x As StrChar) As StringBuilder42 Function Append(x As Char) As StringBuilder 43 43 EnsureCapacity(size + 1) 44 44 separateBuffer() … … 47 47 Return This 48 48 End Function 49 50 #ifdef __STRING_IS_NOT_UNICODE 49 #ifdef UNICODE 50 Function Append(x As SByte) As StringBuilder 51 ActiveBasic.Strings.Detail.FormatIntegerD(This, x, DWORD_MAX, 0, 0) 52 Return This 53 End Function 54 #endif 55 Function Append(x As Byte) As StringBuilder 56 ActiveBasic.Strings.Detail.FormatIntegerU(This, x, DWORD_MAX, 0, 0) 57 Return This 58 End Function 59 60 Function Append(x As Integer) As StringBuilder 61 ActiveBasic.Strings.Detail.FormatIntegerD(This, x, DWORD_MAX, 0, 0) 62 Return This 63 End Function 64 #ifndef UNICODE 51 65 Function Append(x As Word) As StringBuilder 52 Append(Str$(x As DWord)) 53 Return This 54 End Function 55 #else 56 Function Append(x As SByte) As StringBuilder 57 Append(Str$(x As Long)) 66 ActiveBasic.Strings.Detail.FormatIntegerU(This, x, DWORD_MAX, 0, 0) 58 67 Return This 59 68 End Function 60 69 #endif 61 62 Function Append(x As Byte) As StringBuilder63 Append(Str$(x As DWord))64 Return This65 End Function66 67 Function Append(x As Integer) As StringBuilder68 Append(Str$(x As Long))69 Return This70 End Function71 72 70 Function Append(x As Long) As StringBuilder 73 A ppend(Str$(x))71 ActiveBasic.Strings.Detail.FormatIntegerD(This, x, DWORD_MAX, 0, 0) 74 72 Return This 75 73 End Function 76 74 77 75 Function Append(x As DWord) As StringBuilder 78 A ppend(Str$(x))76 ActiveBasic.Strings.Detail.FormatIntegerU(This, x, DWORD_MAX, 0, 0) 79 77 Return This 80 78 End Function 81 79 82 80 Function Append(x As Int64) As StringBuilder 83 A ppend(Str$(x))81 ActiveBasic.Strings.Detail.FormatIntegerLD(This, x, DWORD_MAX, 0, 0) 84 82 Return This 85 83 End Function 86 84 87 85 Function Append(x As QWord) As StringBuilder 88 A ppend(Str$(x))86 ActiveBasic.Strings.Detail.FormatIntegerLU(This, x, DWORD_MAX, 0, 0) 89 87 Return This 90 88 End Function 91 89 92 90 Function Append(x As Single) As StringBuilder 93 A ppend(Str$(x))91 ActiveBasic.Strings.Detail.FormatFloatG(This, x, DWORD_MAX, 0, 0) 94 92 Return This 95 93 End Function 96 94 97 95 Function Append(x As Double) As StringBuilder 98 A ppend(Str$(x))96 ActiveBasic.Strings.Detail.FormatFloatG(This, x, DWORD_MAX, 0, 0) 99 97 Return This 100 98 End Function … … 105 103 End Function 106 104 107 Function Append(c As StrChar, n As Long) As StringBuilder105 Function Append(c As Char, n As Long) As StringBuilder 108 106 EnsureCapacity(size + n) 109 107 ActiveBasic.Strings.ChrFill(VarPtr(chars[size]), n As SIZE_T, c) … … 123 121 End Function 124 122 125 Function Append(s As * StrChar, startIndex As Long, count As Long) As StringBuilder123 Function Append(s As *Char, startIndex As Long, count As Long) As StringBuilder 126 124 If s = 0 Then 127 125 If startIndex = 0 And count = 0 Then … … 137 135 End Function 138 136 Private 139 Sub appendCore(s As * StrChar, start As Long, count As Long)137 Sub appendCore(s As *Char, start As Long, count As Long) 140 138 EnsureCapacity(size + count) 141 139 separateBuffer() … … 167 165 End Function 168 166 169 Const Sub CopyTo(sourceIndex As Long, ByRef dest[] As StrChar, destIndex As Long, count As Long)167 Const Sub CopyTo(sourceIndex As Long, ByRef dest[] As Char, destIndex As Long, count As Long) 170 168 If dest = 0 Then 171 169 Throw New ArgumentNullException("StringBuilder.CopyTo: An argument is null", "sourceIndex") … … 174 172 End If 175 173 176 memcpy(VarPtr(dest[destIndex]), VarPtr(chars[sourceIndex]), count * SizeOf ( StrChar))174 memcpy(VarPtr(dest[destIndex]), VarPtr(chars[sourceIndex]), count * SizeOf (Char)) 177 175 End Sub 178 176 … … 181 179 Throw New ArgumentOutOfRangeException("StringBuilder.Append: An argument is out of range value.", "c") 182 180 ElseIf c > Capacity Then 183 Dim p = GC_malloc_atomic((c + 1) * SizeOf ( StrChar)) As *StrChar181 Dim p = GC_malloc_atomic((c + 1) * SizeOf (Char)) As *Char 184 182 ActiveBasic.Strings.ChrCopy(p, chars, size As SIZE_T) 185 183 chars = p … … 212 210 End Function 213 211 214 Function Insert(i As Long, x As StrChar) As StringBuilder212 Function Insert(i As Long, x As Char) As StringBuilder 215 213 Insert(i, VarPtr(x), 0, 1) 216 214 Return This … … 303 301 End Function 304 302 305 Function Insert(i As Long, x As * StrChar, index As Long, count As Long) As StringBuilder303 Function Insert(i As Long, x As *Char, index As Long, count As Long) As StringBuilder 306 304 rangeCheck(i) 307 305 If x = 0 Then … … 342 340 End Function 343 341 344 Function Replace(oldChar As StrChar, newChar As StrChar) As StringBuilder342 Function Replace(oldChar As Char, newChar As Char) As StringBuilder 345 343 replaceCore(oldChar, newChar, 0, size) 346 344 Return This … … 352 350 End Function 353 351 354 Function Replace(oldChar As StrChar, newChar As StrChar, startIndex As Long, count As Long) As StringBuilder352 Function Replace(oldChar As Char, newChar As Char, startIndex As Long, count As Long) As StringBuilder 355 353 rangeCheck(startIndex, count) 356 354 replaceCore(oldChar, newChar, startIndex, count) … … 364 362 End Function 365 363 Private 366 Sub replaceCore(oldChar As StrChar, newChar As StrChar, start As Long, count As Long)364 Sub replaceCore(oldChar As Char, newChar As Char, start As Long, count As Long) 367 365 separateBuffer() 368 366 Dim i As Long … … 386 384 Dim last = start + count 387 385 Do 388 Dim nextPos = ActiveBasic.Strings.ChrFind(VarPtr(chars[curPos]) As * StrChar, size As SIZE_T, StrPtr(oldStr), oldStr.Length As SIZE_T) As Long386 Dim nextPos = ActiveBasic.Strings.ChrFind(VarPtr(chars[curPos]) As *Char, size As SIZE_T, StrPtr(oldStr), oldStr.Length As SIZE_T) As Long 389 387 If nextPos = -1 As SIZE_T Or curPos > last Then 390 388 s.appendCore(chars, curPos, size - curPos) … … 411 409 End Function 412 410 413 Const Function Operator [](i As Long) As StrChar411 Const Function Operator [](i As Long) As Char 414 412 Return Chars[i] 415 413 End Function 416 414 417 Sub Operator []=(i As Long, c As StrChar)415 Sub Operator []=(i As Long, c As Char) 418 416 Chars[i] = c 419 417 End Sub … … 431 429 End Sub 432 430 433 Const Function Chars(i As Long) As StrChar431 Const Function Chars(i As Long) As Char 434 432 If i >= Length Or i < 0 Then 435 433 Throw New IndexOutOfRangeException("StringBuilder.Chars: The index argument 'i' is out of range value.") … … 438 436 End Function 439 437 440 Sub Chars(i As Long, c As StrChar)438 Sub Chars(i As Long, c As Char) 441 439 If i >= Length Or i < 0 Then 442 440 Throw New ArgumentOutOfRangeException("StringBuilder.Chars: An argument is out of range value.", "i") … … 452 450 EnsureCapacity(i) 'iが適切な値かどうかの確認はこの中で行う 453 451 If size < i Then 454 ActiveBasic.Strings.ChrFill(VarPtr(chars[size]), (i - size + 1) As SIZE_T, 0 As StrChar)452 ActiveBasic.Strings.ChrFill(VarPtr(chars[size]), (i - size + 1) As SIZE_T, 0 As Char) 455 453 End If 456 454 size = i … … 461 459 End Function 462 460 463 Function __Chars() As * StrChar461 Function __Chars() As *Char 464 462 Return chars 465 463 End Function … … 483 481 This.maxCapacity = maxCapacity 484 482 This.size = 0 485 This.chars = GC_malloc_atomic((This.capacity + 1) * SizeOf ( StrChar))483 This.chars = GC_malloc_atomic((This.capacity + 1) * SizeOf (Char)) 486 484 End Sub 487 485 … … 516 514 Sub separateBuffer() 517 515 If stringized Then 518 Dim newChars = GC_malloc_atomic(SizeOf ( StrChar) * capacity) As *StrChar516 Dim newChars = GC_malloc_atomic(SizeOf (Char) * capacity) As *Char 519 517 ActiveBasic.Strings.ChrCopy(newChars, chars, capacity As SIZE_T) 520 518 chars = newChars … … 523 521 End Sub 524 522 525 chars As * StrChar523 chars As *Char 526 524 maxCapacity As Long 527 525 capacity As Long … … 534 532 535 533 '暫定 536 Function StrPtr(sb As System.Text.StringBuilder) As * StrChar534 Function StrPtr(sb As System.Text.StringBuilder) As *Char 537 535 Return sb.__Chars 538 536 End Function
Note:
See TracChangeset
for help on using the changeset viewer.