24 #if !defined (octave_load_path_h)
25 #define octave_load_path_h 1
42 : dir_info_list (), fcn_map (), private_fcn_map (), method_map (),
47 typedef void (*hook_fcn_ptr) (
const std::string& dir);
60 instance->do_clear ();
63 static void set (
const std::string& p,
bool warn =
false)
66 instance->do_set (p, warn);
69 static void append (
const std::string& dir,
bool warn =
false)
72 instance->do_append (dir, warn);
75 static void prepend (
const std::string& dir,
bool warn =
false)
78 instance->do_prepend (dir, warn);
81 static bool remove (
const std::string& dir)
83 return instance_ok () ? instance->do_remove (dir) :
false;
86 static void update (
void)
89 instance->do_update ();
92 static bool contains_canonical (
const std::string& dir_name)
94 return instance_ok () ? instance->do_contains_canonical (dir_name) :
false;
97 static std::string find_method (
const std::string& class_name,
98 const std::string& meth,
99 std::string& dir_name)
101 return instance_ok ()
102 ? instance->do_find_method (class_name, meth, dir_name)
106 static std::string find_method (
const std::string& class_name,
107 const std::string& meth)
109 std::string dir_name;
110 return find_method (class_name, meth, dir_name);
113 static std::list<std::string> methods (
const std::string& class_name)
115 return instance_ok ()
116 ? instance->do_methods (class_name) : std::list<std::string> ();
119 static std::list<std::string> overloads (
const std::string& meth)
121 return instance_ok ()
122 ? instance->do_overloads (meth) : std::list<std::string> ();
125 static std::string find_fcn (
const std::string& fcn, std::string& dir_name)
127 return instance_ok ()
128 ? instance->do_find_fcn (fcn, dir_name) : std::string ();
131 static std::string find_fcn (
const std::string& fcn)
133 std::string dir_name;
134 return find_fcn (fcn, dir_name);
137 static std::string find_private_fcn (
const std::string& dir,
138 const std::string& fcn)
140 return instance_ok ()
141 ? instance->do_find_private_fcn (dir, fcn) : std::string ();
144 static std::string find_fcn_file (
const std::string& fcn)
146 std::string dir_name;
148 return instance_ok () ?
149 instance->do_find_fcn (fcn, dir_name, M_FILE) : std::string ();
152 static std::string find_oct_file (
const std::string& fcn)
154 std::string dir_name;
156 return instance_ok () ?
157 instance->do_find_fcn (fcn, dir_name, OCT_FILE) : std::string ();
160 static std::string find_mex_file (
const std::string& fcn)
162 std::string dir_name;
164 return instance_ok () ?
165 instance->do_find_fcn (fcn, dir_name, MEX_FILE) : std::string ();
168 static std::string find_file (
const std::string& file)
170 return instance_ok ()
171 ? instance->do_find_file (file) : std::string ();
174 static std::string find_dir (
const std::string& dir)
176 return instance_ok ()
177 ? instance->do_find_dir (dir) : std::string ();
182 return instance_ok ()
188 return instance_ok () ?
189 instance->do_find_first_of (files) : std::string ();
194 return instance_ok () ?
200 return instance_ok () ? instance->do_dirs () :
string_vector ();
203 static std::list<std::string> dir_list (
void)
205 return instance_ok ()
206 ? instance->do_dir_list () : std::list<std::string> ();
211 return instance_ok ()
217 return instance_ok () ? instance->do_fcn_names () :
string_vector ();
220 static std::string path (
void)
222 return instance_ok () ? instance->do_path () : std::string ();
225 static void display (std::ostream& os)
228 instance->do_display (os);
235 static void set_command_line_path (
const std::string& p)
243 static std::string get_command_line_path (
void)
245 return instance_ok () ? instance->do_get_command_line_path ()
249 static std::string system_path (
void)
251 return instance_ok () ? instance->do_system_path () : std::string ();
256 static const int M_FILE = 1;
257 static const int OCT_FILE = 2;
258 static const int MEX_FILE = 4;
272 class_info (
void) : method_file_map (), private_file_map () { }
275 : method_file_map (ci.method_file_map),
276 private_file_map (ci.private_file_map) { }
304 : dir_name (), abs_dir_name (), is_relative (false),
305 dir_mtime (), dir_time_last_checked (),
306 all_files (), fcn_files (), private_file_map (), method_file_map ()
310 : dir_name (d), abs_dir_name (), is_relative (false),
311 dir_mtime (), dir_time_last_checked (),
312 all_files (), fcn_files (), private_file_map (), method_file_map ()
318 : dir_name (di.dir_name), abs_dir_name (di.abs_dir_name),
319 is_relative (di.is_relative),
320 dir_mtime (di.dir_mtime),
321 dir_time_last_checked (di.dir_time_last_checked),
322 all_files (di.all_files), fcn_files (di.fcn_files),
323 private_file_map (di.private_file_map),
324 method_file_map (di.method_file_map) { }
364 void get_private_file_map (
const std::string&
d);
366 void get_method_file_map (
const std::string&
d,
367 const std::string& class_name);
376 file_info (
const std::string&
d,
int t) : dir_name (d), types (t) { }
379 : dir_name (fi.dir_name), types (fi.types) { }
433 typedef std::map<std::string, dir_info::fcn_file_map_type>
469 static bool instance_ok (
void);
471 const_dir_info_list_iterator find_dir_info (
const std::string& dir)
const;
472 dir_info_list_iterator find_dir_info (
const std::string& dir);
474 bool contains (
const std::string& dir)
const;
476 bool do_contains_canonical (
const std::string& dir)
const;
478 void move_fcn_map (
const std::string& dir,
481 void move_method_map (
const std::string& dir,
bool at_end);
483 void move (std::list<dir_info>::iterator i,
bool at_end);
487 void do_clear (
void);
489 void do_set (
const std::string& p,
bool warn,
bool is_init =
false);
491 void do_append (
const std::string& dir,
bool warn);
493 void do_prepend (
const std::string& dir,
bool warn);
495 void do_add (
const std::string& dir,
bool at_end,
bool warn);
497 void remove_fcn_map (
const std::string& dir,
const string_vector& fcn_files);
499 void remove_private_fcn_map (
const std::string& dir);
501 void remove_method_map (
const std::string& dir);
503 bool do_remove (
const std::string& dir);
505 void do_update (
void)
const;
508 check_file_type (std::string& fname,
int type,
int possible_types,
509 const std::string& fcn,
const char *who);
511 std::string do_find_fcn (
const std::string& fcn,
512 std::string& dir_name,
513 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
515 std::string do_find_private_fcn (
const std::string& dir,
516 const std::string& fcn,
517 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
519 std::string do_find_method (
const std::string& class_name,
520 const std::string& meth,
521 std::string& dir_name,
522 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
524 std::list<std::string> do_methods (
const std::string& class_name)
const;
526 std::list<std::string> do_overloads (
const std::string& meth)
const;
528 std::string do_find_file (
const std::string& file)
const;
530 std::string do_find_dir (
const std::string& dir)
const;
532 string_vector do_find_matching_dirs (
const std::string& dir)
const;
534 std::string do_find_first_of (
const string_vector& files)
const;
540 std::list<std::string> do_dir_list (
void)
const;
542 string_vector do_files (
const std::string& dir,
bool omit_exts)
const;
546 std::string do_path (
void)
const;
548 friend void print_types (std::ostream& os,
int types);
555 void do_display (std::ostream& os)
const;
559 std::string do_get_command_line_path (
void)
const
562 void add_to_fcn_map (
const dir_info& di,
bool at_end)
const;
564 void add_to_private_fcn_map (
const dir_info& di)
const;
566 void add_to_method_map (
const dir_info& di,
bool at_end)
const;
568 friend dir_info::fcn_file_map_type
get_fcn_files (
const std::string&
d);