+
+ return 0;
+}
+
+void
+IO::prepare_for_reset (XMLNode& node, const std::string& name)
+{
+ /* reset name */
+ node.add_property ("name", name);
+
+ /* now find connections and reset the name of the port
+ in one so that when we re-use it it will match
+ the name of the thing we're applying it to.
+ */
+
+ XMLProperty* prop;
+ XMLNodeList children = node.children();
+
+ for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
+
+ if ((*i)->name() == "Port") {
+
+ prop = (*i)->property (X_("name"));
+
+ if (prop) {
+ string new_name;
+ string old = prop->value();
+ string::size_type slash = old.find ('/');
+
+ if (slash != string::npos) {
+ /* port name is of form: <IO-name>/<port-name> */
+
+ new_name = name;
+ new_name += old.substr (old.find ('/'));
+
+ prop->set_value (new_name);
+ }
+ }
+ }
+ }
+}
+
+
+int
+IO::make_connections_2X (const XMLNode& node, int /*version*/, bool in)
+{
+ const XMLProperty* prop;
+
+ /* XXX: bundles ("connections" as was) */
+
+ if ((prop = node.property ("inputs")) != 0 && in) {
+
+ string::size_type ostart = 0;
+ string::size_type start = 0;
+ string::size_type end = 0;
+ int i = 0;
+ int n;
+ vector<string> ports;
+
+ string const str = prop->value ();
+
+ while ((start = str.find_first_of ('{', ostart)) != string::npos) {
+ start += 1;
+
+ if ((end = str.find_first_of ('}', start)) == string::npos) {
+ error << string_compose(_("IO: badly formed string in XML node for inputs \"%1\""), str) << endmsg;
+ return -1;
+ }
+
+ if ((n = parse_io_string (str.substr (start, end - start), ports)) < 0) {
+ error << string_compose(_("bad input string in XML node \"%1\""), str) << endmsg;
+
+ return -1;
+
+ } else if (n > 0) {
+
+
+ for (int x = 0; x < n; ++x) {
+ /* XXX: this is a bit of a hack; need to check if it's always valid */
+ string::size_type const p = ports[x].find ("/out");
+ if (p != string::npos) {
+ ports[x].replace (p, 4, "/audio_out");
+ }
+ nth(i)->connect (ports[x]);
+ }
+ }
+
+ ostart = end+1;
+ i++;
+ }
+
+ }
+
+ if ((prop = node.property ("outputs")) != 0 && !in) {
+
+ string::size_type ostart = 0;
+ string::size_type start = 0;
+ string::size_type end = 0;
+ int i = 0;
+ int n;
+ vector<string> ports;
+
+ string const str = prop->value ();
+
+ while ((start = str.find_first_of ('{', ostart)) != string::npos) {
+ start += 1;
+
+ if ((end = str.find_first_of ('}', start)) == string::npos) {
+ error << string_compose(_("IO: badly formed string in XML node for outputs \"%1\""), str) << endmsg;
+ return -1;
+ }
+
+ if ((n = parse_io_string (str.substr (start, end - start), ports)) < 0) {
+ error << string_compose(_("IO: bad output string in XML node \"%1\""), str) << endmsg;
+
+ return -1;
+
+ } else if (n > 0) {
+
+ for (int x = 0; x < n; ++x) {
+ /* XXX: this is a bit of a hack; need to check if it's always valid */
+ string::size_type const p = ports[x].find ("/in");
+ if (p != string::npos) {
+ ports[x].replace (p, 3, "/audio_in");
+ }
+ nth(i)->connect (ports[x]);
+ }
+ }
+
+ ostart = end+1;
+ i++;
+ }
+ }
+