Exemplo n.º 1
0
	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;
	}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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);
}
Exemplo n.º 5
0
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
}
Exemplo n.º 6
0
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());
		}
	}
}
// 文件校验
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;

}
Exemplo n.º 8
0
	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);
	}
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
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
std::wstring CWXConver::s2ws(const std::string str)   
{   
    wchar_t* pw = CWXConver::Char2WChar(str.c_str());   
    std::wstring wstr(pw);   
    delete[] pw;   
    return wstr;   
}   
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
// 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;
		}
	}
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
	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;
	}
Exemplo n.º 16
0
std::string Func_lcase::getStrVal(rowgroup::Row& row,
						FunctionParm& fp,
						bool& isNull,
						execplan::CalpontSystemCatalog::ColType&)
{
//	string str = fp[0]->data()->getStrVal(row, isNull);

//	transform (str.begin(), str.end(), str.begin(), to_lower());

	const string& tstr = fp[0]->data()->getStrVal(row, isNull);
	if (isNull)
		return "";

	size_t strwclen = utf8::idb_mbstowcs(0, tstr.c_str(), 0) + 1;
	wchar_t* wcbuf = (wchar_t*)alloca(strwclen * sizeof(wchar_t));
	strwclen = utf8::idb_mbstowcs(wcbuf, tstr.c_str(), strwclen);
	wstring wstr(wcbuf, strwclen);

	for (uint i = 0; i < strwclen; i++)
		wstr[i] = std::towlower(wstr[i]);

	size_t strmblen = utf8::idb_wcstombs(0, wstr.c_str(), 0) + 1;
	char* outbuf = (char*)alloca(strmblen * sizeof(char));
	strmblen = utf8::idb_wcstombs(outbuf, wstr.c_str(), strmblen);
	return string(outbuf, strmblen);
}							
Exemplo n.º 17
0
/**
@SYMTestCaseID          PDS-STORE-CT-4016
@SYMTestCaseDesc	    Tests for CPBEncryptElement
@SYMTestPriority 	    High
@SYMTestActions  	    Externalizing and internalizing CPBEncryptionData. Tests for constructors.
@SYMTestExpectedResults Externalizing must not fail. After internalization CPBEncryptionData object should
						be valid. Object created with all constructors should be valid.
@SYMDEF                 DEF135804
*/
LOCAL_C void testForgottenAPI_L()
	{
	test.Next(_L("@SYMTestCaseID PDS-STORE-CT-4016: Tests for CPBEncryptElement"));
	CBufFlat* buffer = CBufFlat::NewL(10*1024);
	CleanupStack::PushL(buffer);
	RBufWriteStream wstr(*buffer,0);
	
	CPBEncryptElement* elementKey = CPBEncryptElement::NewLC(KTestPassword);
    const CPBEncryptionData& encryptData = elementKey->EncryptionData();    
    wstr << encryptData;
    CleanupStack::PopAndDestroy();
	
	wstr.CommitL();
	wstr.Close();
	
	RBufReadStream rstr(*buffer,0);
	CPBEncryptionData* enData = CPBEncryptionData::NewL(rstr);
	test(enData != NULL);
	delete enData;
	enData = NULL;
	rstr.Close();
	rstr.Open(*buffer,0);
	enData = CPBEncryptionData::NewLC(rstr);
	test(enData != NULL);
	CleanupStack::PopAndDestroy();
	enData = NULL;
	
	rstr.Close();
	
	CleanupStack::PopAndDestroy();
	}
