mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-17 11:45:50 +00:00
Move path composition knowledge into EntryPath.
This commit is contained in:
parent
489d545c60
commit
0b6e6ad1d6
3 changed files with 34 additions and 7 deletions
|
@ -27,6 +27,8 @@
|
|||
#include <boost/phoenix/bind/bind_function.hpp>
|
||||
#include <boost/phoenix/operator.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
||||
|
@ -120,4 +122,28 @@ namespace din {
|
|||
assert(parIndex < level());
|
||||
return m_stack[parIndex];
|
||||
}
|
||||
|
||||
uint32_t EntryPath::group_id() const {
|
||||
if (m_stack.empty())
|
||||
return 0;
|
||||
else
|
||||
return boost::lexical_cast<uint32_t>(m_stack.front());
|
||||
}
|
||||
|
||||
const std::string& EntryPath::group_id_as_string () const {
|
||||
static const std::string empty_string;
|
||||
if (m_stack.empty())
|
||||
return empty_string;
|
||||
else
|
||||
return m_stack.front();
|
||||
}
|
||||
|
||||
std::string EntryPath::file_path() const {
|
||||
if (m_stack.empty())
|
||||
return std::string();
|
||||
|
||||
std::ostringstream oss;
|
||||
boost::copy(boost::make_iterator_range(m_stack.begin() + 1, m_stack.end()), infix_ostream_iterator<std::string>(oss, "/"));
|
||||
return oss.str();
|
||||
}
|
||||
} //namespace din
|
||||
|
|
|
@ -32,6 +32,10 @@ namespace din {
|
|||
uint16_t level ( void ) const;
|
||||
const std::string& operator[] ( std::size_t parIndex ) const;
|
||||
|
||||
uint32_t group_id ( void ) const;
|
||||
const std::string& group_id_as_string ( void ) const;
|
||||
std::string file_path ( void ) const;
|
||||
|
||||
private:
|
||||
using StackType = std::vector<std::string>;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <sstream>
|
||||
#include <ciso646>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace din {
|
||||
|
@ -91,9 +90,8 @@ namespace din {
|
|||
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(sets_info)));
|
||||
}
|
||||
else {
|
||||
const auto start_from = curr_path.find('/', 1);
|
||||
auto path_prefix = boost::string_ref(curr_path).substr(start_from == curr_path.npos ? curr_path.size() : start_from + 1);
|
||||
const auto set_id = boost::lexical_cast<uint32_t>(parDir[0]);
|
||||
auto path_prefix = parDir.file_path();
|
||||
const auto set_id = parDir.group_id();
|
||||
auto files_info = m_db->file_details<FileDetail_Path>(set_id, parDir.level(), path_prefix);
|
||||
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(files_info)));
|
||||
}
|
||||
|
@ -116,10 +114,9 @@ namespace din {
|
|||
assert(false); //not implemented
|
||||
}
|
||||
else {
|
||||
const auto start_from = curr_path.find('/', 1);
|
||||
auto path_prefix = boost::string_ref(curr_path).substr(start_from == curr_path.npos ? curr_path.size() : start_from + 1);
|
||||
const auto set_id = boost::lexical_cast<uint32_t>(parDir[0]);
|
||||
assert(parDir.level() > 0);
|
||||
const auto set_id = parDir.group_id();
|
||||
const auto path_prefix = parDir.file_path();
|
||||
auto file_list = m_db->paths_starting_by(set_id, parDir.level() - 1, path_prefix);
|
||||
m_cache.push_back(std::make_pair(curr_path, file_list));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue