X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fpbd%2Fsearch_path.cc;h=f305e24f90ac76db135ea230fa4a7fbece7206b7;hb=8aca90e593aae691fcc6f115e28cb7552ce0fb31;hp=9a10557dabaae7e5bcd8c5a3b93edaf3793c7507;hpb=2c8d0460c2f99c2027d78c090b80d8df95d6f1e6;p=ardour.git diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc index 9a10557dab..f305e24f90 100644 --- a/libs/pbd/search_path.cc +++ b/libs/pbd/search_path.cc @@ -17,9 +17,11 @@ */ -#include -#include -#include +#include "pbd/tokenizer.h" +#include "pbd/search_path.h" +#include "pbd/error.h" + +using namespace std; namespace { @@ -42,32 +44,26 @@ SearchPath::SearchPath (const string& path) { vector tmp; - if(!tokenize ( path, string(path_delimiter), std::back_inserter (tmp))) - { - // log warning(info perhaps?) that the path is empty - warning << "SearchPath contains no tokens" << endmsg; - + if (tokenize (path, string(path_delimiter), std::back_inserter (tmp))) { + add_directories (tmp); } - - add_directories (tmp); } -SearchPath::SearchPath (const vector& paths) +SearchPath::SearchPath (const sys::path& directory_path) { - add_directories (paths); + add_directory (directory_path); } -SearchPath::SearchPath (const SearchPath& other) - : m_dirs(other.m_dirs) +SearchPath::SearchPath (const vector& paths) { - + add_directories (paths); } void SearchPath::add_directory (const sys::path& directory_path) { // test for existance and warn etc? - m_dirs.push_back(directory_path); + push_back(directory_path); } void @@ -79,11 +75,11 @@ SearchPath::add_directories (const vector& paths) } const string -SearchPath::get_string () const +SearchPath::to_string () const { string path; - for (vector::const_iterator i = m_dirs.begin(); i != m_dirs.end(); ++i) { + for (vector::const_iterator i = begin(); i != end(); ++i) { path += (*i).to_string(); path += path_delimiter; } @@ -93,17 +89,10 @@ SearchPath::get_string () const return path; } -SearchPath& -SearchPath::operator= (const SearchPath& path) -{ - m_dirs = path.m_dirs; - return *this; -} - SearchPath& SearchPath::operator+= (const SearchPath& spath) { - m_dirs.insert(m_dirs.end(), spath.m_dirs.begin(), spath.m_dirs.end()); + insert(end(), spath.begin(), spath.end()); return *this; } @@ -125,18 +114,14 @@ SearchPath& SearchPath::operator+ (const SearchPath& spath) { // concatenate paths into new SearchPath - m_dirs.insert(m_dirs.end(), spath.m_dirs.begin(), spath.m_dirs.end()); + insert(end(), spath.begin(), spath.end()); return *this; } SearchPath& SearchPath::add_subdirectory_to_paths (const string& subdir) { - vector tmp; - string directory_path; - - for (vector::iterator i = m_dirs.begin(); i != m_dirs.end(); ++i) - { + for (vector::iterator i = begin(); i != end(); ++i) { // should these new paths just be added to the end of // the search path rather than replace? *i /= subdir; @@ -144,11 +129,5 @@ SearchPath::add_subdirectory_to_paths (const string& subdir) return *this; } - -SearchPath& -SearchPath::operator/= (const string& subdir) -{ - return add_subdirectory_to_paths (subdir); -} } // namespace PBD