Ignore:
Timestamp:
Feb 23, 2007, 11:00:24 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

Unicode (#50) 前準備
Byte→Char (#51) 型名は殆ど完了、ただし中身までは手を付けていないものが多い

File:
1 edited

Legend:

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

    r49 r119  
    22    m_Length As Long
    33Public
    4     Chars As LPSTR
     4    Chars As *Char
    55
    66    Sub String()
     
    99    End Sub
    1010
    11     Sub String(initStr As LPSTR)
     11    Sub String(initStr As *Char)
    1212        String()
    1313        Assign(initStr)
     
    2424    End Sub
    2525*/
    26     Sub String(initChar As Byte, length As Long)
     26    Sub String(initChar As Char, length As Long)
    2727        ReSize(length, initChar)
    2828    End Sub
     
    4040    End Function
    4141
    42     Function Operator() As LPSTR
     42    Function Operator() As *Char
    4343        Return Chars
    4444    End Function
     
    4848    End Sub
    4949
    50     Sub Operator = (text As LPSTR)
     50    Sub Operator = (text As *Char)
    5151        Assign(text)
    5252    End Sub
    5353
    54     Function Operator[] (n As Long) As Byte
     54    Function Operator[] (n As Long) As Char
    5555        Return Chars[n]
    5656    End Function
    5757
    58     Sub Operator[]= (n As Long, c As Byte)
     58    Sub Operator[]= (n As Long, c As Char)
    5959        Chars[n] = c
    6060    End Sub
    6161
    62     Function Operator+ (lpszText As LPSTR) As String
     62    Function Operator+ (lpszText As *Char) As String
    6363        Return Concat(lpszText, lstrlen(lpszText))
    6464    End Function
     
    6868    End Function
    6969
    70     Function Operator& (lpszText As LPSTR) As String
     70    Function Operator& (lpszText As *Char) As String
    7171        Dim tempString As String
    7272        tempString=This+lpszText
     
    8888    End Function
    8989
    90     Function Operator== (lpszText As LPSTR) As Long
     90    Function Operator== (lpszText As *Char) As Long
    9191        If lstrcmp(This, lpszText) = 0 Then
    9292            Return _System_TRUE
     
    100100    End Function
    101101
    102     Function Operator<> (lpszText As LPSTR) As Long
     102    Function Operator<> (lpszText As *Char) As Long
    103103        Return lstrcmp(This, lpszText)
    104104    End Function
     
    112112    End Function
    113113
    114     Function Operator< (lpszText As LPSTR) As Long
     114    Function Operator< (lpszText As *Char) As Long
    115115        If lstrcmp(This, lpszText) < 0 Then
    116116            Return _System_TRUE
     
    128128    End Function
    129129
    130     Function Operator> (lpszText As LPSTR) As Long
     130    Function Operator> (lpszText As *Char) As Long
    131131        If lstrcmp(This, lpszText) > 0 Then
    132132            Return _System_TRUE
     
    144144    End Function
    145145
    146     Function Operator<= (lpszText As LPSTR) As Long
     146    Function Operator<= (lpszText As *Char) As Long
    147147        If lstrcmp(This, lpszText) <= 0 Then
    148148            Return _System_TRUE
     
    160160    End Function
    161161
    162     Function Operator>= (lpszText As LPSTR) As Long
     162    Function Operator>= (lpszText As *Char) As Long
    163163        If lstrcmp(This, lpszText) => 0 Then
    164164            Return _System_TRUE
     
    168168    End Function
    169169
    170     Function StrPtr() As LPSTR
     170    Function StrPtr() As *Char
    171171        Return Chars
    172172    End Function
     
    186186    End Sub
    187187
    188     Sub ReSize(allocLength As Long, c As Byte)
     188    Sub ReSize(allocLength As Long, c As Char)
    189189        If allocLength < 0 Then
    190190            Exit Sub
     
    201201    End Sub
    202202
    203     Sub Assign(lpszText As LPSTR, textLength As Long)
     203    Sub Assign(lpszText As *Char, textLength As Long)
    204204        If lpszText = Chars Then Exit Sub
    205205        If AllocStringBuffer(textLength) <> 0 Then
     
    213213    End Sub
    214214
    215     Sub Assign(lpszText As LPSTR)
     215    Sub Assign(lpszText As *Char)
    216216        If lpszText Then
    217217            Assign(lpszText, lstrlen(lpszText))
     
    223223    End Sub
    224224
    225     Sub Append(lpszText As LPSTR, textLength As Long)
     225    Sub Append(lpszText As *Char, textLength As Long)
    226226        Dim prevLen As Long
    227227        prevLen = m_Length
     
    232232    End Sub
    233233
    234     Sub Append(text As LPSTR)
     234    Sub Append(text As *Char)
    235235        Append(text, lstrlen(text))
    236236    End Sub
     
    240240    End Sub
    241241
    242     Function Concat(lpszText As LPSTR, textLength As Long) As String
     242    Function Concat(lpszText As *Char, textLength As Long) As String
    243243        Dim tempString As String
    244244        With tempString
     
    259259    End Function
    260260
    261     Function Contains(lpszText As LPSTR) As BOOL
     261    Function Contains(lpszText As *Char) As BOOL
    262262        If IndexOf(lpszText, 0, m_Length) >= 0 Then
    263263            Return _System_TRUE
     
    267267    End Function
    268268
    269     Function IndexOf(lpszText As LPSTR) As Long
     269    Function IndexOf(lpszText As *Char) As Long
    270270        Return IndexOf(lpszText, 0, m_Length)
    271271    End Function
    272272
    273     Function IndexOf(lpszText As LPSTR, startIndex As Long) As Long
     273    Function IndexOf(lpszText As *Char, startIndex As Long) As Long
    274274        Return IndexOf(lpszText, startIndex, m_Length - startIndex)
    275275    End Function
    276276
    277     Function IndexOf(lpszText As LPSTR, startIndex As Long, count As Long) As Long
     277    Function IndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long
    278278        Dim length As Long
    279279        length = lstrlen(lpszText)
     
    298298    End Function
    299299
    300     Function LastIndexOf(lpszText As LPSTR) As Long
     300    Function LastIndexOf(lpszText As *Char) As Long
    301301        Return LastIndexOf(lpszText, m_Length - 1, m_Length)
    302302    End Function
    303303
    304     Function LastIndexOf(lpszText As LPSTR, startIndex As Long) As Long
    305         Return LastIndexOf(lpszText As LPSTR, startIndex, startIndex + 1)
    306     End Function
    307 
    308     Function LastIndexOf(lpszText As LPSTR, startIndex As Long, count As Long) As Long
     304    Function LastIndexOf(lpszText As *Char, startIndex As Long) As Long
     305        Return LastIndexOf(lpszText As *Char, startIndex, startIndex + 1)
     306    End Function
     307
     308    Function LastIndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long
    309309        Dim length As Long
    310310        length = lstrlen(lpszText)
     
    329329    End Function
    330330
    331     Function StartsWith(lpszText As LPSTR) As BOOL
     331    Function StartsWith(lpszText As *Char) As BOOL
    332332        If IndexOf(lpszText) = 0 Then
    333333            Return _System_TRUE
     
    337337    End Function
    338338
    339     Function EndsWith(lpszText As LPSTR) As BOOL
     339    Function EndsWith(lpszText As *Char) As BOOL
    340340        If LastIndexOf(lpszText) = m_Length - lstrlen(lpszText) Then
    341341            Return _System_TRUE
     
    345345    End Function
    346346
    347     Function Insert(startIndex As Long, lpszText As LPSTR) As Long
     347    Function Insert(startIndex As Long, lpszText As *Char) As Long
    348348        Dim length As Long
    349349        length = lstrlen(lpszText)
     
    351351        If startIndex < 0 Or startIndex > m_Length Then Return -1
    352352
    353         Dim newChars As LPSTR
     353        Dim newChars As *Char
    354354        newChars = _System_malloc(length + m_Length + 1)
    355355        If newChars = 0 Then Return -1
     
    391391        If startIndex + count > m_Length Then Return -1
    392392
    393         Dim newChars As LPSTR
     393        Dim newChars As *Char
    394394        newChars = _System_malloc(m_Length - count + 1)
    395395        If newChars = 0 Then Return -1
     
    413413    End Function
    414414
    415     Sub Replace(oldChar As Byte, newChar As Byte)
     415
     416    Sub Replace(oldChar As Char, newChar As Char)
    416417        Dim i As Long
    417418        For i = 0 To ELM(m_Length)
     
    468469    End Sub
    469470
     471    Override Function ToString() As String
     472        Return This
     473    End Function
     474
    470475Private
    471476    ' メモリ確保に失敗すると元の文字列は失われない。(例外安全でいう強い保障)
    472     Function AllocStringBuffer(textLength As Long) As LPSTR
     477    Function AllocStringBuffer(textLength As Long) As *Char
    473478        If textLength < 0 Then
    474479            Return 0
Note: See TracChangeset for help on using the changeset viewer.