mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-19 12:04:54 +00:00
Improve interface and add some getters.
This commit is contained in:
parent
485796db48
commit
3f8cda06aa
4 changed files with 21 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -107,4 +107,9 @@ namespace din {
|
|||
dummy.push_back(StringListPair(parString, parBaseString));
|
||||
this->update(dummy.begin(), dummy.end());
|
||||
}
|
||||
|
||||
template <typename C, typename Str, typename StrRef>
|
||||
auto StringPool<C, Str, StrRef>::get_stringref_source (std::size_t parIndex) const -> const string_type* {
|
||||
return m_strings[parIndex].second;
|
||||
}
|
||||
} //namespace din
|
||||
|
|
Loading…
Add table
Reference in a new issue