00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PANDASEARCHPATH_H
00016 #define PANDASEARCHPATH_H
00017
00018 #include "dtoolbase.h"
00019
00020 #include "filename.h"
00021 #include "pvector.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class EXPCL_DTOOL DSearchPath {
00033 PUBLISHED:
00034 class EXPCL_DTOOL Results {
00035 PUBLISHED:
00036 Results();
00037 Results(const Results ©);
00038 void operator = (const Results ©);
00039 ~Results();
00040
00041 void clear();
00042 int get_num_files() const;
00043 const Filename &get_file(int n) const;
00044
00045 INLINE Filename operator [] (int n) const;
00046 INLINE int size() const;
00047
00048 void output(ostream &out) const;
00049 void write(ostream &out, int indent_level = 0) const;
00050
00051 public:
00052 void add_file(const Filename &file);
00053
00054 private:
00055 typedef pvector<Filename> Files;
00056 Files _files;
00057 };
00058
00059 DSearchPath();
00060 DSearchPath(const string &path, const string &separator = string());
00061 DSearchPath(const Filename &directory);
00062 DSearchPath(const DSearchPath ©);
00063 void operator = (const DSearchPath ©);
00064 ~DSearchPath();
00065
00066 void clear();
00067 void append_directory(const Filename &directory);
00068 void prepend_directory(const Filename &directory);
00069 void append_path(const string &path,
00070 const string &separator = string());
00071 void append_path(const DSearchPath &path);
00072 void prepend_path(const DSearchPath &path);
00073
00074 bool is_empty() const;
00075 int get_num_directories() const;
00076 const Filename &get_directory(int n) const;
00077 MAKE_SEQ(get_directories, get_num_directories, get_directory);
00078
00079 Filename find_file(const Filename &filename) const;
00080 int find_all_files(const Filename &filename, Results &results) const;
00081 INLINE Results find_all_files(const Filename &filename) const;
00082
00083 INLINE static Filename
00084 search_path(const Filename &filename, const string &path,
00085 const string &separator = string());
00086
00087 void output(ostream &out, const string &separator = string()) const;
00088 void write(ostream &out, int indent_level = 0) const;
00089
00090 private:
00091 typedef pvector<Filename> Directories;
00092 Directories _directories;
00093 };
00094
00095 INLINE ostream &operator << (ostream &out, const DSearchPath &sp) {
00096 sp.output(out);
00097 return out;
00098 }
00099
00100 #include "dSearchPath.I"
00101
00102 #endif