diff --git a/src/pathname.cpp b/src/pathname.cpp index 0772329..c7565fc 100644 --- a/src/pathname.cpp +++ b/src/pathname.cpp @@ -59,10 +59,10 @@ namespace din { } } //unnamed namespace - PathName::PathName (const char* parPath) { - if (nullptr != parPath && *parPath != '\0') { - m_absolute = ('/' == *parPath); - std::string path(parPath); + PathName::PathName (boost::string_ref parPath) { + if (not parPath.empty()) { + m_absolute = ('/' == parPath.front()); + std::string path(parPath.begin(), parPath.end()); const auto count = count_grouped(path, '/'); const std::size_t trailing = (path.back() == '/' ? 1 : 0); @@ -75,6 +75,7 @@ namespace din { } else { m_original_path = nullptr; + m_absolute = false; } } @@ -122,4 +123,8 @@ namespace din { const boost::string_ref ref(src); m_pool.insert(ref, &src); } + + void PathName::join (boost::string_ref parOther, const std::string* parSource) { + m_pool.insert(parOther, parSource); + } } //namespace din diff --git a/src/pathname.hpp b/src/pathname.hpp index 387ab25..7377b7f 100644 --- a/src/pathname.hpp +++ b/src/pathname.hpp @@ -27,16 +27,20 @@ namespace din { class PathName { public: - explicit PathName ( const char* parPath ); + PathName ( PathName&& ) = default; + PathName ( const PathName& ) = default; + explicit PathName ( boost::string_ref parPath ); ~PathName ( void ) noexcept = default; - bool is_absolute ( void ) const; + bool is_absolute ( void ) const { return m_absolute; } std::string path ( void ) const; const std::string& original_path ( void ) const { return (m_original_path ? *m_original_path : m_empty_str); } std::size_t atom_count ( void ) const; const boost::string_ref operator[] ( std::size_t parIndex ) const; void join ( const PathName& parOther ); void join ( const char* parOther ); + void join ( boost::string_ref parOther, const std::string* parSource ); + const std::string* get_stringref_source ( std::size_t parIndex ) const; private: static const std::string m_empty_str; diff --git a/src/stringpool.hpp b/src/stringpool.hpp index b2f6587..bd5820a 100644 --- a/src/stringpool.hpp +++ b/src/stringpool.hpp @@ -55,6 +55,7 @@ namespace din { bool empty ( void ) const { return m_strings.empty(); } const_iterator begin ( void ) const; const_iterator end ( void ) const; + const string_type* get_stringref_source ( std::size_t parIndex ) const; private: PoolType m_pool; diff --git a/src/stringpool.inl b/src/stringpool.inl index f05d6c3..4ccefcb 100644 --- a/src/stringpool.inl +++ b/src/stringpool.inl @@ -107,4 +107,9 @@ namespace din { dummy.push_back(StringListPair(parString, parBaseString)); this->update(dummy.begin(), dummy.end()); } + + template + auto StringPool::get_stringref_source (std::size_t parIndex) const -> const string_type* { + return m_strings[parIndex].second; + } } //namespace din