summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-06-26 19:07:38 +0200
committerRobin Gareus <robin@gareus.org>2014-06-26 19:16:20 +0200
commit789cf92a23d6c6d96d3b7f5f410502c88a547c13 (patch)
tree091dfa474e70efa3ea68e2fd5f6f48ff37793025 /libs/ardour/utils.cc
parenta74d7bd232c1b97a05be478c4389aa434470bb60 (diff)
bump take-name after every recording
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index d4b0a77893..6fdab19497 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -196,6 +196,31 @@ ARDOUR::bump_name_once (const std::string& name, char delimiter)
}
+string
+ARDOUR::bump_name_number (const std::string& name)
+{
+ size_t pos = name.length();
+ bool have_number = false;
+ while (pos > 0 && isdigit(name.at(--pos))) {
+ have_number = true;
+ }
+
+ string newname;
+ if (have_number) {
+ ++pos;
+ int32_t num = strtol (name.c_str() + pos, (char **)NULL, 10);
+ char buf[32];
+ snprintf (buf, sizeof(buf), "%d", num + 1);
+ newname = name.substr (0, pos);
+ newname += buf;
+ } else {
+ newname = name;
+ newname += "1";
+ }
+
+ return newname;
+}
+
XMLNode *
ARDOUR::find_named_node (const XMLNode& node, string name)
{