本文整理汇总了C++中CStdStringW类的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringW类的具体用法?C++ CStdStringW怎么用?C++ CStdStringW使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStdStringW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLocal
bool CWINFileSMB::Exists(const CURL& url)
{
CStdString strFile = GetLocal(url);
URIUtils::RemoveSlashAtEnd(strFile);
CStdStringW strWFile;
g_charsetConverter.utf8ToW(strFile, strWFile, false);
DWORD attributes = GetFileAttributesW(strWFile.c_str());
if(attributes != INVALID_FILE_ATTRIBUTES)
return true;
DWORD err = GetLastError();
if(err != ERROR_ACCESS_DENIED)
return false;
XFILE::CWINSMBDirectory smb;
if(smb.ConnectToShare(url) == false)
return false;
attributes = GetFileAttributesW(strWFile.c_str());
if(attributes == INVALID_FILE_ATTRIBUTES)
return false;
return true;
}
示例2: while
void CCharsetConverter::utf16LEtoW(const char* strSource, CStdStringW &strDest)
{
if (m_iconvUtf16LEtoW == (iconv_t) - 1)
m_iconvUtf16LEtoW = iconv_open(WCHAR_CHARSET, "UTF-16LE");
if (m_iconvUtf16LEtoW != (iconv_t) - 1)
{
size_t inBytes = 2;
short* s = (short*) strSource;
while (*s != 0)
{
s++;
inBytes += 2;
}
size_t outBytes = (inBytes + 1)*sizeof(wchar_t); // UTF-8 is up to 4 bytes/character
char *dst = (char*) strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16LEtoW, &strSource, &inBytes, &dst, &outBytes))
{ // failed :(
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例3: GetModuleHandleW
bool Win32DllLoader::NeedsHooking(const char *dllName)
{
LibraryLoader *loader = DllLoaderContainer::GetModule(dllName);
if (loader)
{
// may have hooked this already (we can have repeats in the import table)
for (unsigned int i = 0; i < m_referencedDlls.size(); i++)
{
if (loader->GetHModule() == m_referencedDlls[i])
return false;
}
}
CStdStringW strdllNameW;
g_charsetConverter.utf8ToW(_P(dllName), strdllNameW, false);
HMODULE hModule = GetModuleHandleW(strdllNameW.c_str());
wchar_t filepathW[MAX_PATH];
GetModuleFileNameW(hModule, filepathW, MAX_PATH);
CStdString dllPath;
g_charsetConverter.wToUTF8(filepathW, dllPath);
// compare this filepath with some special directories
CStdString xbmcPath = _P("special://xbmc");
CStdString homePath = _P("special://home");
CStdString tempPath = _P("special://temp");
return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.GetLength()) == 0) ||
(strncmp(homePath.c_str(), dllPath.c_str(), homePath.GetLength()) == 0) ||
(strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.GetLength()) == 0));
}
示例4: _T
CStdStringW FacadeDocumentProviderImpl::GetDefaultSaveExtensionFromFormatString(const CStdStringW& sAvailableFormats, long lIndex)
{
if(sAvailableFormats.IsEmpty())
return _T("wdf");
int iStartPos = -1;
int lSkip = (lIndex-1)*2;
for (int i=0; i<lSkip; i++)
{
iStartPos = sAvailableFormats.Find(_T('|'),iStartPos);
}
int iFirstDelimeterPos = sAvailableFormats.Find(_T('|'), iStartPos);
if (iFirstDelimeterPos == iStartPos+1) // we've hit the "||" at the end ...
iFirstDelimeterPos = sAvailableFormats.Find(_T('|')); // go back to default
int iNextDelimeterPos = sAvailableFormats.Find(_T('|'),iFirstDelimeterPos);
CStdStringW sExt = sAvailableFormats.Mid(iFirstDelimeterPos + 1 ,iNextDelimeterPos - iFirstDelimeterPos - 1 );
int iPeriodPos = sExt.Find(_T('.'));
sExt = sExt.Mid(iPeriodPos + 1, sExt.length() - iPeriodPos );
return sExt;
}
示例5: ReadWideString
CStdStringW DocReader::ReadWideString(int iOffset, int iCharCount)
{
CStdStringW sResult;
ReadIntoBufferIgnoringBitsInDeletedList(iOffset, iCharCount*2, sResult.GetBuffer(iCharCount + 1), iCharCount*2 + 2);
sResult.ReleaseBuffer();
return sResult;
}
示例6: UpdateLabel
void CGUIDialogKeyboardGeneric::UpdateLabel() // FIXME seems to be called twice for one USB SDL keyboard action/character
{
CGUILabelControl* pEdit = ((CGUILabelControl*)GetControl(CTL_LABEL_EDIT));
if (pEdit)
{
CStdStringW edit = m_strEdit;
if (m_hiddenInput)
{ // convert to *'s
edit.Empty();
if (m_lastRemoteClickTime + REMOTE_SMS_DELAY > CTimeUtils::GetFrameTime() && m_strEdit.size())
{ // using the remove to input, so display the last key input
edit.append(m_strEdit.size() - 1, L'*');
edit.append(1, m_strEdit[m_strEdit.size() - 1]);
}
else
edit.append(m_strEdit.size(), L'*');
}
// convert back to utf8
CStdString utf8Edit;
g_charsetConverter.wToUTF8(edit, utf8Edit);
pEdit->SetLabel(utf8Edit);
// Send off a search message
unsigned int now = CTimeUtils::GetFrameTime();
// don't send until the REMOTE_SMS_DELAY has passed
if (m_lastRemoteClickTime && m_lastRemoteClickTime + REMOTE_SMS_DELAY >= now)
return;
if (m_pCharCallback)
m_pCharCallback(this, utf8Edit);
}
}
示例7: GetFileName
bool Win32DllLoader::Load()
{
if (m_dllHandle != NULL)
return true;
CStdString strFileName = GetFileName();
CLog::Log(LOGDEBUG, "%s(%s)\n", __FUNCTION__, strFileName.c_str());
CStdStringW strDllW;
g_charsetConverter.utf8ToW(_P(strFileName), strDllW);
m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (!m_dllHandle)
{
CLog::Log(LOGERROR, "%s: Unable to load %s (%d)", __FUNCTION__, strFileName.c_str(), GetLastError());
return false;
}
// handle functions that the dll imports
if (NeedsHooking(strFileName.c_str()))
OverrideImports(strFileName);
else
bIsSystemDll = true;
return true;
}
示例8: EnumWindowsProc
//EnumWindows handler
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lparam)
{
try
{
CMWDiscovery* mwd = reinterpret_cast<CMWDiscovery*>(lparam);
IAccessiblePtr pAccessibleObject;
HRESULT hr = ::AccessibleObjectFromWindow( hwnd, OBJID_WINDOW, __uuidof(IAccessible), (void**)&pAccessibleObject );
if( hr == S_OK )
{
if( pAccessibleObject )
{
_bstr_t bsName;
VARIANT varChild;
varChild.vt = VT_I4;
varChild.lVal = CHILDID_SELF;
if (SUCCEEDED(pAccessibleObject->get_accName(varChild, bsName.GetAddress())))
{
CStdStringW name = bsName;
CStdString::size_type iFind = name.rfind(mwd->m_name);
if(iFind != CStdString::npos )
{
mwd->m_hwnd = hwnd;
return false;
}
}
}
}
}
catch(...)
{ //don't want this to stop the handler
LOG_WS_ERROR(_T("Exception during EnumWindows"));
}
return true;
}
示例9: GetString
_bstr_t GetString(const OcText& value)
{
if(!value.getBuffer() || (1 > value.getCharacterCount()))
return _T("");
switch(value.getCharacterEncoding())
{
case ENCODING_NONE:
{
CStdString val((const TCHAR*)value.getBuffer());
val.Trim();
val.ReleaseBuffer();
return val.c_str();
}
case ENCODING_UTF16:
{
CStdStringW wideVal((const wchar_t*)value.getBuffer());
wideVal.Trim();
wideVal.ReleaseBuffer();
return wideVal.c_str();
}
default:
{
CStdStringA multiByteVal((LPSTR)value.getBuffer());
multiByteVal.ReleaseBuffer();
CStdStringW wideVal = MultiByteSupport::ACPToWide(multiByteVal);
return wideVal.c_str();
}
}
}
示例10: subtitleCharsetToW
void CCharsetConverter::subtitleCharsetToW(const CStdStringA& strSource, CStdStringW& strDest)
{
CStdStringA strFlipped;
// No need to flip hebrew/arabic as mplayer does the flipping
if (m_iconvSubtitleCharsetToW == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetSubtitleCharSet();
m_iconvSubtitleCharsetToW = iconv_open(WCHAR_CHARSET, strCharset.c_str());
}
if (m_iconvSubtitleCharsetToW != (iconv_t) - 1)
{
const char* src = strSource.c_str();
size_t inBytes = strSource.length() + 1;
char *dst = (char*)strDest.GetBuffer(inBytes * sizeof(wchar_t));
size_t outBytes = inBytes * sizeof(wchar_t);
if (iconv_const(m_iconvSubtitleCharsetToW, &src, &inBytes, &dst, &outBytes))
{
strDest.ReleaseBuffer();
// For some reason it failed (maybe wrong charset?). Nothing to do but
// return the original..
strDest = strSource;
}
strDest.ReleaseBuffer();
}
}
示例11: sizeof
void CCharsetConverter::utf16BEtoUTF8(const CStdStringW& strSource, CStdStringA &strDest)
{
if (m_iconvUtf16BEtoUtf8 == (iconv_t) - 1)
m_iconvUtf16BEtoUtf8 = iconv_open("UTF-8", "UTF-16BE");
if (m_iconvUtf16BEtoUtf8 != (iconv_t) - 1)
{
size_t inBytes = (strSource.length() + 1) * sizeof(wchar_t);
size_t outBytes = (strSource.length() + 1) * 4;
const char *src = (const char*) strSource.c_str();
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16BEtoUtf8, &src, &inBytes, &dst, &outBytes))
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
if (iconv(m_iconvUtf16BEtoUtf8, NULL, NULL, &dst, &outBytes))
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例12: m_function
PerformanceMonitor::PerformanceMonitor(const wchar_t* function) :
m_function(function)
{
try
{
if(PerformanceMonitor::m_timer == PerformanceMonitor::UnknownTimer)
{
DetermineTimer();
PerformanceMonitor::m_enableLogging = IsLoggingSystemEnabled();
}
if(!PerformanceMonitor::m_enableLogging)
return;
if(PerformanceMonitor::m_timer == PerformanceMonitor::HighResolutionTimer)
QueryPerformanceCounter(&m_start);
else
m_startClock = clock();
CStdStringW sFunction;
sFunction.Format(_T("Starting %s"), m_function.c_str());
LOG_WS_INFO(sFunction.c_str());
}
catch(...)
{
}
}
示例13: GetFileName
bool Win32DllLoader::Load()
{
if (m_dllHandle != NULL)
return true;
CStdString strFileName = GetFileName();
CStdStringW strDllW;
g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strFileName), strDllW);
m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (!m_dllHandle)
{
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, 0, (LPTSTR) &lpMsgBuf, 0, NULL );
CLog::Log(LOGERROR, "%s: Failed to load %s with error %d:%s", __FUNCTION__, CSpecialProtocol::TranslatePath(strFileName).c_str(), dw, lpMsgBuf);
LocalFree(lpMsgBuf);
return false;
}
// handle functions that the dll imports
if (NeedsHooking(strFileName.c_str()))
OverrideImports(strFileName);
else
bIsSystemDll = true;
return true;
}
示例14: dllFindFirstFileA
extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
{
char* p = strdup(lpFileName);
CORRECT_SEP_STR(p);
// change default \\*.* into \\* which the xbox is using
char* e = strrchr(p, '.');
if (e != NULL && strlen(e) > 1 && e[1] == '*')
{
e[0] = '\0';
}
#ifdef TARGET_WINDOWS
struct _WIN32_FIND_DATAW FindFileDataW;
CStdStringW strwfile;
g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(p), strwfile, false);
HANDLE res = FindFirstFileW(strwfile.c_str(), &FindFileDataW);
if (res != INVALID_HANDLE_VALUE)
to_WIN32_FIND_DATA(&FindFileDataW, lpFindFileData);
#else
HANDLE res = FindFirstFile(CSpecialProtocol::TranslatePath(p).c_str(), lpFindFileData);
#endif
free(p);
return res;
}
示例15: while
void CKeyboardLayoutConfiguration::readByteMapFromXML(const TiXmlElement* pXMLMap, map<BYTE, WCHAR>& charToCharMap, const char* mapRootElement)
{
if (pXMLMap && !pXMLMap->NoChildren())
{ // map keys
const TiXmlElement* pEntry = pXMLMap->FirstChildElement();
while (pEntry)
{
CStdString strInHex = XMLUtils::GetAttribute(pEntry, "inhex");
CStdString strOutChar = XMLUtils::GetAttribute(pEntry, "outchar");
if (!strInHex.empty() && !strOutChar.empty())
{
CStdString hexValue = strInHex;
CStdStringW toStr;
g_charsetConverter.utf8ToW(strOutChar, toStr);
int from;
if (sscanf(hexValue.c_str(), "%x", (unsigned int *)&from))
{
if (from != 0) // eats nearly any typing error as 0: catch it:
{
if (from < 256)
{
if (toStr.size()==1)
{
charToCharMap.insert(pair<BYTE, WCHAR>(from, toStr[0]));
CLog::Log(LOGDEBUG, "insert map entry from %d to %c ", from, toStr[0]);
}
else
{
CLog::Log(LOGERROR, "String to %ls does not have the expected length of >=1", toStr.c_str());
}
}
else
{
CLog::Log(LOGERROR, "From value %d was greater than 255! ", from);
}
}
else
{
CLog::Log(LOGERROR, "Scanned from-value %d as 0 probably a (typing?) error! ", from);
}
}
else
{
CLog::Log(LOGERROR, "Could not scan from-value %s (was no valid hex value) ", hexValue.c_str());
}
}
else
{
CLog::Log(LOGERROR, "map entry misses attribute <inhex> or <outchar> or content of them");
}
pEntry = pEntry->NextSiblingElement();
}
}
else
{
CLog::Log(LOGERROR, "XML-Configuration doesn't contain expected map root element %s", mapRootElement);
}
}