> The XQuery Processor
00001 #ifndef ZORBA_PATH_H 00002 #define ZORBA_PATH_H 00003 00004 #include <string> 00005 #include <iostream> 00006 00007 namespace zorba { 00008 00009 class filesystem_path { 00010 private: 00011 std::string path; 00012 void canonicalize (); 00013 00014 public: 00015 typedef enum { CONVERT_SLASHES = 1 << 0, 00016 RESOLVE = 1 << 1 00017 } flags_t; 00018 00019 public: 00020 const std::string &get_path () const { return path; } 00021 const char *c_str () { return path.c_str (); } 00022 operator const std::string & () const { return path; } 00023 filesystem_path (const std::string &path_, int flags = 0); 00024 filesystem_path (const filesystem_path &base, const filesystem_path &rel) { 00025 if (rel.is_complete ()) 00026 *this = rel; 00027 else { 00028 *this = base.get_path () + get_path_separator () + rel.get_path (); 00029 canonicalize (); 00030 } 00031 } 00032 // from current dir 00033 filesystem_path (); 00034 filesystem_path &operator = (const std::string &p_) 00035 { path = p_; canonicalize (); return *this; } 00036 00037 bool is_complete () const; 00038 bool is_root () const; 00039 void resolve_relative (); 00040 00041 filesystem_path branch_path () const; 00042 00043 static const char *get_path_separator (); 00044 }; 00045 00046 inline std::ostream &operator<< (std::ostream &os, const filesystem_path &p) 00047 { os << p.get_path (); return os; } 00048 00049 } 00050 00051 #endif 00052 00053 /* 00054 * Local variables: 00055 * mode: c++ 00056 * End: 00057 */