Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_pathsearch_h)
00024 #define octave_pathsearch_h 1
00025
00026 #include <string>
00027
00028 #include "str-vec.h"
00029
00030 class
00031 OCTAVE_API
00032 dir_path
00033 {
00034 public:
00035
00036 dir_path (const std::string& s = std::string (),
00037 const std::string& d = std::string ())
00038 : p_orig (s), p_default (d), initialized (false), p (), pv ()
00039 {
00040 if (! p_orig.empty ())
00041 init ();
00042 }
00043
00044 dir_path (const dir_path& dp)
00045 : p_orig (dp.p_orig), p_default (dp.p_default),
00046 initialized (dp.initialized), p (dp.p), pv (dp.pv)
00047 { }
00048
00049 dir_path& operator = (const dir_path& dp)
00050 {
00051 p_orig = dp.p_orig;
00052 p_default = dp.p_default;
00053 initialized = dp.initialized;
00054 p = dp.p;
00055 pv = dp.pv;
00056 return *this;
00057 }
00058
00059 ~dir_path (void) { }
00060
00061 void set (const std::string& s)
00062 {
00063 initialized = false;
00064 p_orig = s;
00065 init ();
00066 }
00067
00068 string_vector elements (void);
00069 string_vector all_directories (void);
00070
00071 std::string find_first (const std::string&);
00072 std::string find (const std::string& nm) { return find_first (nm); }
00073
00074 string_vector find_all (const std::string&);
00075
00076 std::string find_first_of (const string_vector& names);
00077 string_vector find_all_first_of (const string_vector& names);
00078
00079 void rehash (void)
00080 {
00081 initialized = false;
00082 init ();
00083 }
00084
00085 static char path_sep_char (void)
00086 {
00087 return static_members::path_sep_char ();
00088 }
00089
00090 static void path_sep_char (char c)
00091 {
00092 static_members::path_sep_char (c);
00093 }
00094
00095 static std::string path_sep_str (void)
00096 {
00097 return static_members::path_sep_str ();
00098 }
00099
00100 static bool is_path_sep (char c) { return c == path_sep_char (); }
00101
00102 private:
00103
00104
00105 std::string p_orig;
00106
00107
00108
00109 std::string p_default;
00110
00111
00112 bool initialized;
00113
00114
00115
00116 std::string p;
00117
00118
00119 string_vector pv;
00120
00121 void init (void);
00122
00123
00124
00125
00126
00127 class OCTAVE_API static_members
00128 {
00129 public:
00130
00131 static_members (void);
00132
00133 static char path_sep_char (void)
00134 {
00135 return instance_ok () ? instance->xpath_sep_char : 0;
00136 }
00137
00138 static void path_sep_char (char c)
00139 {
00140 if (instance_ok ())
00141 {
00142 instance->xpath_sep_char = c;
00143 instance->xpath_sep_str = std::string (1, c);
00144 }
00145 }
00146
00147 static std::string path_sep_str (void)
00148 {
00149 return instance_ok () ? instance->xpath_sep_str : std::string ();
00150 }
00151
00152 private:
00153
00154 static static_members *instance;
00155
00156 static void cleanup_instance (void) { delete instance; instance = 0; }
00157
00158 static bool instance_ok (void);
00159
00160
00161
00162 static_members (const static_members&);
00163
00164 static_members& operator = (const static_members&);
00165
00166 char xpath_sep_char;
00167
00168 std::string xpath_sep_str;
00169 };
00170 };
00171
00172 #endif