Ignore:
Timestamp:
Apr 4, 2007, 6:53:48 PM (18 years ago)
Author:
イグトランス (egtra)
Message:

GCHandleの追加、String.Compareなどの追加、gc.sbpの修正

File:
1 edited

Legend:

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

    r193 r203  
    1616
    1717Class String
     18'   Inherits IComparable, ICloneable, IConvertible, IEnumerable
     19
    1820    m_Length As Long
    1921Public
     
    2123
    2224    Sub String()
    23         Chars = _System_malloc(SizeOf (StrChar)) '0
     25        Chars = _System_malloc(SizeOf (StrChar))
    2426        Chars[0] = 0
    2527        m_Length = 0
     
    129131    End Function
    130132
    131     Const Function Operator + (ByRef objString As String) As String
     133    Const Function Operator + (objString As String) As String
    132134        Return Concat(objString.Chars, objString.m_Length)
    133135    End Function
     
    143145    End Function
    144146
    145     Const Function Operator & (ByRef objString As String) As String
     147    Const Function Operator & (objString As String) As String
    146148        Dim tempString = This + objString
    147149        Return tempString
    148150    End Function
    149151
    150     Const Function Operator == (ByRef objString As String) As Boolean
    151         Return _System_StrCmp(This.Chars, objString.Chars) = 0
     152    Const Function Operator == (objString As String) As Boolean
     153        Return String.Compare(This, objString) = 0
    152154    End Function
    153155
     
    156158    End Function
    157159
    158     Const Function Operator <> (ByRef objString As String) As Boolean
    159         Return _System_StrCmp(This.Chars, objString.Chars) <> 0
     160    Const Function Operator <> (objString As String) As Boolean
     161        Return String.Compare(This, objString) <> 0
    160162    End Function
    161163
     
    164166    End Function
    165167
    166     Const Function Operator < (ByRef objString As String) As Boolean
    167         Return _System_StrCmp(This.Chars, objString.Chars) < 0
     168    Const Function Operator < (objString As String) As Boolean
     169        Return String.Compare(This, objString) < 0
    168170    End Function
    169171
     
    172174    End Function
    173175
    174     Const Function Operator > (ByRef objString As String) As Boolean
    175         Return _System_StrCmp(This.Chars, objString.Chars) > 0
     176    Const Function Operator > (objString As String) As Boolean
     177        Return String.Compare(This, objString) > 0
    176178    End Function
    177179
     
    180182    End Function
    181183
    182     Const Function Operator <= (ByRef objString As String) As Boolean
    183         Return _System_StrCmp(This.Chars, objString.Chars) <= 0
     184    Const Function Operator <= (objString As String) As Boolean
     185        Return String.Compare(This, objString) <= 0
    184186    End Function
    185187
     
    188190    End Function
    189191
    190     Const Function Operator >= (ByRef objString As String) As Boolean
    191         Return _System_StrCmp(This.Chars, objString.Chars) >= 0
     192    Const Function Operator >= (objString As String) As Boolean
     193        Return String.Compare(This, objString) >= 0
    192194    End Function
    193195
    194196    Const Function Operator >= (text As *StrChar) As Boolean
    195197        Return _System_StrCmp(This.Chars, text) >= 0
     198    End Function
     199
     200    Static Function Compare(x As String, y As String) As Long
     201        Return CompareOrdinal(x, y)
     202    End Function
     203
     204    Static Function Compare(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
     205        Return CompareOrdinal(x, indexX, y, indexY, length)
     206    End Function
     207
     208    Static Function CompareOrdinal(x As String, y As String) As Long
     209        Return _System_StrCmp(x.Chars, y.Chars)
     210    End Function
     211
     212    Static Function CompareOrdinal(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
     213        If x = Nothing Then
     214            If y = Nothing Then
     215                Return 0
     216            Else
     217                Return -1
     218            End If
     219        ElseIf y = Nothing Then
     220            Return 1
     221        End If
     222        Return _System_StrCmpN(VarPtr(x.Chars[indexX]), VarPtr(y.Chars[indexY]), length)
     223    End Function
     224
     225    Function CompareTo(y As String) As Long
     226        Return String.Compare(This, y)
     227    End Function
     228
     229    Function CompareTo(y As Object) As Long
     230        Dim s = y As String
     231'       If y is not String Then
     232'           Throw New ArgumentException
     233'       End If
     234        Return CompareTo(y)
    196235    End Function
    197236
     
    341380#endif
    342381    End Function
    343     Const Function Contains(ByRef objString As String) As Boolean
     382
     383    Static Function Concat(x As String, y As String) As String
     384        If x = Nothing Then
     385            Return y
     386        Else
     387            Return x.Concat(objString.Chars, objString.m_Length)
     388        End If
     389    End Function
     390
     391    Static Function Concat(x As Object, y As Object) As String
     392        Return String.Concat(x.ToString, y.ToString)
     393    End Function
     394
     395    Const Function Contains(objString As String) As Boolean
    344396        Return IndexOf(objString, 0, m_Length) >= 0
    345397    End Function
Note: See TracChangeset for help on using the changeset viewer.