Changeset 175 for Include/com/bstring.ab


Ignore:
Timestamp:
Mar 21, 2007, 7:06:34 PM (18 years ago)
Author:
イグトランス (egtra)
Message:

Variant, VBObjectの追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/com/bstring.ab

    r142 r175  
    6666    Sub AssignFromBStr(bstr As BSTR)
    6767        Clear()
    68         BString(bstr)
     68        String.Copy(bs, bstr)
    6969    End Sub
     70
     71    Const Function Copy() As BSTR
     72        BString.Copy(Copy, bs)
     73    End Function
    7074
    7175    Sub Clear()
     
    7882    Sub Attach(bstr As BSTR)
    7983        Clear()
    80         bs = bstr
     84        BString.Move(bs, bstr)
    8185    End Sub
    8286
    8387    Function Detach() As BSTR
    84         Detach = bs
    85         bs = 0
     88        BString.Move(Detach, bs)
    8689    End Function
    8790
     
    113116
    114117    Override Function ToString() As String
    115         Dim s As String(bs, Length)
     118        Dim s As String(bs As PCWSTR, Length As Long)
    116119        Return s
     120    End Function
     121
     122    Override Function GetHashCode() As Long
     123        Return _System_GetHashFromWordArray(bs, Length)
    117124    End Function
    118125
    119126Private
    120127    bs As BSTR
     128
     129    Static Sub Copy(ByRef dst As BSTR, ByVal src As BSTR)
     130        dst = SysAllocStringLen(src, SysStringLen(src))
     131    End Sub
     132
     133    Static Sub Move(ByRef dst As BSTR, ByRef src As BSTR)
     134        dst = src
     135        src = 0
     136    End Sub
    121137End Class
    122138
Note: See TracChangeset for help on using the changeset viewer.