mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-04 04:39:33 +01:00
add operator-= variants for PBD::Searchpath
This commit is contained in:
parent
f4a84a0272
commit
d3e3f5f005
2 changed files with 51 additions and 0 deletions
|
|
@ -97,6 +97,16 @@ public:
|
|||
*/
|
||||
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
|
||||
|
|
@ -108,6 +118,8 @@ protected:
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,30 @@ Searchpath::Searchpath (const vector<std::string>& paths)
|
|||
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)
|
||||
{
|
||||
|
|
@ -115,6 +139,21 @@ Searchpath::operator+ (const Searchpath& spath)
|
|||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue