本文整理汇总了C++中wstring::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::assign方法的具体用法?C++ wstring::assign怎么用?C++ wstring::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wstring
的用法示例。
在下文中一共展示了wstring::assign方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* Converts a descriptor of type HBufc16 to Wstring
*
* @param aSrc is the descriptor to be converted , aDes is the
* reference to the Wstring array where the result of conversion
* is stored
* @return Status code (0 is ESuccess, -1 is EInsufficientMemory,
* -4 is EInvalidPointer , -5 is EDescriptorNoData)
*/
EXPORT_C int Hbufc16ToWstring(HBufC16* aSrc, wstring& aDes)
{
unsigned int ilen = 0;
if (!aSrc)
{
return EInvalidPointer;
}
else
{
ilen = aSrc->Length();
if (0 == ilen )
{
return EDescriptorNoData;
}
}
wchar_t* wcharString = new wchar_t[ilen+1];
if (!wcharString)
{
return EInsufficientSystemMemory;
}
wmemcpy((wchar_t*)wcharString, (const wchar_t*)aSrc->Ptr(), ilen);
wcharString[ilen] = L'\0';
aDes.assign(wcharString);
delete []wcharString;
return ESuccess;
}
示例2: sizeof
// Load a string from the registry
//
bool
WebCam::LoadSetting(const WCHAR* name, wstring& value)
{
HKEY hkey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, sRegKey.c_str(), 0, KEY_EXECUTE, &hkey)
!= ERROR_SUCCESS)
return false;
// Determine length of string
//
TCHAR szValue[8193];
DWORD keysize = sizeof(szValue);
LONG l = RegQueryValueEx(hkey, name, NULL, NULL,
reinterpret_cast<BYTE*>(szValue),
&keysize);
RegCloseKey(hkey);
if (ERROR_SUCCESS != l)
return false;
if (keysize < sizeof(TCHAR))
return false;
value.assign(szValue, keysize/sizeof(TCHAR) - 1);
return true;
}
示例3: HandleToString
OSErr HandleToString(const Handle h, wstring & outString)
{
OSErr error = kNoErr;
const wstring sEmptyWString;
outString = sEmptyWString;
int32 s = sPSHandle->GetSize(h);
if (s > 0)
{
Boolean oldLock = FALSE;
uint16 * p = NULL;
sPSHandle->SetLock(h, true, reinterpret_cast<char**>(&p), &oldLock);
if (p != NULL)
{
outString.assign(p, p + ( s / sizeof(uint16) ));
sPSHandle->SetLock(h, false, reinterpret_cast<char**>(&p), &oldLock);
}
else
{
error = errPlugInHostInsufficient;
}
}
else
{
error = errPlugInHostInsufficient;
}
return error;
}
示例4: TryGetRegistryValue
bool winRegistry::TryGetRegistryValue(HKEY hkeyParent, const wstring& path, const wstring& valueName, wstring& value)
{
DWORD valueType;
if (!TryGetRegistryValue(hkeyParent, path, valueName, value, valueType))
{
return false;
}
if (valueType == REG_EXPAND_SZ)
{
DWORD n = ExpandEnvironmentStringsW(value.c_str(), nullptr, 0);
if (n == 0)
{
MIKTEX_FATAL_WINDOWS_ERROR_2("ExpandEnvironmentStringsW", "str", WU_(path));
}
vector<wchar_t> buf;
buf.reserve(n);
DWORD n2 = ExpandEnvironmentStringsW(value.c_str(), buf.data(), n);
if (n2 == 0)
{
MIKTEX_FATAL_WINDOWS_ERROR_2("ExpandEnvironmentStringsW", "str", WU_(path));
}
MIKTEX_ASSERT(n2 == n);
value.assign(buf.data(), n2);
}
return true;
}
示例5: input_dlg
bool input_dlg(const GUID& id, const wstring& title, const wstring& msg, wstring& text, INPUTBOXFLAGS flags) {
Buffer<wchar_t> buf(1024);
if (g_far.InputBox(&c_plugin_guid, &id, title.c_str(), msg.c_str(), nullptr, text.c_str(), buf.data(), static_cast<int>(buf.size()), nullptr, flags)) {
text.assign(buf.data());
return true;
}
return false;
}
示例6: ConvertRawBytesToWideString
bool WONCommon::ConvertRawBytesToWideString(const WONCommon::RawBuffer& theRawBytes, wstring& theStringR)
{
if(theRawBytes.length() % 2)
return false;
theStringR.assign(reinterpret_cast<const wchar_t*>(theRawBytes.data()), theRawBytes.length()/2);
makeLittleEndianWString(theStringR);
return true;
}
示例7: get_volume_guid_path
bool get_volume_guid_path( const wstring& volume_mount_point, wstring& volume_guid_path ) {
unsigned buf_size = MAX_PATH;
unique_ptr<wchar_t[ ]> buffer( new wchar_t[ buf_size ] );
if ( !::GetVolumeNameForVolumeMountPointW( add_trailing_slash( volume_mount_point ).c_str( ), buffer.get( ), buf_size ) ) {
return false;
}
volume_guid_path.assign( buffer.get( ) );
return true;
}
示例8: split_next
static int split_next(const wstring &src, wstring &des, char ch, int start){
int pos = 0;
pos = src.find(ch, start);
des.clear();
if(pos < start){
pos = src.length();
}
if(pos > start){
des.assign(src, start, pos - start);
}
return pos;
}
示例9: StrToWstr
//---------------------------------------------------------------------
void StrToWstr(const char* str, wstring& dstr)
{
CryStackStringT<wchar_t, 64> tmp;
tmp.resize(strlen(str));
tmp.clear();
while (const wchar_t c=(wchar_t)(*str++))
{
tmp.append(1, c);
}
dstr.assign(tmp.data(), tmp.length());
}
示例10: get_device_path
bool get_device_path( const wstring& volume_guid_path, wstring& volume_dev_path ) {
const wstring c_prefix( L"\\\\?\\" );
if ( volume_guid_path.size( ) < c_prefix.size( ) || volume_guid_path.substr( 0, c_prefix.size( ) ) != c_prefix ) {
return false;
}
unsigned buf_size = MAX_PATH;
unique_ptr<wchar_t[ ]> buffer( new wchar_t[ buf_size ] );
SetLastError( NO_ERROR );
DWORD len = QueryDosDeviceW( del_trailing_slash( volume_guid_path ).substr( 4 ).c_str( ), buffer.get( ), buf_size );
if ( len == 0 || GetLastError( ) != NO_ERROR ) {
return false;
}
volume_dev_path.assign( buffer.get( ) );
return true;
}
示例11: getPluginDirectory
DWORD getPluginDirectory(wstring& directory)
{
DWORD result;
HINSTANCE hinst = (HINSTANCE)GetModuleHandleW(PLUGIN_NAME L".dll");
wchar_t* p;
wchar_t buffer[TEXTLEN] = {0};
result = GetModuleFileNameW(hinst, buffer, TEXTLEN);
p = wcsrchr(buffer, '\\');
if (p)
{
*p = '\0';
directory.assign(buffer);
return 1;
}
else
return 0;
}
示例12: query_str_nt
bool Key::query_str_nt(wstring& value, const wchar_t* name) {
DWORD type = REG_SZ;
DWORD data_size;
LONG res = RegQueryValueExW(h_key, name, nullptr, &type, nullptr, &data_size);
if (res != ERROR_SUCCESS) {
SetLastError(res);
return false;
}
Buffer<wchar_t> buf(data_size / sizeof(wchar_t));
res = RegQueryValueExW(h_key, name, nullptr, &type, reinterpret_cast<LPBYTE>(buf.data()), &data_size);
if (res != ERROR_SUCCESS) {
SetLastError(res);
return false;
}
value.assign(buf.data(), buf.size() - 1);
return true;
}