Changeset 709 for trunk/ab5.0/ablib/src/com/bstring.ab
- Timestamp:
- Jun 29, 2009, 4:03:45 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/com/bstring.ab
r478 r709 5 5 6 6 Class BString 7 Implements System.IDisposable ', System.ICloneable7 Implements System.IDisposable, System.ICloneable 8 8 Public 9 9 Sub BString() … … 15 15 End Sub 16 16 17 Sub BString(s As BString)18 If Not IsNothing(s) Then19 bs = copy(s.bs)20 End If21 End Sub22 23 17 Sub BString(s As LPCOLESTR, len As DWord) 24 If s <> 0 Then 25 bs = SysAllocStringLen(s, len) 26 End If 18 init(s, len) 27 19 End Sub 28 20 29 21 Sub BString(s As String) 30 22 If Not IsNothing(s) Then 31 Init(s.StrPtr, s.Length As DWord)23 init(s.StrPtr, s.Length As DWord) 32 24 End If 33 25 End Sub … … 73 65 End Function 74 66 75 /*Override*/Function Clone() As BString76 Return New BString( This)77 End Function 78 79 /*Override*/Sub Dispose()67 Function Clone() As BString 68 Return New BString(bs, Length) 69 End Function 70 71 Sub Dispose() 80 72 Clear() 81 73 End Sub … … 103 95 104 96 Const Function Length() As DWord 105 Length = GetDWord(bs As VoidPtr - SizeOf (DWord)) 'SysStringLen(bs)97 Length = SysStringLen(bs) 106 98 End Function 107 99 108 100 Const Function Operator [](i As SIZE_T) As OLECHAR 109 101 If i > Length Then 110 Throw New ArgumentOutOfRangeException("i")102 Throw New System.ArgumentOutOfRangeException("i - BString.Operator [] (get)") 111 103 End If 112 104 Return bs[i] … … 115 107 Sub Operator []=(i As SIZE_T, c As OLECHAR) 116 108 If i > Length Then 117 Throw New ArgumentOutOfRangeException("i")109 Throw New System.ArgumentOutOfRangeException("i - BString.Operator [] (set)") 118 110 End If 119 111 bs[i] = c … … 148 140 End If 149 141 Else 150 If IsNullOrEmpty( bsr) Then142 If IsNullOrEmpty(r) Then 151 143 Compare = 1 152 144 Else … … 156 148 End Function 157 149 158 Static Function IsNullOrEmpty(s As BString) 150 Static Function IsNullOrEmpty(s As BString) As Boolean 159 151 If IsNothing(s) Then 160 152 IsNullOrEmpty = True … … 196 188 197 189 Sub init(s As PCSTR, len As DWord) 198 If <> 0 Then199 Dim lenBS = MultiByteToWideChar(CP_ THREAD_ACP, 0, s, len As Long, 0, 0)190 If s <> 0 Then 191 Dim lenBS = MultiByteToWideChar(CP_ACP, 0, s, len As Long, 0, 0) 200 192 bs = SysAllocStringLen(0, lenBS) 201 193 If bs <> 0 Then 202 MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, bs, lenBS) 203 End If 194 MultiByteToWideChar(CP_ACP, 0, s, len As Long, bs, lenBS) 195 End If 196 End If 197 End Sub 198 199 Sub init(s As PCWSTR, len As DWord) 200 If s <> 0 Then 201 bs = SysAllocStringLen(s, len) 204 202 End If 205 203 End Sub 206 204 207 205 Sub reset(newBS As BSTR) 208 Dim old = InterlockedExchangePointer( bs, newBS)206 Dim old = InterlockedExchangePointer(ByVal VarPtr(bs) As *VoidPtr, newBS) 209 207 SysFreeString(old) 210 208 End Sub … … 215 213 216 214 Static Function move(ByRef src As BSTR) As BSTR 217 move = InterlockedExchangePointer( src, 0)215 move = InterlockedExchangePointer(ByVal VarPtr(src) As *VoidPtr, 0) 218 216 End Function 219 217 End Class
Note:
See TracChangeset
for help on using the changeset viewer.