[Summary] improve function remove_pattern_from_string()

[git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 465192]
This commit is contained in:
Nikolay Polyanovskii 2014-06-02 10:29:07 -05:00 committed by Paul Davis
parent cd94ffdebe
commit ec6c49d171

View file

@ -46,13 +46,15 @@ using namespace Glib;
#define dbg_msg(a) MessageDialog (a, PROGRAM_NAME).run();
namespace {
// if pattern is not found out_str == in_str
bool remove_pattern_from_string(const std::string& in_str, const std::string& pattern, std::string& out_str) {
if (in_str.find(pattern) != std::string::npos ) {
out_str = in_str.substr(pattern.size() );
out_str.assign(in_str);
size_t pos = in_str.find(pattern);
if ( pos != std::string::npos ) {
out_str.erase(pos, pattern.length() );
return true;
} else {
out_str = in_str;
return false;
}
}