本文整理汇总了C++中strings::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ strings::erase方法的具体用法?C++ strings::erase怎么用?C++ strings::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strings
的用法示例。
在下文中一共展示了strings::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_json_form
// Utility: extract argument values from JSON request body
void HttpInterface::parse_json_form(std::string content, strings& values)
{
std::string buffer = content;
buffer.erase(std::remove_if(buffer.begin(), buffer.end(), ::isspace), buffer.end());
std::stringstream ss(buffer);
if (ss.get() == '[')
{
int i;
while (ss >> i)
{
// values.push_back(std::to_string(short(i)));
std::stringstream valss;
valss << short(i);
values.push_back(valss.str());
if (ss.peek() == ']')
break;
else if (ss.peek() == ',')
ss.ignore();
}
if (ss.get() != ']')
values.erase(values.begin(),values.end());
}
示例2: findPossibleSubtitles
void TsubtitlesFile::findPossibleSubtitles(const char_t *aviFlnm, const char_t *sdir, strings &files, subtitleFilesSearchMode searchMode)
{
if (!aviFlnm || !sdir) {
return;
}
char_t avidir[MAX_PATH];
if (aviFlnm[0]) {
char_t dsk[MAX_PATH], dir[MAX_PATH], name[MAX_PATH];
_splitpath_s(aviFlnm, dsk, MAX_PATH, dir, MAX_PATH, name, MAX_PATH, NULL, 0);
_makepath_s(avidir, countof(avidir), dsk, dir, NULL, NULL);
} else {
strcpy(avidir, _l("."));
}
strings dirs;
strtok(sdir, _l(";"), dirs);
fixRelativePaths(dirs, avidir);
for (strings::const_iterator sd = dirs.begin(); sd != dirs.end(); sd++) {
findPossibleSubtitles(sd->c_str(), files);
}
// If search mode is "search video file match then heuristic", then test if at least 1 subtitle filename matches with the video filename
bool videoFileMatch = false;
ffstring videoFlnmNoExt;
extractfilenameWOext(aviFlnm, videoFlnmNoExt);
videoFlnmNoExt.ConvertToLowerCase();
if (searchMode == SUBFILES_VIDEO_FILE_HEURISTIC) {
for (strings::iterator f = files.begin(); f != files.end(); f++) {
ffstring flnmNoExt;
extractfilenameWOext((*f).c_str(), flnmNoExt);
flnmNoExt.ConvertToLowerCase();
if (strncmp(videoFlnmNoExt.c_str(), flnmNoExt.c_str(), videoFlnmNoExt.length()) == 0) {
/* Common portion of video and subtitle filenames. Check if lengths are equal (identical names)
or if this is a dot "." right after like in videofile.<suffix>.ext */
if (videoFlnmNoExt.length() == flnmNoExt.length() || flnmNoExt[videoFlnmNoExt.length()] == _l('.')) {
videoFileMatch = true;
break;
}
}
}
}
if (searchMode != SUBFILES_ALL) {
EditDistance dist;
for (strings::iterator f = files.begin(); f != files.end();) {
ffstring flnmNoExt;
extractfilenameWOext((*f).c_str(), flnmNoExt);
flnmNoExt.ConvertToLowerCase();
// If search mode is based on video file name removes the non matching entries
if (searchMode == SUBFILES_VIDEO_FILE_MATCH
|| (searchMode == SUBFILES_VIDEO_FILE_HEURISTIC && videoFileMatch)) {
if (strncmp(videoFlnmNoExt.c_str(), flnmNoExt.c_str(), videoFlnmNoExt.length()) != 0
|| (videoFlnmNoExt.length() != flnmNoExt.length() && flnmNoExt[videoFlnmNoExt.length()] != _l('.'))) {
f = files.erase(f);
} else {
f++;
}
continue;
}
// Heuristic search
int distance = dist.CalEditDistance(videoFlnmNoExt.c_str(), flnmNoExt.c_str(), 2 * MAX_PATH);
//DPRINTF(_l("Subtitle files : %s vs %s match result = %d"), flnmNoExt.c_str(), videoFlnmNoExt.c_str(), distance);
if (distance > SUBFILES_HEURISTIC_LIMIT) {
f = files.erase(f);
} else {
f++;
}
}
}
}