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/Classes/System/String.ab

    r143 r175  
    233233    End Sub
    234234
    235     Sub AssignFromStrChar(text As *StrChar, textLength As Long)
    236         If text = Chars Then Exit Sub
    237         If AllocStringBuffer(textLength) <> 0 Then
    238             memcpy(Chars, text, SizeOf (StrChar) * textLength)
    239             Chars[m_Length] = 0
    240         End If
    241     End Sub
    242 #ifdef __STRCHAR_IS_NOT_UNICODE
    243     Sub AssignFromWideChar(text As PCWSTR, textLengthW As Long)
     235    Sub Assign(text As PCSTR, textLengthA As Long)
     236#ifdef __STRING_IS_NOT_UNICODE
     237        AssignFromStrChar(text, textLengthA)
     238#else
     239        Dim textLengthW = MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, 0, 0)
     240        If AllocStringBuffer(textLengthW) <> 0 Then
     241            MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, Chars, textLengthW)
     242        End If
     243#endif
     244    End Sub
     245
     246    Sub Assign(text As PCWSTR, textLengthW As Long)
     247#ifdef __STRING_IS_NOT_UNICODE
    244248        Dim textLengthA = WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, 0, 0, 0, 0)
    245249        If AllocStringBuffer(textLengthA) <> 0 Then
    246250            WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, Chars, textLengthA, 0, 0)
    247251        End If
    248     End Sub
    249252#else
    250     Sub AssignFromMultiByte(text As PCSTR, textLengthA As Long)
    251         Dim textLengthW = MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, 0, 0)
    252         If AllocStringBuffer(textLengthW) <> 0 Then
    253             MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, Chars, textLengthW)
    254         End If
    255     End Sub
    256 #endif
    257     Sub Assign(text As PCSTR, textLength As Long)
    258 #ifdef __STRING_IS_NOT_UNICODE
    259         AssignFromStrChar(text, textLength)
    260 #else
    261         AssignFromMultiByte(text, textLength)
    262 #endif
    263     End Sub
    264 
    265     Sub Assign(text As PCWSTR, textLength As Long)
    266 #ifdef __STRING_IS_NOT_UNICODE
    267         AssignFromWideChar(text, textLength)
    268 #else
    269         AssignFromStrChar(text, textLength)
     253        AssignFromStrChar(text, textLengthW)
    270254#endif
    271255    End Sub
     
    571555        Dim size = m_Length
    572556#endif
    573         Dim hash = 0 As DWord
    574         Dim p = Chars As *Word
    575         Dim i As Long
    576         For i = 0 To ELM(size)
    577             hash = ((hash << 16) + p[i]) Mod &h7fffffff
    578         Next
    579         Return hash As Long
     557        Return _System_GetHashFromWordArray(Chars As *Word, size)
    580558    End Function
    581559Private
     
    617595    End Function
    618596
     597    Sub AssignFromStrChar(text As *StrChar, textLength As Long)
     598        If text = Chars Then Exit Sub
     599        If AllocStringBuffer(textLength) <> 0 Then
     600            memcpy(Chars, text, SizeOf (StrChar) * textLength)
     601            Chars[m_Length] = 0
     602        End If
     603    End Sub
    619604End Class
Note: See TracChangeset for help on using the changeset viewer.