本文整理汇总了C++中StringX::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ StringX::replace方法的具体用法?C++ StringX::replace怎么用?C++ StringX::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringX
的用法示例。
在下文中一共展示了StringX::replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseNotes
static void ParseNotes(StringX &sxNotes,
std::vector<StringX> &vsxnotes_lines)
{
if (!sxNotes.empty()) {
// Use \n and \r to tokenise this line
StringX::size_type st_start(0), st_end(0);
const StringX sxdelim = _T("\r\n");
StringX sxline;
StringX::size_type st_index;
while (st_end != StringX::npos) {
st_end = sxNotes.find(sxdelim, st_start);
sxline = (sxNotes.substr(st_start,
(st_end == StringX::npos) ? StringX::npos : st_end - st_start));
st_index = 0;
// Remove all tabs - \t
for (;;) {
st_index = sxline.find(_T("\\t"), st_index);
if (st_index == StringX::npos)
break;
sxline.replace(st_index, 2, _T(""));
st_index += 1;
}
vsxnotes_lines.push_back(sxline);
st_start = ((st_end > (StringX::npos - sxdelim.size()))
? StringX::npos : st_end + sxdelim.size());
}
}
}
示例2: GetAutoTypeString
StringX PWSAuxParse::GetAutoTypeString(const StringX &sx_in_autotype,
const StringX &sx_group,
const StringX &sx_title,
const StringX &sx_user,
const StringX &sx_pwd,
const StringX &sx_notes,
const StringX &sx_url,
const StringX &sx_email,
std::vector<size_t> &vactionverboffsets)
{
StringX sxtmp(_T(""));
StringX sxNotes(sx_notes);
TCHAR curChar;
StringX sx_autotype(sx_in_autotype);
StringX::size_type st_index;
std::vector<StringX> vsxnotes_lines;
vactionverboffsets.clear();
// If empty, try the database default
if (sx_autotype.empty()) {
sx_autotype = PWSprefs::GetInstance()->
GetPref(PWSprefs::DefaultAutotypeString);
// If still empty, take this default
if (sx_autotype.empty()) {
// checking for user and password for default settings
if (!sx_pwd.empty()){
if (!sx_user.empty())
sx_autotype = DEFAULT_AUTOTYPE;
else
sx_autotype = _T("\\p\\n");
}
}
}
// No recursive substitution (e.g. \p or \u), although '\t' will be replaced by a tab
if (!sx_notes.empty()) {
// Use \n and \r to tokenise this line
StringX::size_type st_start(0), st_end(0);
const StringX sxdelim = _T("\r\n");
StringX sxline;
while (st_end != StringX::npos) {
st_end = sxNotes.find_first_of(sxdelim, st_start);
sxline = (sxNotes.substr(st_start, (st_end == StringX::npos) ?
StringX::npos : st_end - st_start));
st_index = 0;
for (;;) {
st_index = sxline.find(_T("\\t"), st_index);
if (st_index == StringX::npos)
break;
sxline.replace(st_index, 2, _T("\t"));
st_index += 1;
}
vsxnotes_lines.push_back(sxline);
// If we just hit a "\r\n", move past it. Or else, it is a "\r" without
// a following "\n" or a "\n", so just move past one single char
if (st_end != StringX::npos) {
st_start = st_end + (sxNotes.compare(st_end, 2, sxdelim) == 0 ? 2 : 1);
if (st_start >= sxNotes.length())
break;
}
}
// Now change '\n' to '\r' in the complete notes field
st_index = 0;
for (;;) {
st_index = sxNotes.find(sxdelim, st_index);
if (st_index == StringX::npos)
break;
sxNotes.replace(st_index, 2, _T("\r"));
st_index += 1;
}
st_index = 0;
for (;;) {
st_index = sxNotes.find(_T("\\t"), st_index);
if (st_index == StringX::npos)
break;
sxNotes.replace(st_index, 2, _T("\t"));
st_index += 1;
}
}
const size_t N = sx_autotype.length();
const StringX sxZeroes = _T("000");
int gNumIts;
for (size_t n = 0; n < N; n++){
curChar = sx_autotype[n];
if (curChar == TCHAR('\\')) {
n++;
if (n < N)
curChar = sx_autotype[n];
switch (curChar){
case TCHAR('\\'):
sxtmp += TCHAR('\\');
break;
case TCHAR('n'):
case TCHAR('r'):
sxtmp += TCHAR('\r');
//.........这里部分代码省略.........