mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 05:35:47 +01:00
[Summary] improve function remove_pattern_from_string()
[git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 465192]
This commit is contained in:
parent
cd94ffdebe
commit
ec6c49d171
1 changed files with 6 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue