// file : cutl/fs/path.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2009 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file #ifndef CUTL_FS_PATH_HXX #define CUTL_FS_PATH_HXX #include #include #include namespace cutl { namespace fs { struct invalid_path: exception { virtual char const* what () const throw (); }; template class basic_path; typedef basic_path path; typedef basic_path wpath; template class basic_path { public: typedef std::basic_string string_type; typedef typename string_type::size_type size_type; explicit basic_path (C const* s) : path_ (s) { init (false); } explicit basic_path (string_type const& s) : path_ (s) { init (false); } public: basic_path leaf () const; basic_path directory () const; basic_path base () const; public: basic_path operator/ (basic_path const&); public: string_type string () const { return path_.empty () ? string_type (1, '/') : path_; } private: void init (bool internal); // Assume internal format. // basic_path (C const* s, size_type n) : path_ (s, n) { init (true); } private: string_type path_; }; template inline std::basic_ostream& operator<< (std::basic_ostream& os, basic_path const& p) { return os << p.string (); } } } #include #endif // CUTL_FS_PATH_HXX