本文整理汇总了C++中string_t::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ string_t::erase方法的具体用法?C++ string_t::erase怎么用?C++ string_t::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string_t
的用法示例。
在下文中一共展示了string_t::erase方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_file_extension
static void remove_file_extension(string_t& str) {
for (int p=string_t_size(str)-1; p > 0; p--) {
if (str[p]=='.') {
str.erase(p,string_t_size(str)-p);
break;
}
}
}
示例2: load_file
bool file_manager::load_file(std::ifstream &fs, string_t& out_buf) const
{
if (!fs.is_open() || !fs.good()) return false;
while (fs.good()) {
out_buf.push_back(fs.get());
}
out_buf.erase(out_buf.size()-1,1);
return true;
}
示例3: dirname
string_t dirname(string_t source)
{
if (source.size() <= 1) //Make sure it's possible to check the last character.
{
return source;
}
if (*(source.rbegin() + 1) == '/') //Remove trailing slash if it exists.
{
source = source.substr(0, source.size() - 1);
}
source.erase(std::find(source.rbegin(), source.rend(), '/').base(), source.end());
return source;
}
示例4: detect_fucking_warez_ad_tag
static void detect_fucking_warez_ad_tag(string_t& str) {
if (string_t_find_success(str.find("(www.")))
{
size_t pos=str.find("(www.");
str.erase(pos, string_t_size(str));
}
else if (string_t_find_success(str.find("(http://")))
{
size_t pos=str.find("(http://");
str.erase(str.find("(http://"), string_t_size(str));
str.erase(pos, string_t_size(str));
}
else if (string_t_find_success(str.find("http://")))
{
size_t pos=str.find("http://");
str.erase(pos, string_t_size(str));
}
else if (string_t_find_success(str.find("www."))) {
size_t pos=str.find("www.");
str.erase(pos, string_t_size(str));
}
remove_useless_spaces_before(str);
}
示例5: remove_multiple_whitespaces
void remove_multiple_whitespaces(string_t & string)
{
auto it = std::begin(string);
while (std::next(it) != std::end(string))
{
auto const next = std::next(it);
if (std::isspace(int(*it)) && std::isspace(int(*next)))
{
*next = ' ';
it = string.erase(it);
}
else
{
++it;
}
}
}
示例6: remove_track_number
static void remove_track_number(string_t& str) {
unsigned int end_num=0;
remove_useless_spaces_before(str);
for (end_num=0; end_num < string_t_size(str); end_num++)
{
if ((char) str[end_num] >= '0' && (char) str[end_num] <= '9') continue;
else if ((char) str[end_num] == ' ' ||
(char) str[end_num] == '_' ||
(char) str[end_num] == ')' ||
(char) str[end_num] == '.') break;
else {
end_num=string_t_size(str)+1;
break;
}
}
if (end_num < 5 && end_num+1 < string_t_size(str)) {
str.erase(0,end_num+1);
remove_useless_spaces_before(str);
}
}
示例7: remove_useless_spaces_after
static void remove_useless_spaces_after(string_t& str){
while (string_t_size(str) > 0 && (str[string_t_size(str)-1] == ' ' || str[string_t_size(str)-1] == '_'))
str.erase(string_t_size(str)-1,1);
}
示例8: remove_useless_spaces_before
//#if defined(STRING_T_IS_SF_STRING)
static void remove_useless_spaces_before(string_t& str){
while (!string_t_empty(str) && (str[0] == ' ' || str[0] == '_'))
str.erase(0,1);
}