00001
00002
00003
00004
00005
00006
00007
00008 #ifndef FILE_IDENTIFIER_H_
00009 #define FILE_IDENTIFIER_H_
00010
00011 #include <string>
00012 #include <vector>
00013
00014 #include <boost/serialization/vector.hpp>
00015 #include <boost/serialization/map.hpp>
00016 #include <boost/serialization/list.hpp>
00017 #include <boost/serialization/string.hpp>
00018 #include <boost/serialization/version.hpp>
00019 #include <boost/serialization/split_member.hpp>
00020 #include <boost/serialization/shared_ptr.hpp>
00021 #include <boost/serialization/base_object.hpp>
00022 #include <boost/serialization/export.hpp>
00023 #include <boost/serialization/set.hpp>
00024
00025 using namespace std;
00026
00030 class FileIdentifier
00031 {
00032 friend class boost::serialization::access;
00033 template<class Archive>
00034 void serialize(Archive & ar, const unsigned int version)
00035 {
00036 ar & dirs;
00037 ar & file;
00038 }
00039
00040 private:
00041 vector<string> dirs;
00042 string file;
00043
00044
00045 public:
00046 FileIdentifier(){};
00047 FileIdentifier(string path);
00048 FileIdentifier(const FileIdentifier& other);
00049 string to_string(char separator = '/') const;
00050 const string& get_filename() const;
00051 int num_dirs();
00052 const string & get_ith_dir(int i);
00053 bool operator==(const FileIdentifier& other) const;
00054 bool operator!=(const FileIdentifier& other) const;
00055 bool operator<(const FileIdentifier& other) const;
00056 bool operator>(const FileIdentifier& other) const;
00057 void add_dir(const string& dir);
00058 void pop_dir();
00059
00060 virtual ~FileIdentifier();
00061
00062
00063
00064
00065
00066 static string construct_absolute_path(const string& path,
00067 vector<string>& path_vec);
00068
00069 static void chop_into_directories(const string& path, vector<string>& dirs);
00070
00071 friend ostream& operator <<(ostream &os, const FileIdentifier &obj);
00072
00073 };
00074
00075 ostream& operator <<(ostream &os, const FileIdentifier &obj);
00076
00077 #endif