本文整理匯總了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);
}