Path.h 840 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef QLOW_UTIL_PATH_H_
  2. #define QLOW_UTIL_PATH_H_
  3. #include <string>
  4. #include <utility>
  5. namespace qlow::util
  6. {
  7. class Path;
  8. }
  9. class qlow::util::Path
  10. {
  11. std::string path;
  12. static const std::string dirSeparator;
  13. public:
  14. inline Path(std::string path) :
  15. path{ std::move(path) }
  16. {
  17. }
  18. inline Path(const char* path) :
  19. path{ path }
  20. {
  21. }
  22. void append(const Path& other);
  23. Path parentPath(void) const;
  24. Path operator +(const std::string& op) const;
  25. /// for compatibilty with std::map
  26. inline bool operator < (const Path& other) const { return path < other.path; }
  27. operator const std::string&(void) const;
  28. const std::string& string(void) const;
  29. const char* c_str(void) const;
  30. private:
  31. bool endsWithSeparator(void) const;
  32. };
  33. #endif // QLOW_UTIL_PATH_H_