tweak transport bar spacing
[ardour.git] / libs / pbd / pbd / search_path.h
index 18f05ef0142a8d2bb10604affa5799229cae713c..de0eeeeb5a8925e165bef976bfe8104e4d846092 100644 (file)
 #include <string>
 #include <vector>
 
-#include <pbd/filesystem.h>
+#include "pbd/filesystem.h"
 
 namespace PBD {
 
-using std::string;
-using std::vector;
-
 /**
  * @class The SearchPath class is a helper class for getting a 
  * vector of paths contained in a search path string where a 
@@ -39,76 +36,41 @@ using std::vector;
  * The SearchPath class does not test whether the paths exist
  * or are directories. It is basically just a container.
  */
-class SearchPath {
+class SearchPath : public std::vector<sys::path>
+{
 public:
-
-       typedef std::vector<sys::path>::iterator         iterator;
-       typedef std::vector<sys::path>::const_iterator   const_iterator;
-
-public:
-
        /**
         * Create an empty SearchPath.
         */
        SearchPath ();
 
        /**
-        * Initialize SearchPath from a string each path may or may not
-        * exist.
+        * Initialize SearchPath from a string where the string contains
+        * one or more absolute paths to directories which are delimited 
+        * by a path separation character. The path delimeter is a 
+        * colon(:) on unix and a semi-colon(;) on windows.
+        *
+        * Each path contained in the search path may or may not resolve to
+        * an existing directory in the filesystem.
         * 
         * @param search_path A path string.
         */
-       SearchPath (const string& search_path);
+       SearchPath (const std::string& search_path);
 
        /**
-        * Initialize SearchPath from a vector of paths that may or may
-        * not exist.
+        * Initialize SearchPath from a sys::path.
         *
-        * @param path A path.
+        * @param directory_path A directory path.
         */
-       SearchPath (const vector<sys::path>& paths);
+       SearchPath (const PBD::sys::path& directory_path);
 
        /**
-        * The copy constructor does what you would expect and copies the
-        * vector of paths contained by the SearchPath.
-        */
-       SearchPath (const SearchPath& search_path);
-
-       /**
-        * Indicate whether there are any directory paths in m_dirs.
-        *
-        * If SearchPath is initialized with an empty string as the 
-        * result of for instance the contents of an unset environment
-        * variable.
+        * Initialize SearchPath from a vector of paths that may or may
+        * not exist.
         *
-        * @return true if there are any paths in m_paths.
+        * @param paths A vector of paths.
         */
-       operator void* () const { return (void*)!m_dirs.empty(); }
-
-       /**
-        *  @return a read/write iterator that points to the first
-        *  path in the SearchPath. Iteration is done in ordinary
-        *  element order.
-        */
-       iterator begin () { return m_dirs.begin(); }
-       
-       /**
-        *  @return A read-only (constant) iterator that points to the
-        *  first path in the SearchPath.
-        */
-       const_iterator begin () const { return m_dirs.begin(); }
-
-       /**
-        *  @return A read/write iterator that points one past the last
-        *  path in the SearchPath.
-        */
-       iterator end () { return m_dirs.end(); }
-       
-       /**
-        *  @return A read-only (constant) iterator that points one past 
-        *  the last path in the SearchPath.
-        */
-       const_iterator end () const { return m_dirs.end(); }
+       SearchPath (const std::vector<PBD::sys::path>& paths);
 
        /**
         * @return a search path string.
@@ -116,12 +78,7 @@ public:
         * The string that is returned contains the platform specific
         * path separator.
         */
-       const string get_string () const;
-
-       /**
-        * Assignment of another SearchPath to this.
-        */
-       SearchPath& operator= (const SearchPath& spath);
+       const std::string to_string () const;
 
        /**
         * Add all the directories in path to this.
@@ -131,7 +88,7 @@ public:
        /**
         * Add another directory path to the search path.
         */
-       SearchPath& operator+= (const sys::path& directory_path);
+       SearchPath& operator+= (const PBD::sys::path& directory_path);
        
        /**
         * Concatenate another SearchPath onto this.
@@ -141,29 +98,18 @@ public:
        /**
         * Add another path to the search path.
         */
-       SearchPath& operator+ (const sys::path& directory_path);
+       SearchPath& operator+ (const PBD::sys::path& directory_path);
 
        /**
         * Add a sub-directory to each path in the search path.
         * @param subdir The directory name, it should not contain 
         * any path separating tokens.
         */
-       SearchPath& add_subdirectory_to_paths (const string& subdir);
-
-       /**
-        * Add a sub-directory to each path in the search path.
-        * @see add_subdirectory_to_paths
-        */
-       SearchPath& operator/= (const string& subdir);
+       SearchPath& add_subdirectory_to_paths (const std::string& subdir);
 
 protected:
-
        void add_directory (const sys::path& directory_path);
-
-       void add_directories (const vector<sys::path>& paths);
-       
-       vector<sys::path> m_dirs;
-
+       void add_directories (const std::vector<PBD::sys::path>& paths);
 };
 
 } // namespace PBD