path.hpp
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
00024
00029
00030 #ifndef PATH_HPP
00031 #define PATH_HPP
00032
00033 #include "../my_config.h"
00034 #include <list>
00035 #include <string>
00036 #include "erreurs.hpp"
00037
00038 #define FAKE_ROOT path(string("<ROOT>"))
00039
00040 namespace libdar
00041 {
00042
00044
00047
00048 class path
00049 {
00050 public :
00052
00055 path(const std::string & s);
00056
00058
00061 path(const char *s) { *this = path(std::string(s)); };
00062
00064 path(const path & ref);
00065
00067 path & operator = (const path & ref);
00068
00070 bool operator == (const path & ref) const;
00071
00073
00075 std::string basename() const;
00076
00078
00080 void reset_read() { reading = dirs.begin(); };
00081
00083
00087 bool read_subdir(std::string & r);
00088
00090 bool is_relative() const { return relative; };
00091
00093
00099 bool pop(std::string & arg);
00100
00102
00108 bool pop_front(std::string & arg);
00109
00111
00115 path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; };
00116
00117
00119
00122 path & operator += (const path & arg);
00123
00125
00128 bool is_subdir_of(const path & p, bool case_sensit) const;
00129
00131
00133 std::string display() const;
00134
00138 unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); };
00139
00140 private :
00141 std::list<std::string>::iterator reading;
00142 std::list<std::string> dirs;
00143 bool relative;
00144
00145 void reduce();
00146 };
00147
00148
00149 }
00150
00151 #endif