Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ZORBA_PATH_H
00018 #define ZORBA_PATH_H
00019
00020 #include <string>
00021 #include <iostream>
00022 #include <zorba/config.h>
00023
00024 namespace zorba {
00025
00026 class ZORBA_DLL_PUBLIC filesystem_path {
00027 private:
00028 std::string path;
00029
00030 void canonicalize ();
00031
00032 protected:
00033 std::string
00034 getPathString() const;
00035
00036 public:
00037 enum flags_t {
00038 CONVERT_SLASHES = 1,
00039 RESOLVE = 2
00040 };
00041
00042 public:
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 static std::string normalize_path(std::string const &in, std::string const &base = "");
00061
00062
00063 filesystem_path ();
00064
00065 filesystem_path (const std::string &path_, int flags = 0);
00066
00067 filesystem_path (const filesystem_path &base, const filesystem_path &rel) {
00068 if (rel.is_complete ())
00069 *this = rel;
00070 else {
00071 *this = base.get_path () + get_directory_separator () + rel.get_path ();
00072 canonicalize ();
00073 }
00074 }
00075
00076 filesystem_path &operator = (const std::string &p_)
00077 { path = p_; canonicalize (); return *this; }
00078
00079 const std::string &get_path () const { return path; }
00080 const char *c_str () const { return path.c_str (); }
00081 operator const std::string & () const { return path; }
00082
00083 bool is_complete () const;
00084 bool is_root () const;
00085 void resolve_relative ();
00086
00087 filesystem_path branch_path () const;
00088
00089 static const char *get_directory_separator ();
00090 static const char *get_path_separator ();
00091 };
00092
00093 inline std::ostream &operator<< (std::ostream &os, const filesystem_path &p) {
00094 return os << p.get_path ();
00095 }
00096
00097
00098 }
00099 #endif
00100
00101
00102
00103
00104
00105