21 #include "libardour-config.h"
26 #include <libxml/uri.h>
32 #include <glibmm/miscutils.h>
34 #include <glibmm/convert.h>
39 #include "ardour/utils.h"
49 const char*
const sfdb_file_name =
"sfdb";
52 static const char*
TAG =
"http://ardour.org/ontology/Tag";
54 AudioLibrary::AudioLibrary ()
58 sfdb_file_path = Glib::build_filename (sfdb_file_path, sfdb_file_name);
60 src = Glib::filename_to_uri (sfdb_file_path);
68 lrdf_read_file(src.c_str());
72 AudioLibrary::~AudioLibrary ()
77 AudioLibrary::save_changes ()
80 if (lrdf_export_by_source(src.c_str(), src.substr(5).c_str())) {
87 AudioLibrary::set_tags (
string member, vector<string> tags)
90 sort (tags.begin(), tags.end());
91 tags.erase (unique(tags.begin(), tags.end()), tags.end());
93 const string file_uri(Glib::filename_to_uri (member));
95 lrdf_remove_uri_matches (file_uri.c_str());
97 for (vector<string>::iterator i = tags.begin(); i != tags.end(); ++i) {
98 lrdf_add_triple (src.c_str(), file_uri.c_str(),
TAG, (*i).c_str(), lrdf_literal);
104 AudioLibrary::get_tags (
string member)
108 char * uri = strdup(Glib::filename_to_uri(member).c_str());
110 lrdf_statement pattern;
111 pattern.subject = uri;
112 pattern.predicate =
const_cast<char*
>(
TAG);
114 pattern.object_type = lrdf_literal;
116 lrdf_statement* matches = lrdf_matches (&pattern);
118 lrdf_statement* current = matches;
119 while (current != 0) {
120 tags.push_back (current->object);
122 current = current->next;
125 lrdf_free_statements (matches);
127 sort (tags.begin(), tags.end());
134 AudioLibrary::search_members_and (vector<string>& members,
const vector<string>& tags)
137 lrdf_statement **head;
138 lrdf_statement* pattern = 0;
139 lrdf_statement* old = 0;
142 vector<string>::const_iterator i;
143 for (i = tags.begin(); i != tags.end(); ++i){
144 pattern =
new lrdf_statement;
145 pattern->subject =
const_cast<char*
>(
"?");
146 pattern->predicate =
const_cast<char*
>(
TAG);
147 pattern->object = strdup((*i).c_str());
154 lrdf_uris* ulist = lrdf_match_multi(*head);
155 for (uint32_t j = 0; ulist && j < ulist->count; ++j) {
156 members.push_back(Glib::filename_from_uri(ulist->items[j]));
158 lrdf_free_uris(ulist);
160 sort(members.begin(), members.end());
161 unique(members.begin(), members.end());
167 free(pattern->object);
169 pattern = pattern->next;
LIBPBD_API Transmitter warning
std::ostream & endmsg(std::ostream &ostr)
LIBARDOUR_API int touch_file(std::string path)
LIBARDOUR_API std::string user_config_directory(int version=-1)
std::string string_compose(const std::string &fmt, const T1 &o1)