void Valid() {
  std::string empty();
  std::string str(4, 'x');
  std::wstring wstr(4, L'x');
  std::string s1("test", 4);
  std::string s2("test", 3);
}
Exemplo n.º 19
0
// string → wstring
inline std::wstring to_wstr(const std::string& astr)
{
	setlocale(LC_ALL, "japanese");
	std::wstring wstr(mbstowcs(0, astr.c_str(), 0) + 1, 0);
	mbstowcs(&wstr[0], astr.c_str(), wstr.size());

	return wstr;
}
void CFindItemDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	OnOK();
	std::wstring wstr(m_KeywordStringValue);
	CSettingsSM::GetInstance()->SetUserString(wstr);
	
}
Exemplo n.º 21
0
//string을 wstring으로
std::wstring CCharacter::string2wstring(std::string str) {

	std::wstring wstr(str.length(),L' ');

	copy(str.begin(),str.end(),wstr.begin());

	return wstr;

}
Exemplo n.º 22
0
	inline FileSystem::FileType	GetFileType(const std::string& path)
	{
		std::wstring	wstr(path.begin(), path.end());
		unsigned long attribute = GetFileAttributesW(wstr.c_str());
		FileSystem::FileType type = FileSystem::FileType::INVALID;
		if (attribute == INVALID_FILE_ATTRIBUTES)
			return type;
		type = (!(attribute & FILE_ATTRIBUTE_DIRECTORY)) ? (FileSystem::FileType::REGULAR) : (FileSystem::FileType::DIRECTORY);
		return (type);
	}
Exemplo n.º 23
0
TEST(StringTests, TrimSingleWordTest)
{
    std::string str("foo");
    str = dhorn::trim(str);
    ASSERT_TRUE(str == "foo");

    std::wstring wstr(L"foo");
    wstr = dhorn::trim(wstr);
    ASSERT_TRUE(wstr == L"foo");
}
Exemplo n.º 24
0
TEST(StringTests, TrimTrailingWhitespaceTest)
{
    std::string str("foo   \t\n");
    str = dhorn::trim(str);
    ASSERT_TRUE(str == "foo");

    std::wstring wstr(L"foo   \t\n");
    wstr = dhorn::trim(wstr);
    ASSERT_TRUE(wstr == L"foo");
}
Exemplo n.º 25
0
TEST(StringTests, TrimSentenceTest)
{
    std::string str("foo bar");
    str = dhorn::trim(str);
    ASSERT_TRUE(str == "foo bar");

    std::wstring wstr(L"foo bar");
    wstr = dhorn::trim(wstr);
    ASSERT_TRUE(wstr == L"foo bar");
}
Exemplo n.º 26
0
void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent,
					 const LLFontGL &font,
					 const U8 style,
					 const F32 x_offset, const F32 y_offset,
					 const LLColor4& color,
					 const BOOL orthographic)
{
	LLWString wstr(utf8str_to_wstring(str));
	hud_render_text(wstr, pos_agent, font, style, x_offset, y_offset, color, orthographic);
}
Exemplo n.º 27
0
/**
 * Removes a file from the specified path.
 * @param path Full path to file.
 * @return True if the operation succeeded, False otherwise.
 */
bool deleteFile(const std::string &path)
{
#ifdef _WIN32
	int size = MultiByteToWideChar(CP_UTF8, 0, &path[0], (int)path.size(), NULL, 0);
    std::wstring wstr(size, 0);
    MultiByteToWideChar(CP_UTF8, 0, &path[0], (int)path.size(), &wstr[0], size);
	return (DeleteFileW(wstr.c_str()) != 0);
#else
	return (remove(path.c_str()) != 0);
#endif
}
Exemplo n.º 28
0
void LoadString (CString &Str, UINT id)
{
    TCHAR szString[ 256 ];
    GetString (szString, id);
#ifdef UNICODE
    CString wstr(szString);
    Str = wstr;
#else
    Str = szString;
#endif
}
Exemplo n.º 29
0
		/// <summary>Converts a null terminated wchar_t string to UTF-8.</summary>
		/// <param name="str">null-terminated wchar_t string</param>
		/// <return>null-terminated UTF-8 encoded char*.  If str is null, an empty std::string will be returned.</return>
		std::string convert_to_utf8(const wchar_t* str)
		{
			// return an empty string for the null or empty case.
			if ((str == nullptr) || (wcslen(str) == 0)) { return std::string(); }
			
			std::wstring wstr(str);
			std::wstring_convert<std::codecvt_utf8<wchar_t> > to_utf8;
			std::string utf8_str = to_utf8.to_bytes(wstr);
			
			return utf8_str;
		}
void DPTextBox::m_SetText(std::string str)
{
	std::wstring wstr(str.begin(), str.end());
	m_String.SetString(wstr.c_str());
	m_bTextSet = true;
	if(m_bCreate)
	{
		SetWindowText((LPCTSTR)wstr.c_str());
		UpdateData();
		
	}
}