00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00040 #ifndef LIMAL_PATH_PATHNAME_HPP
00041 #define LIMAL_PATH_PATHNAME_HPP
00042
00043 #include <limal/config.h>
00044 #include <blocxx/String.hpp>
00045 #include <blocxx/List.hpp>
00046 #include <iosfwd>
00047
00048
00049
00050 namespace LIMAL_NAMESPACE
00051 {
00052 namespace path
00053 {
00054
00055
00063 class PathName
00064 {
00065 public:
00066 typedef blocxx::List<blocxx::String> List;
00067
00072 PathName();
00073
00078 PathName(const PathName &path);
00079
00087 PathName(const PathName::List &list);
00088
00095 PathName(const blocxx::String &name);
00102 PathName(const char *name);
00103
00107 virtual ~PathName();
00108
00116 PathName & operator= (const PathName &path);
00117
00126 PathName & operator+=(const PathName &path);
00127
00133 blocxx::String toString() const;
00134
00146 PathName::List toList() const;
00147
00157 blocxx::String prefix() const;
00158
00164 bool empty() const;
00165
00172 bool absolute() const;
00173
00180 bool relative() const;
00181
00195 PathName dirName() const;
00196
00211 static PathName dirName(const PathName &path);
00212
00224 blocxx::String baseName() const;
00225
00240 static blocxx::String baseName(const PathName &path);
00241
00252 PathName absoluteName() const;
00253
00264 static PathName absoluteName(const PathName &path);
00265
00276 PathName relativeName() const;
00277
00288 static PathName relativeName(const PathName &path);
00289
00308 PathName cat(const PathName &add) const;
00309
00328 static PathName cat(const PathName &path,
00329 const PathName &add);
00349 PathName extend(const blocxx::String &ext) const;
00350
00371 static PathName extend(const PathName &path,
00372 const blocxx::String &ext);
00373
00382 bool equal(const PathName &rpath) const;
00383
00391 static bool equal(const PathName &lpath,
00392 const PathName &rpath);
00393
00394 protected:
00406 void assign(const blocxx::String &path);
00407
00418 void assign(const PathName::List &list);
00419
00420 private:
00425 size_t m_prefix;
00426 blocxx::String m_name;
00427 };
00428
00429
00430
00431 inline bool
00432 operator==(const PathName &lname, const PathName &rname)
00433 {
00434 return PathName::equal( lname, rname);
00435 }
00436
00437
00438
00439 inline bool
00440 operator!=(const PathName &lname, const PathName &rname)
00441 {
00442 return !PathName::equal( lname, rname);
00443 }
00444
00445
00446
00447 inline PathName
00448 operator+ (const PathName &lname, const PathName &rname)
00449 {
00450 return PathName::cat( lname, rname);
00451 }
00452
00453
00454
00455 extern std::ostream &
00456 operator<<(std::ostream &ostr, const PathName &path);
00457
00458
00459
00460 }
00461 }
00462
00463 #endif // LIMAL_PATH_PATHNAME_HPP
00464