00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019
00020
00021 #ifndef SOME_XPPATH_HEADER
00022 #define SOME_XPPATH_HEADER
00023
00024 #include<string>
00025 #include<list>
00026
00027 namespace SOME
00028 {
00029
00030
00031
00032
00033
00034 class XPPath
00035 {
00036 public:
00037 typedef std::list< std::string >::iterator iterator;
00038 typedef std::list< std::string >::size_type size_type;
00039 iterator begin()
00040 {
00041 return file_list.begin();
00042 }
00043 iterator end()
00044 {
00045 return file_list.end();
00046 }
00047 size_type size()
00048 {
00049 return file_list.size();
00050 }
00051
00052 XPPath()
00053 {}
00054
00055
00056 XPPath( std::string path )
00057 {
00058 set(path);
00059 }
00060
00061
00062 bool isFile()
00063 {
00064 return isfile;
00065 }
00066 bool isDir()
00067 {
00068 return isdir;
00069 }
00070
00071 void operator=( std::string path )
00072 {
00073 set(path);
00074 }
00075
00076 00077 00078
00079
00080 void set( std::string path )
00081 {
00082
00083 xppath=path;
00084
00085 ppath = parsePath( path );
00086
00087 checkPath( ppath );
00088
00089 if(isfile)
00090 file_list.push_back( ppath );
00091 else
00092 enumDirectory( ppath );
00093
00094 }
00095
00096 protected:
00097
00098
00099
00100 virtual void checkPath( std::string path )=0;
00101
00102
00103 virtual void enumDirectory(std::string path)=0;
00104
00105 std::string parsePath( std::string path )
00106 {
00107 if(delimit!="/")
00108 while (int pos = path.find(delimit,0)!=std::string::npos)
00109 path.replace(pos, 1, delimit);
00110
00111
00112 return path;
00113 }
00114 std::string delimit;
00115 bool isfile;
00116 bool isdir;
00117 std::list<std::string> file_list;
00118
00119 private:
00120
00121 std::string ppath;
00122 std::string xppath;
00123 };
00124
00125 }
00126 #endif