本文整理汇总了C++中wstr函数的典型用法代码示例。如果您正苦于以下问题:C++ wstr函数的具体用法?C++ wstr怎么用?C++ wstr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wstr
bool OpenFileConnection::OnPoke(const wxString & topic, const wxString & item, const void * data, size_t size, wxIPCFormat format)
{
const char* cData = reinterpret_cast<const char*>(data);
std::string wstr(cData, cData + size);
HandleOpenFile(wstr);
return true;
}
示例2: search_solution
bool search_solution( const TCHAR* dirpath , bool bRecursive = true )
{
WIN32_FIND_DATA fd;
HANDLE hFind = INVALID_HANDLE_VALUE;
wstring dirspec( dirpath );
dirspec += L"\\*";
hFind = FindFirstFile( dirspec.c_str(), &fd);
if (INVALID_HANDLE_VALUE == hFind) {
return false;
}
do {
if ( fd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY && bRecursive )
{
if ( _tcscmp(fd.cFileName, L".")
&& _tcscmp(fd.cFileName, L"..")
&& _tcscmp(fd.cFileName, L".svn")
&& _tcscmp(fd.cFileName, L".git")
)
{
TCHAR curpath[MAX_PATH];
ZeroMemory( curpath , sizeof( curpath ) );
_stprintf_s( curpath , L"%s\\%s" , dirpath , fd.cFileName );
search_solution( curpath , bRecursive );
}
}
else if ( fd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY )
{
wstring wstr( fd.cFileName );
size_t pos = wstr.find( L"." );
if ( pos > 0 )
{
TCHAR curpath[MAX_PATH];
ZeroMemory( curpath , sizeof( curpath ) );
_stprintf_s( curpath , L"%s\\%s" , dirpath , fd.cFileName );
wstring wfilepath( curpath );
for_each( wstr.begin() , wstr.end() , ToLower() );
size_t poscomma = wstr.rfind( L"." );
wstring ext = wstr.substr( poscomma + 1 , wstr.length() );
if ( ext == L"vcxproj")
{
project_info_table info;
info.project_dir_path = wstring(dirpath) + L"\\";
info.project_file_path = wfilepath;
g_all_project_info.push_back( info );
}
}
}
} while (FindNextFile(hFind, &fd));
DWORD err = GetLastError();
FindClose(hFind);
return true;
}
示例3: setlocale
std::string strconv::w2a(std::wstring str)
{
if(!bSetLocale)
{
setlocale (LC_ALL,"");
bSetLocale = true;
}
size_t nmax = 0;
#ifdef _WIN32
wcstombs_s(&nmax, NULL, 0, str.c_str(), 0);
#else
nmax = wcstombs(NULL, str.c_str(), 0);
#endif
if(nmax==0 || nmax==(size_t)(-1))
return "";
char* buf = new char[nmax+1];
if(buf==NULL)
return "";
size_t count = 0;
#ifdef _WIN32
wcstombs_s(&count, buf, nmax, str.c_str(), nmax+1);
#else
wcstombs(buf, str.c_str(), nmax+1);
#endif
buf[nmax] = 0; // ensure buffer is zero terminated
std::string wstr(buf);
delete [] buf;
return wstr;
}
示例4: switch
FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
FX_DWORD dwEventID = pEvent->GetClassID();
switch (dwEventID) {
case FWL_EVTHASH_EDT_TextChanged: {
CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent;
CFX_WideString wsChange;
OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText);
break;
}
case FWL_EVTHASH_EDT_AddDoRecord: {
OnAddDoRecord(m_pNormalWidget->GetWidget());
break;
}
case FWL_EVTHASH_EDT_TextFull: {
OnTextFull(m_pNormalWidget->GetWidget());
break;
}
case FWL_EVTHASH_EDT_CheckWord: {
CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged");
CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent;
event->bCheckWord = CheckWord(event->bsWord);
break;
}
case FWL_EVTHASH_EDT_GetSuggestWords: {
CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent;
event->bSuggestWords =
GetSuggestWords(event->bsWord, event->bsArraySuggestWords);
break;
}
default: {}
}
return m_pOldDelegate->OnProcessEvent(pEvent);
}
示例5: MultiByteToWideChar
std::wstring strconv::utf82w(std::string str)
{
#ifdef _WIN32
// Calculate required buffer size
int count = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
if(count==0)
{
return NULL;
}
// Convert UNICODE->UTF8
LPWSTR buf = new wchar_t[count];
int result = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, (LPWSTR)buf, count);
if(result==0)
{
delete [] buf;
return NULL;
}
std::wstring wstr(buf);
delete [] buf;
return wstr;
#else
// On Linux do multibyte->widechar conversion.
return a2w(str);
#endif
}
示例6: stream
void MtlParser::ParseMtl(GpuApi *gpu, const char *text)
{
std::stringstream stream(text);
std::string line;
while (std::getline(stream,line,'\n'))
{
int pos = -1;
if ((pos = line.find("newmtl ")) > -1)
{
WavefrontMtl mtl;
line = line.substr(pos + strlen("newmtl "));
line.erase(line.find_first_of("#"));
line.erase(line.find_last_not_of(" \n\r\t")+1);
mtl.name = line;
materials.emplace_back(mtl);
}
if ((pos = line.find("map_Kd ")) > -1)
{
WavefrontMtl &mtl = materials[materials.size() - 1];
line = line.substr(pos + strlen("map_Kd "));
line.erase(line.find_first_of("#"));
line.erase(line.find_last_not_of(" \n\r\t")+1);
std::wstring wstr(line.begin(),line.end());
mtl.tex = gpu->CreateGpuTextureFromFile(wstr.c_str());
}
}
}
示例7: str
// 文件校验
bool CDownloadAndSetupThread::CheckDownLoadFile(LPCTSTR lpPath)
{
//std::list<std::wstring>::const_iterator it;
//for(it = UrlList.begin (); it != UrlList.end (); it ++)
{
#ifdef _UNICODE
CStringW str(lpPath);
if(!BankMdrVerifier::VerifyModule(str) )
{
return false;
}
#else
#error "why use ansi???"
USES_CONVERSION;
std::wstring wstr(CT2W(m_vecLocalFiles[j].c_str()));
CStringW str = wstring.c_str();
if(!BankMdrVerifier::VerifyModule(str) )
{
return false;
}
#endif
}
return true;
}
示例8: locker
void Font::print(float x, float y, float z, const String& text)
{
if (text.empty())
return;
MutexLocker locker(pMutex);
if (!font)
return;
glScalef(1.0f, -1.0f, 1.0f);
for(int k = 0 ; k < (bBold ? 3 : 1) ; ++k)
{
#ifdef __FTGL__lower__
font->Render( text.c_str(), -1,
FTPoint(x, -(y + 0.5f * (-font->Descender() + font->Ascender())), z),
FTPoint(), FTGL::RENDER_ALL);
#else
glPushMatrix();
glTranslatef( x, -(y + 0.5f * (-font->Descender() + font->Ascender())), z );
# ifndef TA3D_PLATFORM_DARWIN
WString wstr(text);
font->Render(wstr.cw_str());
# else
font->Render(text.c_str());
# endif
glPopMatrix();
#endif
}
glScalef(1.0f, -1.0f, 1.0f);
}
示例9: Test
void Test() {
std::string str('x', 4);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
std::wstring wstr(L'x', 4);
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
std::string s0(0, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
std::string s1(-4, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
std::string s2(0x1000000, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
std::string q0("test", 0);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
std::string q1(kText, -4);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
std::string q2("test", 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q3(kText, 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q4(kText2, 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q5(kText3, 0x1000000);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
}
示例10: ToWideString
std::wstring ToWideString(const std::string& str)
{
int stringLength = MultiByteToWideChar(CP_ACP, 0, str.data(), str.length(), 0, 0);
std::wstring wstr(stringLength, 0);
MultiByteToWideChar(CP_ACP, 0, str.data(), str.length(), &wstr[0], stringLength);
return wstr;
}
示例11: wstr
std::wstring CWXConver::s2ws(const std::string str)
{
wchar_t* pw = CWXConver::Char2WChar(str.c_str());
std::wstring wstr(pw);
delete[] pw;
return wstr;
}
示例12: SendMessageW
std::string ListBox::getSelectedItem() {
wchar_t s[255];
SendMessageW(instance, LB_GETTEXT,(WPARAM)getSelectedItemIndex(),(LPARAM)s);
std::wstring wstr(s);
std::string str(wstr.begin(),wstr.end());
return str;
}
示例13: str
// static
void LLFloaterProperties::onClickCopy(void* user_data)
{
LLFloaterProperties* floaterp = (LLFloaterProperties*)user_data;
if(floaterp)
{
LLViewerInventoryItem* item = (LLViewerInventoryItem*)floaterp->findItem();
if(item)
{
std::string str(floaterp->childGetValue("item_text").asString());
std::string::size_type pos;
while((pos = str.find(" ")) != std::string::npos)
{
str.replace(pos, 4, "\t");
}
std::istringstream strm(str);
LLViewerInventoryItem* temp = new LLViewerInventoryItem();
temp->importLegacyStream(strm);
std::ostringstream strm2;
temp->exportLegacyStream(strm2, TRUE);
LLWString wstr(utf8str_to_wstring(strm2.str()));
gClipboard.copyFromSubstring(wstr, 0, wstr.length());
//delete temp;
}
}
}
示例14: wstr
std::wstring CMapiWrapper::str_to_wstr(const std::string &str)
{
std::wstring wstr(str.length() + 1, 0);
MultiByteToWideChar(CP_ACP, 0, str.c_str(), (int)str.length(), &wstr[0], (int)str.length());
return wstr;
}
示例15: WindowsMake
static bool WindowsMake(const AnyString& path)
{
String norm;
Yuni::IO::Normalize(norm, path);
Private::WString<true> wstr(norm);
if (wstr.size() < 4)
return false;
wchar_t* t = wstr.c_str() + 4;
while (*t != L'\0')
{
if ((*t == L'\\' or *t == L'/') and (*(t-1) != ':'))
{
*t = L'\0';
if (!CreateDirectoryW(wstr.c_str(), nullptr))
{
if (GetLastError() != ERROR_ALREADY_EXISTS)
return false;
}
*t = L'\\';
}
++t;
}
if (not CreateDirectoryW(wstr.c_str(), nullptr))
{
if (GetLastError() != ERROR_ALREADY_EXISTS)
return false;
}
return true;
}