Use std::string instead of PBD::sys::path in pbd/search_path.h, pbd/file_utils.h...
[ardour.git] / libs / pbd / pbd / search_path.h
1 /*
2     Copyright (C) 2007 Tim Mayberry 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef PBD_SEARCH_PATH_INCLUDED
21 #define PBD_SEARCH_PATH_INCLUDED
22
23 #include <string>
24 #include <vector>
25
26 namespace PBD {
27
28 /**
29  * @class The SearchPath class is a helper class for getting a 
30  * vector of paths contained in a search path string where a 
31  * "search path string" contains absolute directory paths 
32  * separated by a colon(:) or a semi-colon(;) on windows.
33  *
34  * The SearchPath class does not test whether the paths exist
35  * or are directories. It is basically just a container.
36  */
37 class SearchPath : public std::vector<std::string>
38 {
39 public:
40         /**
41          * Create an empty SearchPath.
42          */
43         SearchPath ();
44
45         /**
46          * Initialize SearchPath from a string where the string contains
47          * one or more absolute paths to directories which are delimited 
48          * by a path separation character. The path delimeter is a 
49          * colon(:) on unix and a semi-colon(;) on windows.
50          *
51          * Each path contained in the search path may or may not resolve to
52          * an existing directory in the filesystem.
53          * 
54          * @param search_path A path string.
55          */
56         SearchPath (const std::string& search_path);
57
58         /**
59          * Initialize SearchPath from a vector of paths that may or may
60          * not exist.
61          *
62          * @param paths A vector of paths.
63          */
64         SearchPath (const std::vector<std::string>& paths);
65
66         /**
67          * @return a search path string.
68          *
69          * The string that is returned contains the platform specific
70          * path separator.
71          */
72         const std::string to_string () const;
73
74         /**
75          * Add all the directories in path to this.
76          */
77         SearchPath& operator+= (const SearchPath& spath);
78
79         /**
80          * Add another directory path to the search path.
81          */
82         SearchPath& operator+= (const std::string& directory_path);
83         
84         /**
85          * Concatenate another SearchPath onto this.
86          */
87         SearchPath& operator+ (const SearchPath& other);
88         
89         /**
90          * Add another path to the search path.
91          */
92         SearchPath& operator+ (const std::string& directory_path);
93
94         /**
95          * Add a sub-directory to each path in the search path.
96          * @param subdir The directory name, it should not contain 
97          * any path separating tokens.
98          */
99         SearchPath& add_subdirectory_to_paths (const std::string& subdir);
100
101 protected:
102
103         void add_directory (const std::string& directory_path);
104         void add_directories (const std::vector<std::string>& paths);
105 };
106
107 } // namespace PBD
108
109 #endif