summaryrefslogtreecommitdiff
path: root/libs/ardour/export_filename.cc
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2016-08-28 09:51:00 +1000
committerTim Mayberry <mojofunk@gmail.com>2017-04-19 09:36:51 +1000
commit589f564ed8b63c683aea97dd624041bad03a3b4f (patch)
tree37e9d544708d9bdfcdb7732535f727046509d86d /libs/ardour/export_filename.cc
parent8f488515e69b082fcbce210ebd8c98708f3f9de3 (diff)
Use XMLNode::get/set_property in ARDOUR::ExportFilename class
Serious improvement in code readability in ExportFilename::get_field
Diffstat (limited to 'libs/ardour/export_filename.cc')
-rw-r--r--libs/ardour/export_filename.cc49
1 files changed, 19 insertions, 30 deletions
diff --git a/libs/ardour/export_filename.cc b/libs/ardour/export_filename.cc
index 576ea915a3..274374e20d 100644
--- a/libs/ardour/export_filename.cc
+++ b/libs/ardour/export_filename.cc
@@ -87,8 +87,8 @@ ExportFilename::get_state ()
FieldPair dir = analyse_folder();
child = node->add_child ("Folder");
- child->add_property ("relative", dir.first ? "true" : "false");
- child->add_property ("path", dir.second);
+ child->set_property ("relative", dir.first);
+ child->set_property ("path", dir.second);
add_field (node, "label", include_label, label);
add_field (node, "session", include_session);
@@ -99,7 +99,7 @@ ExportFilename::get_state ()
add_field (node, "date", include_date, enum_2_string (date_format));
XMLNode * extra_node = new XMLNode ("ExportRevision");
- extra_node->add_property ("revision", to_string (revision, std::dec));
+ extra_node->set_property ("revision", revision);
session.add_extra_xml (*extra_node);
return *node;
@@ -109,7 +109,6 @@ int
ExportFilename::set_state (const XMLNode & node)
{
XMLNode * child;
- XMLProperty const * prop;
FieldPair pair;
child = node.child ("Folder");
@@ -117,15 +116,14 @@ ExportFilename::set_state (const XMLNode & node)
folder = "";
- if ((prop = child->property ("relative"))) {
- if (string_is_affirmative (prop->value())) {
- folder = session.session_directory().root_path();
- }
+ bool is_relative;
+ if (child->get_property ("relative", is_relative) && is_relative) {
+ folder = session.session_directory ().root_path ();
}
- if ((prop = child->property ("path"))) {
- std::string tmp;
- tmp = Glib::build_filename (folder, prop->value());
+ std::string tmp;
+ if (child->get_property ("path", tmp)) {
+ tmp = Glib::build_filename (folder, tmp);
if (!Glib::file_test (tmp, Glib::FILE_TEST_EXISTS)) {
warning << string_compose (_("Existing export folder for this session (%1) does not exist - ignored"), tmp) << endmsg;
} else {
@@ -167,8 +165,8 @@ ExportFilename::set_state (const XMLNode & node)
extra_node = session.instant_xml ("ExportRevision");
}
- if (extra_node && (prop = extra_node->property ("revision"))) {
- revision = atoi (prop->value());
+ if (extra_node) {
+ extra_node->get_property ("revision", revision);
}
return 0;
@@ -365,10 +363,10 @@ ExportFilename::add_field (XMLNode * node, string const & name, bool enabled, st
return;
}
- child->add_property ("name", name);
- child->add_property ("enabled", enabled ? "true" : "false");
+ child->set_property ("name", name);
+ child->set_property ("enabled", enabled);
if (!value.empty()) {
- child->add_property ("value", value);
+ child->set_property ("value", value);
}
}
@@ -381,20 +379,11 @@ ExportFilename::get_field (XMLNode const & node, string const & name)
XMLNodeList children = node.children();
for (XMLNodeList::iterator it = children.begin(); it != children.end(); ++it) {
- XMLProperty const * prop = (*it)->property ("name");
- if (prop && !prop->value().compare (name)) {
-
- prop = (*it)->property ("enabled");
- if (prop && !prop->value().compare ("true")) {
- pair.first = true;
- } else {
- pair.first = false;
- }
-
- prop = (*it)->property ("value");
- if (prop) {
- pair.second = prop->value();
- }
+ std::string str;
+ if ((*it)->get_property ("name", str) && name == str) {
+
+ (*it)->get_property ("enabled", pair.first);
+ (*it)->get_property ("value", pair.second);
return pair;
}