From 789cf92a23d6c6d96d3b7f5f410502c88a547c13 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 26 Jun 2014 19:07:38 +0200 Subject: bump take-name after every recording --- libs/ardour/utils.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libs/ardour/utils.cc') 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) { -- cgit v1.2.3