*/
LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator+ (const std::string& directory_path);
+ /**
+ * Remove all the directories in path from this.
+ */
+ LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator-= (const Searchpath& spath);
+
+ /**
+ * Remove a directory path from the search path.
+ */
+ LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator-= (const std::string& directory_path);
+
/**
* Add a sub-directory to each path in the search path.
* @param subdir The directory name, it should not contain
LIBPBD_TEMPLATE_MEMBER_API void add_directory (const std::string& directory_path);
LIBPBD_TEMPLATE_MEMBER_API void add_directories (const std::vector<std::string>& paths);
+ LIBPBD_TEMPLATE_MEMBER_API void remove_directory (const std::string& directory_path);
+ LIBPBD_TEMPLATE_MEMBER_API void remove_directories (const std::vector<std::string>& paths);
};
LIBPBD_API void export_search_path (const std::string& base_dir, const char* varname, const char* dir);
add_directories (paths);
}
+void
+Searchpath::remove_directory (const std::string& directory_path)
+{
+ if (directory_path.empty()) {
+ return;
+ }
+
+ for (vector<std::string>::iterator i = begin(); i != end();) {
+ if (*i == directory_path) {
+ i = erase (i);
+ } else {
+ ++i;
+ }
+ }
+}
+
+void
+Searchpath::remove_directories (const vector<std::string>& paths)
+{
+ for(vector<std::string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
+ remove_directory (*i);
+ }
+}
+
void
Searchpath::add_directory (const std::string& directory_path)
{
return *this;
}
+Searchpath&
+Searchpath::operator-= (const Searchpath& spath)
+{
+ remove_directories (spath);
+ return *this;
+}
+
+Searchpath&
+Searchpath::operator-= (const std::string& directory_path)
+{
+ remove_directory (directory_path);
+ return *this;
+}
+
+
Searchpath&
Searchpath::add_subdirectory_to_paths (const string& subdir)
{