Changeset 621 for trunk/ab5.0
- Timestamp:
- Sep 2, 2008, 2:22:49 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/String.ab
r531 r621 61 61 62 62 Sub String(initStr As String) 63 If Not String.IsNullOrEmpty(initStr) Then63 If Not IsNullOrEmpty(initStr) Then 64 64 Assign(initStr.Chars, initStr.m_Length) 65 65 End If … … 234 234 Function CompareTo(y As Object) As Long 235 235 If Not Object.Equals(This.GetType(), y.GetType()) Then 236 Throw New ArgumentException("String.CompareTo: The type of the argumenty is not String.", "y")236 Throw New ArgumentException("String.CompareTo: y is not String.", "y") 237 237 End If 238 238 Return CompareTo(y As String) … … 260 260 #ifdef UNICODE 261 261 Dim textLengthW = MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, 0, 0) 262 If AllocStringBuffer(textLengthW) <> 0 Then 263 MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, Chars, textLengthW) 264 Chars[textLengthW] = 0 265 End If 262 AllocStringBuffer(textLengthW) 263 MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, Chars, textLengthW) 264 Chars[textLengthW] = 0 266 265 #else 267 266 AssignFromCharPtr(text, textLengthA) … … 274 273 #else 275 274 Dim textLengthA = WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, 0, 0, 0, 0) 276 If AllocStringBuffer(textLengthA) <> 0 Then 277 WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, Chars, textLengthA, 0, 0) 278 Chars[textLengthA] = 0 279 End If 275 AllocStringBuffer(textLengthA) 276 WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, Chars, textLengthA, 0, 0) 277 Chars[textLengthA] = 0 280 278 #endif 281 279 End Sub … … 323 321 324 322 Static Function Concat(x As String, y As String) As String 325 If String.IsNullOrEmpty(x) Then323 If IsNullOrEmpty(x) Then 326 324 Return y 327 325 Else … … 359 357 360 358 Const Function Contains(s As String) As Boolean 361 If Object.ReferenceEquals(s, Nothing) Then359 If ActiveBasic.IsNothing(s) Then 362 360 Throw New ArgumentNullException("String.Contains: An argument is null value.", "s") 363 361 ElseIf s = "" Then … … 399 397 Const Function IndexOf(s As String, startIndex As Long, count As Long) As Long 400 398 rangeCheck(startIndex, count) 401 If Object.ReferenceEquals(s, Nothing) Then399 If ActiveBasic.IsNothing(s) Then 402 400 Throw New ArgumentNullException("String.IndexOf: An argument is out of range value.", "s") 403 401 End If … … 458 456 459 457 Const Function LastIndexOf(s As String, start As Long, count As Long) As Long 460 If Object.ReferenceEquals(s, Nothing) Then458 If ActiveBasic.IsNothing(s) Then 461 459 Throw New ArgumentNullException("String.LastIndexOf: An argument is out of range value.", "s") 462 460 End If … … 684 682 End Function 685 683 Private 686 Function AllocStringBuffer(textLength As Long) As *Char684 Sub AllocStringBuffer(textLength As Long) 687 685 If textLength < 0 Then 688 Return 0 689 End If 690 AllocStringBuffer = GC_malloc_atomic(SizeOf(Char) * (textLength + 1)) 691 If AllocStringBuffer = 0 Then 692 'Throw New OutOfMemoryException 693 End If 686 Throw New ArgumentException 687 End If 688 Chars = GC_malloc_atomic(SizeOf(Char) * (textLength + 1)) 694 689 m_Length = textLength 695 Chars = AllocStringBuffer 696 End Function 690 End Sub 697 691 698 692 Sub AssignFromCharPtr(text As *Char, textLength As Long) … … 704 698 Const Sub rangeCheck(index As Long) 705 699 If index < 0 Or index > m_Length Then 706 Throw New ArgumentOutOfRangeException("String: An argument sis out of range value.", "index")700 Throw New ArgumentOutOfRangeException("String: An argument is out of range value.", "index") 707 701 End If 708 702 End Sub
Note:
See TracChangeset
for help on using the changeset viewer.