示例#1
0
void CString::AssignCopy(int nSrcLen, LPCTSTR lpszSrcData)
{
	AllocBeforeWrite(nSrcLen);
	memcpy(m_pchData, lpszSrcData, nSrcLen*sizeof(TCHAR));
	GetData()->nDataLength = nSrcLen;
	m_pchData[nSrcLen] = '\0';
}
示例#2
0
/*
 * @implemented
 */
const CHString& CHString::operator=(LPCSTR lpsz) throw (CHeap_Exception)
{
    int Len;

    // If we have string, get its len
    if (lpsz != 0)
    {
        Len = strlen(lpsz);
    }
    else
    {
        Len = 0;
    }

    // Do this call, even with null len, just to get empty string
    AllocBeforeWrite(Len);
    if (Len == 0)
    {
        Release();
        return *this;
    }

    // Convert and copy
    mbstowcsz(m_pchData, lpsz, Len + 1);
    // Get new size and so on
    ReleaseBuffer();

    return *this;
}
void CFX_WideString::AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData)
{
    AllocBeforeWrite(nSrcLen);
    FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR));
    m_pData->m_nDataLength = nSrcLen;
    m_pData->m_String[nSrcLen] = 0;
}
示例#4
0
const CString& CString::operator=(LPCWSTR lpsz)
{
	int nSrcLen = lpsz != NULL ? wcslen(lpsz) : 0;
	AllocBeforeWrite(nSrcLen*2);
	_wcstombsz(m_pchData, lpsz, (nSrcLen*2)+1);
	ReleaseBuffer();
	return *this;
}
示例#5
0
const CString& CString::operator=(LPCSTR lpsz)
{
	int nSrcLen = lpsz != NULL ? lstrlenA(lpsz) : 0;
	AllocBeforeWrite(nSrcLen);
	_mbstowcsz(m_pchData, lpsz, nSrcLen+1);
	ReleaseBuffer();
	return *this;
}
示例#6
0
// get the pointer to writable buffer of (at least) nLen bytes
wxStringCharType *wxStringImpl::DoGetWriteBuf(size_t nLen)
{
  if ( !AllocBeforeWrite(nLen) ) {
    // allocation failure handled by caller
    return NULL;
  }

  wxASSERT( GetStringData()->nRefs == 1 );
  GetStringData()->Validate(false);

  return m_pchData;
}
示例#7
0
// helper function: does real copy
bool wxStringImpl::AssignCopy(size_t nSrcLen,
                              const wxStringCharType *pszSrcData)
{
  if ( nSrcLen == 0 ) {
    Reinit();
  }
  else {
    if ( !AllocBeforeWrite(nSrcLen) ) {
      // allocation failure handled by caller
      return false;
    }
    memcpy(m_pchData, pszSrcData, nSrcLen*sizeof(wxStringCharType));
    GetStringData()->nDataLength = nSrcLen;
    m_pchData[nSrcLen] = wxT('\0');
  }
  return true;
}
示例#8
0
// helper function: does real copy
bool wxStringImpl::AssignCopy(size_t nSrcLen,
                              const wxStringCharType *pszSrcData)
{
  if ( nSrcLen == 0 ) {
    Reinit();
  }
  else {
    if ( !AllocBeforeWrite(nSrcLen) ) {
      // allocation failure handled by caller
      return false;
    }

    // use memmove() and not memcpy() here as we might be copying from our own
    // buffer in case of assignment such as "s = s.c_str()" (see #11294)
    memmove(m_pchData, pszSrcData, nSrcLen*sizeof(wxStringCharType));

    GetStringData()->nDataLength = nSrcLen;
    m_pchData[nSrcLen] = wxT('\0');
  }
  return true;
}
示例#9
0
/*
 * @implemented
 */
void CHString::AssignCopy(int nSrcLen, LPCWSTR lpszSrcData) throw (CHeap_Exception)
{
    // Don't allow negative len
    if (nSrcLen < 0)
    {
        RaiseException(ERROR_INVALID_PARAMETER, EXCEPTION_NONCONTINUABLE, 0, 0);
    }

    // We will have to modify a string that might be shared, so duplicate it
    // Ensuring it's big enough to contain our new stuff
    AllocBeforeWrite(nSrcLen);
    if (nSrcLen == 0)
    {
        Release();
        return;
    }

    // Just copy, write down new size, and ensure it's null terminated
    wcsncpy(m_pchData, lpszSrcData, nSrcLen);
    GetData()->nDataLength = nSrcLen;
    m_pchData[nSrcLen] = 0;
}
示例#10
0
void CFX_ByteString::AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen) {
  AllocBeforeWrite(nSrcLen);
  m_pData->CopyContents(pSrcData, nSrcLen);
  m_pData->m_nDataLength = nSrcLen;
}