Changeset 119 for Include/Classes/System/String.ab
- Timestamp:
- Feb 23, 2007, 11:00:24 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/String.ab
r49 r119 2 2 m_Length As Long 3 3 Public 4 Chars As LPSTR4 Chars As *Char 5 5 6 6 Sub String() … … 9 9 End Sub 10 10 11 Sub String(initStr As LPSTR)11 Sub String(initStr As *Char) 12 12 String() 13 13 Assign(initStr) … … 24 24 End Sub 25 25 */ 26 Sub String(initChar As Byte, length As Long)26 Sub String(initChar As Char, length As Long) 27 27 ReSize(length, initChar) 28 28 End Sub … … 40 40 End Function 41 41 42 Function Operator() As LPSTR42 Function Operator() As *Char 43 43 Return Chars 44 44 End Function … … 48 48 End Sub 49 49 50 Sub Operator = (text As LPSTR)50 Sub Operator = (text As *Char) 51 51 Assign(text) 52 52 End Sub 53 53 54 Function Operator[] (n As Long) As Byte54 Function Operator[] (n As Long) As Char 55 55 Return Chars[n] 56 56 End Function 57 57 58 Sub Operator[]= (n As Long, c As Byte)58 Sub Operator[]= (n As Long, c As Char) 59 59 Chars[n] = c 60 60 End Sub 61 61 62 Function Operator+ (lpszText As LPSTR) As String62 Function Operator+ (lpszText As *Char) As String 63 63 Return Concat(lpszText, lstrlen(lpszText)) 64 64 End Function … … 68 68 End Function 69 69 70 Function Operator& (lpszText As LPSTR) As String70 Function Operator& (lpszText As *Char) As String 71 71 Dim tempString As String 72 72 tempString=This+lpszText … … 88 88 End Function 89 89 90 Function Operator== (lpszText As LPSTR) As Long90 Function Operator== (lpszText As *Char) As Long 91 91 If lstrcmp(This, lpszText) = 0 Then 92 92 Return _System_TRUE … … 100 100 End Function 101 101 102 Function Operator<> (lpszText As LPSTR) As Long102 Function Operator<> (lpszText As *Char) As Long 103 103 Return lstrcmp(This, lpszText) 104 104 End Function … … 112 112 End Function 113 113 114 Function Operator< (lpszText As LPSTR) As Long114 Function Operator< (lpszText As *Char) As Long 115 115 If lstrcmp(This, lpszText) < 0 Then 116 116 Return _System_TRUE … … 128 128 End Function 129 129 130 Function Operator> (lpszText As LPSTR) As Long130 Function Operator> (lpszText As *Char) As Long 131 131 If lstrcmp(This, lpszText) > 0 Then 132 132 Return _System_TRUE … … 144 144 End Function 145 145 146 Function Operator<= (lpszText As LPSTR) As Long146 Function Operator<= (lpszText As *Char) As Long 147 147 If lstrcmp(This, lpszText) <= 0 Then 148 148 Return _System_TRUE … … 160 160 End Function 161 161 162 Function Operator>= (lpszText As LPSTR) As Long162 Function Operator>= (lpszText As *Char) As Long 163 163 If lstrcmp(This, lpszText) => 0 Then 164 164 Return _System_TRUE … … 168 168 End Function 169 169 170 Function StrPtr() As LPSTR170 Function StrPtr() As *Char 171 171 Return Chars 172 172 End Function … … 186 186 End Sub 187 187 188 Sub ReSize(allocLength As Long, c As Byte)188 Sub ReSize(allocLength As Long, c As Char) 189 189 If allocLength < 0 Then 190 190 Exit Sub … … 201 201 End Sub 202 202 203 Sub Assign(lpszText As LPSTR, textLength As Long)203 Sub Assign(lpszText As *Char, textLength As Long) 204 204 If lpszText = Chars Then Exit Sub 205 205 If AllocStringBuffer(textLength) <> 0 Then … … 213 213 End Sub 214 214 215 Sub Assign(lpszText As LPSTR)215 Sub Assign(lpszText As *Char) 216 216 If lpszText Then 217 217 Assign(lpszText, lstrlen(lpszText)) … … 223 223 End Sub 224 224 225 Sub Append(lpszText As LPSTR, textLength As Long)225 Sub Append(lpszText As *Char, textLength As Long) 226 226 Dim prevLen As Long 227 227 prevLen = m_Length … … 232 232 End Sub 233 233 234 Sub Append(text As LPSTR)234 Sub Append(text As *Char) 235 235 Append(text, lstrlen(text)) 236 236 End Sub … … 240 240 End Sub 241 241 242 Function Concat(lpszText As LPSTR, textLength As Long) As String242 Function Concat(lpszText As *Char, textLength As Long) As String 243 243 Dim tempString As String 244 244 With tempString … … 259 259 End Function 260 260 261 Function Contains(lpszText As LPSTR) As BOOL261 Function Contains(lpszText As *Char) As BOOL 262 262 If IndexOf(lpszText, 0, m_Length) >= 0 Then 263 263 Return _System_TRUE … … 267 267 End Function 268 268 269 Function IndexOf(lpszText As LPSTR) As Long269 Function IndexOf(lpszText As *Char) As Long 270 270 Return IndexOf(lpszText, 0, m_Length) 271 271 End Function 272 272 273 Function IndexOf(lpszText As LPSTR, startIndex As Long) As Long273 Function IndexOf(lpszText As *Char, startIndex As Long) As Long 274 274 Return IndexOf(lpszText, startIndex, m_Length - startIndex) 275 275 End Function 276 276 277 Function IndexOf(lpszText As LPSTR, startIndex As Long, count As Long) As Long277 Function IndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long 278 278 Dim length As Long 279 279 length = lstrlen(lpszText) … … 298 298 End Function 299 299 300 Function LastIndexOf(lpszText As LPSTR) As Long300 Function LastIndexOf(lpszText As *Char) As Long 301 301 Return LastIndexOf(lpszText, m_Length - 1, m_Length) 302 302 End Function 303 303 304 Function LastIndexOf(lpszText As LPSTR, startIndex As Long) As Long305 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 Long304 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 309 309 Dim length As Long 310 310 length = lstrlen(lpszText) … … 329 329 End Function 330 330 331 Function StartsWith(lpszText As LPSTR) As BOOL331 Function StartsWith(lpszText As *Char) As BOOL 332 332 If IndexOf(lpszText) = 0 Then 333 333 Return _System_TRUE … … 337 337 End Function 338 338 339 Function EndsWith(lpszText As LPSTR) As BOOL339 Function EndsWith(lpszText As *Char) As BOOL 340 340 If LastIndexOf(lpszText) = m_Length - lstrlen(lpszText) Then 341 341 Return _System_TRUE … … 345 345 End Function 346 346 347 Function Insert(startIndex As Long, lpszText As LPSTR) As Long347 Function Insert(startIndex As Long, lpszText As *Char) As Long 348 348 Dim length As Long 349 349 length = lstrlen(lpszText) … … 351 351 If startIndex < 0 Or startIndex > m_Length Then Return -1 352 352 353 Dim newChars As LPSTR353 Dim newChars As *Char 354 354 newChars = _System_malloc(length + m_Length + 1) 355 355 If newChars = 0 Then Return -1 … … 391 391 If startIndex + count > m_Length Then Return -1 392 392 393 Dim newChars As LPSTR393 Dim newChars As *Char 394 394 newChars = _System_malloc(m_Length - count + 1) 395 395 If newChars = 0 Then Return -1 … … 413 413 End Function 414 414 415 Sub Replace(oldChar As Byte, newChar As Byte) 415 416 Sub Replace(oldChar As Char, newChar As Char) 416 417 Dim i As Long 417 418 For i = 0 To ELM(m_Length) … … 468 469 End Sub 469 470 471 Override Function ToString() As String 472 Return This 473 End Function 474 470 475 Private 471 476 ' メモリ確保に失敗すると元の文字列は失われない。(例外安全でいう強い保障) 472 Function AllocStringBuffer(textLength As Long) As LPSTR477 Function AllocStringBuffer(textLength As Long) As *Char 473 478 If textLength < 0 Then 474 479 Return 0
Note:
See TracChangeset
for help on using the changeset viewer.