本文整理汇总了C++中wstring::append方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::append方法的具体用法?C++ wstring::append怎么用?C++ wstring::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wstring
的用法示例。
在下文中一共展示了wstring::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentThreadId
filePathLinkW(const wstring& path) :m_ntType(L"\\??\\")
{
if (path.length() > 4 && path.substr(0, 4) == L"\\??\\")
{
m_ntType.append(path.substr(4));
}
else
{
m_ntType.append(path);
}
static DWORD tick = 0;
wchar_t tmpBuffer[100];
StringCbPrintfW(tmpBuffer, 100, L"%x%x%x%x", GetCurrentThreadId(), GetTickCount(), rand(), ++tick);
m_pathDefine = wstring(FS_BYPASS_DEFINE_PREFIX_W) + tmpBuffer;
if (DefineDosDeviceW(DDD_RAW_TARGET_PATH, m_pathDefine.c_str(), m_ntType.c_str()))
{
m_pathLink = wstring(L"\\\\.\\") + FS_BYPASS_DEFINE_PREFIX_W + tmpBuffer;
m_transformed = true;
}
else
{
m_pathLink = path;
m_transformed = false;
}
}
示例2: insertReplacedString
// See https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
// Some tricky test cases:
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$001"): "$001"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$01"): "a"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$10"): "j"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$15"): "a5"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$20"): "b0"
void insertReplacedString(wstring& builder, const wstring& base, const wstring& str, const RegExpMatch& match)
{
const vector<wstring>& substrings = match.substrings;
const wstring& mstr = substrings[0];
for (size_t i = 0; i < str.length(); i++)
{
if (str[i] == L'$' && str.length() > i + 1)
{
wchar_t ch = str[++i];
switch (ch)
{
case L'$': // insert a '$'
builder.push_back(ch);
break;
case L'&': // insert the matched string
builder.append(mstr);
break;
case L'`': // insert the portion preceding the matched string
builder.append(base.begin(), base.begin() + match.index);
break;
case L'\'': // insert the portion following the matched string
builder.append(base.begin() + match.index + mstr.length(), base.end());
break;
default:
if (ch >= L'0' && ch <= L'9')
{
int expidx = 0;
wchar_t ch2 = str.length() > i + 1 ? str[i + 1] : L'\0';
if (ch2 >= L'0' && ch2 <= L'9')
{
expidx = ch2 - L'0' + 10 * (ch - L'0');
// if expidx overflows, fall back to single-digit
if (expidx == 0 || expidx >= (int)substrings.size())
{
expidx = ch - L'0';
ch2 = 0;
}
}
else
{
ch2 = 0;
expidx = ch - L'0';
}
// substrings.size() is 1 bigger than actual sub matches
if (expidx < (int)substrings.size() && expidx > 0)
{
const wstring& submstr = substrings[expidx];
builder.append(submstr);
if (ch2) ++i;
break;
}
}
// $ escape fails, output as is
builder.push_back(L'$');
builder.push_back(ch);
}
}
else builder.push_back(str[i]);
}
}
示例3:
BOOL CConvertMacro2::Convert(wstring macro, PLUGIN_RESERVE_INFO* info, EPG_EVENT_INFO* epgInfo, wstring& convert)
{
convert = L"";
for( size_t pos = 0;; ){
size_t next = macro.find(L'$', pos);
if( next == wstring::npos ){
convert.append(macro, pos, wstring::npos);
break;
}
convert.append(macro, pos, next - pos);
pos = next;
next = macro.find(L'$', pos + 1);
if( next == wstring::npos ){
convert.append(macro, pos, wstring::npos);
break;
}
if( ExpandMacro(macro.substr(pos + 1, next - pos - 1), info, epgInfo, convert) == FALSE ){
convert += L'$';
pos++;
}else{
pos = next + 1;
}
}
Replace(convert, L"\r", L"");
Replace(convert, L"\n", L"");
return TRUE;
}
示例4: AppendString
void AppendString(wstring& str0, const wstring& str1, const wstring& str2) {
if (str1.empty())
return;
if (!str0.empty())
str0.append(str2);
str0.append(str1);
}
示例5: generateWhitespaceXML
void displayModel_t::generateWhitespaceXML(HWND hwnd, long baseline, wstring& text) {
wstringstream s;
s<<L"<text ";
s<<L"hwnd=\""<<hwnd<<L"\" ";
s<<L"baseline=\""<<baseline<<L"\" ";
s<<L">";
text.append(s.str());
text.append(L" ");
text.append(L"</text>");
}
示例6: process_file
void process_file(wstring& output, set<wstring>& file_set, const wstring& file_path, const list<wstring>& include_dirs) {
if (file_set.count(file_path)) return;
file_set.insert(file_path);
list<wstring> include_files = get_include_file_list(file_path, include_dirs);
if (!include_files.empty()) {
output.append(file_path).append(1, L':');
for (list<wstring>::const_iterator inc_file = include_files.begin(); inc_file != include_files.end(); inc_file++) {
output.append(1, L' ').append(*inc_file);
}
output.append(1, L'\n');
}
for (list<wstring>::const_iterator inc_file = include_files.begin(); inc_file != include_files.end(); inc_file++) {
process_file(output, file_set, *inc_file, include_dirs);
}
}
示例7: BuildTreeString
void BuildTreeString(vector<AccessibleChild>& children, wstring& str, int indent) {
for (auto it = children.begin(); it != children.end(); ++it) {
str.append(indent * 4, L' ');
str += L"[" + it->role + L"] " + it->name + L" = " + it->value + L"\n";
BuildTreeString(it->children, str, indent + 1);
}
}
示例8: dumpLabel
void CCilDisasm::dumpLabel( wstring& str )
{
//32 chars
str.append( L":" );
swprintf_s( m_wstrBuffer, ARRAYSIZE( m_wstrBuffer ), L"%-32s", str.data() );
wcout << m_wstrBuffer;
}
示例9: ToWideString
/**
* @brief std::string → std::wstring変換
*
* @param[out] dst 変換結果バッファ
* @param src 変換するマルチバイト文字列
* @param loc 変換に使用するlocale
* @param cvt 変換関数を提供するcodecvt
*/
void ToWideString(wstring &dst, const string &src, const codecvt<wstring::value_type, string::value_type, mbstate_t>& cvt)
{
typedef wstring::value_type wchar_type;
typedef string::value_type char_type;
typedef codecvt<wchar_type, char_type, mbstate_t> cvt_type;
size_t len = src.length();
wchar_type * buff = new wchar_type[len*2];
const char_type* const pbegin = src.c_str();
const char_type* const pend = pbegin + src.length();
const char_type* pnext = pbegin;
wchar_type* const pwbegin = &buff[0];
wchar_type* const pwend = &buff[len*2];
wchar_type* pwnext = pwbegin;
dst.clear();
mbstate_t state(0);
for(;;){
cvt_type::result result = cvt.in(state, pbegin, pend, pnext, pwbegin, pwend, pwnext);
dst.append(pwbegin, pwnext - pwbegin);
if(result == cvt_type::ok) {
break;
}
assert(result == cvt_type::error);
}
delete[] buff;
}
示例10: AppendBackslash
// Append a backslash to the current string
inline wstring AppendBackslash(wstring str)
{
if (str.length() == 0)
return wstring(L"\\");
if (str[str.length() - 1] == L'\\')
return str;
return str.append(L"\\");
}
示例11: generateXML
void displayModelChunk_t::generateXML(wstring& text) {
wstringstream s;
s<<L"<text ";
s<<L"hwnd=\""<<hwnd<<L"\" ";
s<<L"baseline=\""<<baseline<<L"\" ";
s<<L"direction=\""<<direction<<L"\" ";
s<<L" font-name=\""<<formatInfo.fontName<<L"\" ";
s<<L" font-size=\""<<formatInfo.fontSize<<L"pt\" ";
if(this->formatInfo.bold) s<<L" bold=\"true\"";
if(this->formatInfo.italic) s<<L" italic=\"true\"";
if(this->formatInfo.underline) s<<L" underline=\"true\"";
s<<L" color=\""<<this->formatInfo.color<<L"\"";
s<<L" background-color=\""<<this->formatInfo.backgroundColor<<L"\"";
s<<L">";
text.append(s.str());
for(wstring::iterator i=this->text.begin();i!=this->text.end();++i) appendCharToXML(*i,text);
text.append(L"</text>");
}
示例12: ReadLine
HRESULT CDataTuple::ReadLine(FILE *fp, wstring &line)
{
HRESULT hRet = E_FAIL;
TCHAR buffer[256];
line.clear();
if (NULL != fp)
{
buffer[0] = TEXT('\0');
TCHAR * pStr = _fgetts(buffer, ARRAYSIZE(buffer), fp);
errno_t err;
_get_errno(&err);
if (feof(fp) != 0 || err != 0)
{
return hRet;
}
line.append(buffer);
size_t cBuffer = _tcslen(buffer);
if (cBuffer <= 0)
{
return hRet;
}
while (cBuffer > 0 && buffer[cBuffer-1] != TEXT('\n') )
{
buffer[0] = TEXT('\0');
pStr = _fgetts(buffer, ARRAYSIZE(buffer), fp);
line.append(buffer);
cBuffer = _tcslen(buffer);
}
if (line.length() > 0)
{
hRet = S_OK;
}
}
return hRet;
}
示例13: while
//----------------------------------------------------------------------
// Converts a UTF8 encoded string to a unicode string
// See the following document for more information:
// RFC2279: UTF-8, a transformation format of ISO 10646
// Author: pdaehne
//----------------------------------------------------------------------
void TextFace::convertUTF8ToUnicode(const string &utf8Text, wstring &text)
{
// Clear and prepare the result string
text.erase();
text.reserve(utf8Text.length());
// Transform UTF8 sequences to UTF16 sequences
const char *pos = utf8Text.c_str();
while (*pos != '\0')
text.append(1, utf8Char2Unicode(pos));
}
示例14: find
//可同时处理目录和文件:path可以是路径,也可以是文件名,或者文件通配符
wstring find(wstring path,bool cursive)
{
//取路径名最后一个"//"之前的部分,包括"//"
replace_allW(path,L"\\",L"/");
UINT index=path.find_last_of('/');
if(index+1==path.length()){
path.append(L"*.*");
}
wstring prefix=path.substr(0,path.find_last_of('/')+1);
WIN32_FIND_DATA FindFileData;
HANDLE hFind=::FindFirstFile(path.data(),&FindFileData);
std::wstringstream ss;
if(INVALID_HANDLE_VALUE == hFind)
{
ss<<L"[]";
FindClose(hFind);
return ss.str();
}
else{
ss<<L"[";
}
while(TRUE)
{
bool flag=false;;
//目录
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
//不是当前目录,也不是父目录
if(cursive&&FindFileData.cFileName[0]!='.')
{
wstring temp=prefix+FindFileData.cFileName;
ss<<L"{\"name\":\""<<FindFileData.cFileName<<L"\",\"list\":"<<find(temp+L"/*.*",cursive).data()<<L"}";
flag=true;
}
}
//文件
else
{
ss<<L"\""<<FindFileData.cFileName<<L"\"";
flag=true;
}
if(!FindNextFile(hFind,&FindFileData))
break;
else if(flag){
ss<<L",";
}
}
ss<<L"]";
FindClose(hFind);
return ss.str();
}
示例15: ini_get_wstring
void ini_get_wstring(INI_Reader &ini, wstring &wscValue)
{
string scValue = ini.get_value_string();
wscValue = L"";
long lHiByte;
long lLoByte;
while(sscanf(scValue.c_str(), "%02X%02X", &lHiByte, &lLoByte) == 2)
{
scValue = scValue.substr(4);
wchar_t wChar = (wchar_t)((lHiByte << 8) | lLoByte);
wscValue.append(1, wChar);
}
}