Ignore:
Timestamp:
Mar 6, 2008, 9:49:43 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

(SPrintF.ab) FormatIntegerExにStringBuilderを引数に取る版を追加。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/String.ab

    r428 r457  
    2727
    2828    Class String
    29     '   Inherits IComparable, ICloneable, IConvertible, IEnumerable
     29        Implements /*IComparable, ICloneable, IConvertible, IComparable<String>, IEnumerable, IEnumerable<StrChar>, IEquatable<String>*/
    3030
    3131        m_Length As Long
     
    3434        Sub validPointerCheck(p As VoidPtr, size = 1 As Long)
    3535            If p As ULONG_PTR < &h10000 Then
    36                 'Throw ArgumentException
    37                 Debug
     36                Throw New ArgumentException
    3837            ElseIf IsBadReadPtr(p, size As ULONG_PTR) Then
    39                 'Throw ArgumentException
    40                 Debug
     38                Throw New ArgumentException
    4139            End If
    4240        End Sub
     
    153151
    154152        Const Function Operator == (y As String) As Boolean
    155             Return String.Compare(This, y) = 0
     153            Return Compare(This, y) = 0
    156154        End Function
    157155
    158156        Const Function Operator == (y As *StrChar) As Boolean
    159             Return String.Compare(This, y) = 0
     157            Return Compare(This, y) = 0
    160158        End Function
    161159
    162160        Const Function Operator <> (y As String) As Boolean
    163             Return String.Compare(This, y) <> 0
     161            Return Compare(This, y) <> 0
    164162        End Function
    165163
    166164        Const Function Operator <> (y As *StrChar) As Boolean
    167             Return String.Compare(This, y) <> 0
     165            Return Compare(This, y) <> 0
    168166        End Function
    169167
    170168        Const Function Operator < (y As String) As Boolean
    171             Return String.Compare(This, y) < 0
     169            Return Compare(This, y) < 0
    172170        End Function
    173171
    174172        Const Function Operator < (y As *StrChar) As Boolean
    175             Return String.Compare(This, y) < 0
     173            Return Compare(This, y) < 0
    176174        End Function
    177175
    178176        Const Function Operator > (y As String) As Boolean
    179             Return String.Compare(This, y) > 0
     177            Return Compare(This, y) > 0
    180178        End Function
    181179
    182180        Const Function Operator > (y As *StrChar) As Boolean
    183             Return String.Compare(This, y) > 0
     181            Return Compare(This, y) > 0
    184182        End Function
    185183
    186184        Const Function Operator <= (y As String) As Boolean
    187             Return String.Compare(This, y) <= 0
     185            Return Compare(This, y) <= 0
    188186        End Function
    189187
    190188        Const Function Operator <= (y As *StrChar) As Boolean
    191             Return String.Compare(This, y) <= 0
     189            Return Compare(This, y) <= 0
    192190        End Function
    193191
    194192        Const Function Operator >= (y As String) As Boolean
    195             Return String.Compare(This, y) >= 0
     193            Return Compare(This, y) >= 0
    196194        End Function
    197195
    198196        Const Function Operator >= (y As *StrChar) As Boolean
    199             Return String.Compare(This, y) >= 0
     197            Return Compare(This, y) >= 0
    200198        End Function
    201199
     
    205203
    206204    Public
     205        'Compareなどで、x.Charsではなく、StrPtr(x)と書く理由は、xがNothingの場合のため。
     206
    207207        Static Function Compare(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
    208             Return String.CompareOrdinal(x, indexX, y, indexY, length)
     208            Return CompareOrdinal(x, indexX, y, indexY, length)
    209209        End Function
    210210
    211211        Static Function CompareOrdinal(x As String, y As String) As Long
    212             Return String.CompareOrdinal(x.Chars, y.Chars)
     212            Return CompareOrdinal(StrPtr(x), StrPtr(y))
    213213        End Function
    214214
    215215        Static Function CompareOrdinal(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
    216             Return String.CompareOrdinal(x.Chars, indexX, y.Chars, indexY, length)
     216            Return CompareOrdinal(StrPtr(x), indexX, StrPtr(y), indexY, length)
    217217        End Function
    218218    Private
    219219        Static Function Compare(x As String, y As *StrChar) As Long
    220             Return String.CompareOrdinal(x, y)
     220            Return CompareOrdinal(x, y)
    221221        End Function
    222222
    223223        Static Function CompareOrdinal(x As String, y As *StrChar) As Long
    224             Return String.CompareOrdinal(x.Chars, y)
     224            Return CompareOrdinal(StrPtr(x), y)
    225225        End Function
    226226
     
    257257        Function CompareTo(y As Object) As Long
    258258            If Not Object.Equals(This.GetType(), y.GetType()) Then
    259                 Throw New ArgumentException("String.CompareTo: An argument is out of range value.", "y")
     259                Throw New ArgumentException("String.CompareTo: The type of the argument y is not String.", "y")
    260260            End If
    261261            Return CompareTo(y As String)
     
    351351        End Function
    352352
     353        Static Function Concat(x As String, y As String, z As String) As String
     354            Dim sb = New Text.StringBuilder(removeNull(x).Length + removeNull(y).Length + removeNull(z).Length)
     355            sb.Append(x).Append(y).Append(z)
     356            Concat = sb.ToString
     357        End Function
     358
     359        Static Function Concat(x As String, y As String, z As String, w As String) As String
     360            Dim sb = New Text.StringBuilder(removeNull(x).Length + removeNull(y).Length + removeNull(z).Length + removeNull(w).Length)
     361            sb.Append(x).Append(y).Append(z).Append(w)
     362            Concat = sb.ToString
     363        End Function
     364
    353365        Static Function Concat(x As Object, y As Object) As String
    354             Return String.Concat(x.ToString, y.ToString)
     366            Return Concat(x.ToString, y.ToString)
     367        End Function
     368
     369        Static Function Concat(x As Object, y As Object, z As Object) As String
     370            Return Concat(x.ToString, y.ToString, z.ToString)
     371        End Function
     372
     373        Static Function Concat(x As Object, y As Object, z As Object, w As Object) As String
     374            Return Concat(x.ToString, y.ToString, z.ToString, w.ToString)
    355375        End Function
    356376
     
    575595            Clone = This
    576596        End Function
    577 
     597/*
     598        Function Clone() As Object
     599            Clone = This
     600        End Function
     601*/
    578602        Static Function Copy(s As String) As String
    579603            Copy = New String(s.Chars, s.m_Length)
     
    656680            End If
    657681        End Sub
     682
     683        Static Function removeNull(s As String) As String
     684            If ActiveBasic.IsNothing(s) Then
     685                removeNull = Empty
     686            Else
     687                removeNull = s
     688            End If
     689        End Function
    658690    End Class
    659691
Note: See TracChangeset for help on using the changeset viewer.