mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-03 14:14:11 +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
|
} //unnamed namespace
|
||||||
|
|
||||||
PathName::PathName (const char* parPath) {
|
PathName::PathName (boost::string_ref parPath) {
|
||||||
if (nullptr != parPath && *parPath != '\0') {
|
if (not parPath.empty()) {
|
||||||
m_absolute = ('/' == *parPath);
|
m_absolute = ('/' == parPath.front());
|
||||||
std::string path(parPath);
|
std::string path(parPath.begin(), parPath.end());
|
||||||
|
|
||||||
const auto count = count_grouped(path, '/');
|
const auto count = count_grouped(path, '/');
|
||||||
const std::size_t trailing = (path.back() == '/' ? 1 : 0);
|
const std::size_t trailing = (path.back() == '/' ? 1 : 0);
|
||||||
|
@ -75,6 +75,7 @@ namespace din {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_original_path = nullptr;
|
m_original_path = nullptr;
|
||||||
|
m_absolute = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,4 +123,8 @@ namespace din {
|
||||||
const boost::string_ref ref(src);
|
const boost::string_ref ref(src);
|
||||||
m_pool.insert(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
|
} //namespace din
|
||||||
|
|
|
@ -27,16 +27,20 @@
|
||||||
namespace din {
|
namespace din {
|
||||||
class PathName {
|
class PathName {
|
||||||
public:
|
public:
|
||||||
explicit PathName ( const char* parPath );
|
PathName ( PathName&& ) = default;
|
||||||
|
PathName ( const PathName& ) = default;
|
||||||
|
explicit PathName ( boost::string_ref parPath );
|
||||||
~PathName ( void ) noexcept = default;
|
~PathName ( void ) noexcept = default;
|
||||||
|
|
||||||
bool is_absolute ( void ) const;
|
bool is_absolute ( void ) const { return m_absolute; }
|
||||||
std::string path ( void ) const;
|
std::string path ( void ) const;
|
||||||
const std::string& original_path ( void ) const { return (m_original_path ? *m_original_path : m_empty_str); }
|
const std::string& original_path ( void ) const { return (m_original_path ? *m_original_path : m_empty_str); }
|
||||||
std::size_t atom_count ( void ) const;
|
std::size_t atom_count ( void ) const;
|
||||||
const boost::string_ref operator[] ( std::size_t parIndex ) const;
|
const boost::string_ref operator[] ( std::size_t parIndex ) const;
|
||||||
void join ( const PathName& parOther );
|
void join ( const PathName& parOther );
|
||||||
void join ( const char* 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:
|
private:
|
||||||
static const std::string m_empty_str;
|
static const std::string m_empty_str;
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace din {
|
||||||
bool empty ( void ) const { return m_strings.empty(); }
|
bool empty ( void ) const { return m_strings.empty(); }
|
||||||
const_iterator begin ( void ) const;
|
const_iterator begin ( void ) const;
|
||||||
const_iterator end ( void ) const;
|
const_iterator end ( void ) const;
|
||||||
|
const string_type* get_stringref_source ( std::size_t parIndex ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PoolType m_pool;
|
PoolType m_pool;
|
||||||
|
|
|
@ -107,4 +107,9 @@ namespace din {
|
||||||
dummy.push_back(StringListPair(parString, parBaseString));
|
dummy.push_back(StringListPair(parString, parBaseString));
|
||||||
this->update(dummy.begin(), dummy.end());
|
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
|
} //namespace din
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue