1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-29 01:33:46 +00:00

Rename GenericPath to EntryPath.

This commit is contained in:
King_DuckZ 2016-04-28 10:20:27 +02:00
parent b71a94ef70
commit 489d545c60
7 changed files with 23 additions and 23 deletions

View file

@ -4,7 +4,7 @@ add_executable(${PROJECT_NAME}
main.cpp
commandline.cpp
commandprocessor.cpp
genericpath.cpp
entrypath.cpp
dbsource.cpp
linereader.cpp
listdircontent.cpp

View file

@ -15,7 +15,7 @@
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#include "genericpath.hpp"
#include "entrypath.hpp"
#include "helpers/infix_iterator.hpp"
#include <boost/spirit/include/qi_core.hpp>
#include <boost/spirit/include/qi_parse.hpp>
@ -67,7 +67,7 @@ namespace din {
}
} //unnamed namespace
void GenericPath::push_piece (const std::string& parPiece) {
void EntryPath::push_piece (const std::string& parPiece) {
using boost::spirit::qi::parse;
PathGrammar<std::string::const_iterator> gramm;
@ -105,18 +105,18 @@ namespace din {
}
}
std::string GenericPath::to_string() const {
std::string EntryPath::to_string() const {
std::ostringstream oss;
oss << '/';
boost::copy(m_stack, infix_ostream_iterator<std::string>(oss, "/"));
return oss.str();
}
uint16_t GenericPath::level() const {
uint16_t EntryPath::level() const {
return static_cast<uint16_t>(m_stack.size());
}
const std::string& GenericPath::operator[] (std::size_t parIndex) const {
const std::string& EntryPath::operator[] (std::size_t parIndex) const {
assert(parIndex < level());
return m_stack[parIndex];
}

View file

@ -23,9 +23,9 @@
#include <cstdint>
namespace din {
class GenericPath {
class EntryPath {
public:
GenericPath ( void ) = default;
EntryPath ( void ) = default;
void push_piece ( const std::string& parPiece );
std::string to_string ( void ) const;

View file

@ -18,7 +18,7 @@
#include "linereader.hpp"
#include "listdircontent.hpp"
#include "dindexer-common/readline_wrapper.hpp"
#include "genericpath.hpp"
#include "entrypath.hpp"
#include <cassert>
#include <ciso646>
#include <vector>
@ -27,7 +27,7 @@
namespace din {
namespace {
std::vector<std::string> list_matches (const ListDirContent& parLS, const std::string& parCurrPath, const std::string& parPrefix) {
GenericPath full_prefix;
EntryPath full_prefix;
if (not parCurrPath.empty()) {
full_prefix.push_piece(parCurrPath);
}

View file

@ -16,7 +16,7 @@
*/
#include "listdircontent.hpp"
#include "genericpath.hpp"
#include "entrypath.hpp"
#include "dbsource.hpp"
#include "helpers/infix_iterator.hpp"
#include <cassert>
@ -76,7 +76,7 @@ namespace din {
assert(m_db);
}
auto ListDirContent::ls (const GenericPath& parDir) const -> const ListType& {
auto ListDirContent::ls (const EntryPath& parDir) const -> const ListType& {
const std::string curr_path = parDir.to_string();
{
const auto* cached_item = find_and_refresh_in_cache(m_cache, curr_path);
@ -102,7 +102,7 @@ namespace din {
return m_cache.back().second;
}
auto ListDirContent::ls ( GenericPath parDir, const std::string& parStartWith ) const -> const ListType& {
auto ListDirContent::ls ( EntryPath parDir, const std::string& parStartWith ) const -> const ListType& {
parDir.push_piece(parStartWith);
const std::string curr_path = parDir.to_string();

View file

@ -24,7 +24,7 @@
#include <vector>
namespace din {
class GenericPath;
class EntryPath;
class DBSource;
class ListDirContent {
@ -34,8 +34,8 @@ namespace din {
explicit ListDirContent ( DBSource* parDB );
~ListDirContent ( void ) noexcept = default;
const ListType& ls ( const GenericPath& parDir ) const;
const ListType& ls ( GenericPath parDir, const std::string& parStartWith ) const;
const ListType& ls ( const EntryPath& parDir ) const;
const ListType& ls ( EntryPath parDir, const std::string& parStartWith ) const;
private:
mutable boost::circular_buffer<CachedItemType> m_cache;

View file

@ -18,7 +18,7 @@
#include "commandline.hpp"
#include "commandprocessor.hpp"
#include "dindexer-common/settings.hpp"
#include "genericpath.hpp"
#include "entrypath.hpp"
#include "dbsource.hpp"
#include "dindexerConfig.h"
#include "linereader.hpp"
@ -34,8 +34,8 @@ namespace {
void do_navigation ( din::DBSource& parDB );
bool on_exit ( void );
void on_pwd ( const din::GenericPath& parDirMan );
void on_ls ( const din::ListDirContent& parLS, const din::GenericPath& parDirMan );
void on_pwd ( const din::EntryPath& parDirMan );
void on_ls ( const din::ListDirContent& parLS, const din::EntryPath& parDirMan );
} //unnamed namespace
int main (int parArgc, char* parArgv[]) {
@ -72,11 +72,11 @@ namespace {
return true;
}
void on_pwd (const din::GenericPath& parDirMan) {
void on_pwd (const din::EntryPath& parDirMan) {
std::cout << parDirMan.to_string() << '\n';
}
void on_ls (const din::ListDirContent& parLS, const din::GenericPath& parDirMan) {
void on_ls (const din::ListDirContent& parLS, const din::EntryPath& parDirMan) {
const auto& ls_result = parLS.ls(parDirMan);
boost::copy(ls_result, std::ostream_iterator<std::string>(std::cout, "\n"));
}
@ -89,9 +89,9 @@ namespace {
bool running = true;
std::string curr_line;
din::CommandProcessor proc;
din::GenericPath dir_man;
din::EntryPath dir_man;
proc.add_command("exit", &on_exit, 0);
proc.add_command("cd", std::function<void(const std::string&)>(std::bind(&din::GenericPath::push_piece, &dir_man, std::placeholders::_1)), 1);
proc.add_command("cd", std::function<void(const std::string&)>(std::bind(&din::EntryPath::push_piece, &dir_man, std::placeholders::_1)), 1);
proc.add_command("disconnect", std::function<void()>(std::bind(&din::DBSource::disconnect, &parDB)), 0);
proc.add_command("pwd", std::function<void()>(std::bind(&on_pwd, std::ref(dir_man))), 0);
proc.add_command("ls", std::function<void()>(std::bind(on_ls, std::ref(ls), std::ref(dir_man))), 0);