summaryrefslogtreecommitdiff
path: root/libs/ardour/controllable_descriptor.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-05-17 15:04:42 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-31 15:30:43 -0400
commit2ff7821128c68a1ff34c971e0e7a85f34948f78e (patch)
tree8be166982e434c1dad47c4e14b2c6da1770e2669 /libs/ardour/controllable_descriptor.cc
parent31a8f01d161bc0db330dbe2d4e41398d36808b00 (diff)
expand and correct accepted syntax for ControllableDescriptor strings
note: manual needs updating to reflect this
Diffstat (limited to 'libs/ardour/controllable_descriptor.cc')
-rw-r--r--libs/ardour/controllable_descriptor.cc78
1 files changed, 60 insertions, 18 deletions
diff --git a/libs/ardour/controllable_descriptor.cc b/libs/ardour/controllable_descriptor.cc
index 05aa1845a3..f617468211 100644
--- a/libs/ardour/controllable_descriptor.cc
+++ b/libs/ardour/controllable_descriptor.cc
@@ -16,6 +16,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifdef COMPILER_MSVC
+#include <io.h> // Microsoft's nearest equivalent to <unistd.h>
+#include <ardourext/misc.h>
+#else
+#include <regex.h>
+#endif
+
#include "pbd/strsplit.h"
#include "pbd/convert.h"
@@ -51,28 +58,68 @@ ControllableDescriptor::set (const std::string& str)
return -1;
}
+ bool stripable = false;
+ regex_t compiled_pattern;
+ const char * const pattern = "^[BS]?[0-9]+";
+
if (path[0] == "route" || path[0] == "rid") {
- _top_level_type = PresentationOrderRoute;
+ /* this is not going to fail */
+ regcomp (&compiled_pattern, pattern, REG_EXTENDED|REG_NOSUB);
+ bool matched = (regexec (&compiled_pattern, rest[0].c_str(), 0, 0, 0) == 0);
+ regfree (&compiled_pattern);
- if (rest[0][0] == 'B') {
- _banked = true;
- _presentation_order = atoi (rest[0].substr (1));
- } else if (rest[0][0] == 'S') {
- _top_level_type = SelectionCount;
- _banked = true;
- _selection_id = atoi (rest[0].substr (1));
- } else if (isdigit (rest[0][0])) {
- _banked = false;
- _presentation_order = atoi (rest[0]);
+ if (matched) {
+ _top_level_type = PresentationOrderRoute;
+ stripable = true;
} else {
- return -1;
+ _top_level_type = NamedRoute;
+ _top_level_name = rest[0];
}
} else if (path[0] == "vca") {
-
_top_level_type = PresentationOrderVCA;
+ stripable = true;
+ } else if (path[0] == "bus") {
+ /* digits, or B<digits> or S<digits> will be used as for route;
+ anything else will be treated as a track name.
+ */
+ /* this is not going to fail */
+
+ regcomp (&compiled_pattern, pattern, REG_EXTENDED|REG_NOSUB);
+ bool matched = (regexec (&compiled_pattern, rest[0].c_str(), 0, 0, 0) == 0);
+ regfree (&compiled_pattern);
+
+ if (matched) {
+ _top_level_type = PresentationOrderBus;
+ stripable = true;
+ } else {
+ _top_level_type = NamedRoute;
+ _top_level_name = rest[0];
+ }
+
+ } else if (path[0] == "track") {
+
+ /* digits, or B<digits> or S<digits> will be used as for route;
+ anything else will be treated as a track name.
+ */
+
+ /* this is not going to fail */
+ regcomp (&compiled_pattern, pattern, REG_EXTENDED|REG_NOSUB);
+ bool matched = (regexec (&compiled_pattern, rest[0].c_str(), 0, 0, 0) == 0);
+ regfree (&compiled_pattern);
+
+ if (matched) {
+ _top_level_type = PresentationOrderTrack;
+ stripable = true;
+ } else {
+ _top_level_type = NamedRoute;
+ _top_level_name = rest[0];
+ }
+ }
+
+ if (stripable) {
if (rest[0][0] == 'B') {
_banked = true;
_presentation_order = atoi (rest[0].substr (1));
@@ -86,11 +133,6 @@ ControllableDescriptor::set (const std::string& str)
} else {
return -1;
}
-
- } else if (path[0] == "bus" || path[0] == "track") {
-
- _top_level_type = NamedRoute;
- _top_level_name = rest[0];
}
if (path[1] == "gain") {