本文整理汇总了C++中WString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::c_str方法的具体用法?C++ WString::c_str怎么用?C++ WString::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WString
的用法示例。
在下文中一共展示了WString::c_str方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadAccount_
AccountInterfacePtr AccountManager::loadAccount_( const WString& _accountID )
{
AccountInterfacePtr account = this->newAccount_( _accountID );
if( account == nullptr )
{
LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccount_ invalid create account %ls"
, _accountID.c_str()
);
return nullptr;
}
if( m_accountProvider != nullptr )
{
m_currentAccount = account;
m_accountProvider->onCreateAccount( _accountID );
m_currentAccount = nullptr;
}
if( account->load() == false )
{
LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccount_ invalid load account %ls"
, _accountID.c_str()
);
return nullptr;
}
return account;
}
示例2: Utf16ToUtf8
// Functions from x64dbg project: https://github.com/x64dbg/x64dbg
//Conversion functions taken from: http://www.nubaria.com/en/blog/?p=289
String Utf16ToUtf8(const WString & wstr)
{
String convertedString;
int requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0);
if(requiredSize > 0)
{
std::vector<char> buffer(requiredSize);
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], requiredSize, 0, 0);
convertedString.assign(buffer.begin(), buffer.end() - 1);
}
return convertedString;
}
示例3: Load
void Load()
{
String name = mName;
if (name.substr(name.length() - 4, 4) != ".dll")
name += ".dll";
WString wname = StringToWString(name);
m_hInst = (HINSTANCE)LoadLibraryEx(wname.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH );
if (!m_hInst)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
fprintf(stderr, "%s\n", (char*)lpMsgBuf);
// Free the buffer.
LocalFree( lpMsgBuf );
String error = "Load " + name + " failed!";
ENGINE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, error, "DynLib::Load");
}
}
示例4: create
//---------------------------------------------------------------------
Ogre::DataStreamPtr UnicodeFileSystemArchive::create(const String& _filename) const
{
if (isReadOnly())
{
GOTHOGRE_EXCEPT(_filename << " - Cannot create a file in"
<< " read-only archive " << getName() << ".");
}
WString wfullpath = getFullPath(_filename);
// Always open in binary mode
// Also, always include reading
std::ios::openmode mode = std::ios::out | std::ios::binary;
std::fstream* rwStream = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
rwStream->open(wfullpath.c_str(), mode);
// Should check ensure open succeeded, in case fail for some reason.
if (rwStream->fail())
{
OGRE_DELETE_T(rwStream, basic_fstream, MEMCATEGORY_GENERAL);
GOTHOGRE_EXCEPT(_filename << " - Cannot create file in"
<< " archive " << getName() << ".");
}
GOTHOGRE_INFO(_filename << " - " << "Saving to"
<< " archive " << getName() << ".");
/// Construct return stream, tell it to delete on destroy
FileStreamDataStream* stream = OGRE_NEW FileStreamDataStream(_filename,
rwStream, 0, true);
return DataStreamPtr(stream);
}
示例5: if
std::string WideToUTF8(const WString &inWideString)
{
int len = 0;
const wchar_t *chars = inWideString.c_str();
for(int i=0;i<inWideString.length();i++)
{
int c = chars[i];
if( c <= 0x7F ) len++;
else if( c <= 0x7FF ) len+=2;
else if( c <= 0xFFFF ) len+=3;
else len+= 4;
}
std::string result;
result.resize(len);
unsigned char *data = (unsigned char *) &result[0];
for(int i=0;i<inWideString.length();i++)
{
int c = chars[i];
if( c <= 0x7F )
*data++ = c;
else if( c <= 0x7FF )
{
*data++ = 0xC0 | (c >> 6);
*data++ = 0x80 | (c & 63);
}
else if( c <= 0xFFFF )
示例6: setLogPath
winLog::winLog(bool resetLog, const char* path, const char* name) {
setLogPath(path);
setLogName(name);
// MUST use a wchar_t* logDir to manage correctly international chars.
// If using char* logDir and UTF-8, fopen() is not working correctly and
// will fail to open the log file. (with UTF-8... why?)
// So we use _wfopen() and a wchar_t* logDir.
StringBuffer logDir;
logDir.sprintf("%s\\%s", logPath.c_str(), logName.c_str());
WCHAR* tmp = toWideChar(logDir.c_str());
wlogDir = tmp;
delete [] tmp;
//
// Test to ensure the log file is writable (only if path is set)
//
if (path) {
logFile = _wfopen(wlogDir.c_str(), TEXT("a+"));
if (logFile == NULL) {
WCHAR tmp[512];
wsprintf(tmp, TEXT("Unable to write log file: \"%s\".\nPlease check your user's permissions."), wlogDir.c_str());
MessageBox(NULL, tmp, TEXT("Funambol"), MB_SETFOREGROUND | MB_OK);
}
else {
fclose(logFile);
if (resetLog) {
reset(FUNAMBOL_HEADER);
}
}
}
}
示例7: exception
AString Converter::Unicode2Utf8(const WString& widestring){
int utf8size = ::WideCharToMultiByte(CP_UTF8, 0, widestring.c_str(), -1, NULL, 0, NULL, NULL);
if (utf8size == 0) {
throw std::exception("Error in conversion.");
}
std::vector<char> resultstring(utf8size);
int convresult = ::WideCharToMultiByte(CP_UTF8, 0, widestring.c_str(), -1, &resultstring[0], utf8size, NULL, NULL);
if (convresult != utf8size) {
throw std::exception("La falla!");
}
return AString(&resultstring[0]);
}