mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-25 00:53:43 +00:00
Rename DirManager to GenericPath.
This commit is contained in:
parent
138f112254
commit
9071b25dec
6 changed files with 24 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ cscope.in.out
|
|||
cscope.po.out
|
||||
cscope.out
|
||||
tags
|
||||
autom4te.cache/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright 2015, Michele Santullo
|
||||
/* Copyright 2016, Michele Santullo
|
||||
* This file is part of "dindexer".
|
||||
*
|
||||
* "dindexer" is free software: you can redistribute it and/or modify
|
||||
|
|
|
@ -4,7 +4,7 @@ add_executable(${PROJECT_NAME}
|
|||
main.cpp
|
||||
commandline.cpp
|
||||
commandprocessor.cpp
|
||||
dirmanager.cpp
|
||||
genericpath.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dirmanager.hpp"
|
||||
#include "genericpath.hpp"
|
||||
#include "helpers/infix_iterator.hpp"
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
|
@ -62,7 +62,7 @@ namespace din {
|
|||
}
|
||||
} //unnamed namespace
|
||||
|
||||
void DirManager::push_piece (const std::string& parPiece) {
|
||||
void GenericPath::push_piece (const std::string& parPiece) {
|
||||
using boost::spirit::qi::parse;
|
||||
|
||||
PathGrammar<std::string::const_iterator> gramm;
|
||||
|
@ -97,7 +97,7 @@ namespace din {
|
|||
assert(parse_result);
|
||||
}
|
||||
|
||||
std::string DirManager::to_string() const {
|
||||
std::string GenericPath::to_string() const {
|
||||
std::ostringstream oss;
|
||||
oss << '/';
|
||||
boost::copy(m_stack, infix_ostream_iterator<std::string>(oss, "/"));
|
|
@ -22,9 +22,9 @@
|
|||
#include <string>
|
||||
|
||||
namespace din {
|
||||
class DirManager {
|
||||
class GenericPath {
|
||||
public:
|
||||
DirManager ( void ) = default;
|
||||
GenericPath ( void ) = default;
|
||||
|
||||
void push_piece ( const std::string& parPiece );
|
||||
std::string to_string ( void ) const;
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "commandline.hpp"
|
||||
#include "commandprocessor.hpp"
|
||||
#include "dirmanager.hpp"
|
||||
#include "genericpath.hpp"
|
||||
#include <iostream>
|
||||
#include <ciso646>
|
||||
#include <string>
|
||||
|
@ -28,7 +28,8 @@ namespace {
|
|||
void do_navigation ( void );
|
||||
|
||||
bool on_exit ( void );
|
||||
void on_pwd ( const din::DirManager& parDirMan );
|
||||
void on_pwd ( const din::GenericPath& parDirMan );
|
||||
void on_ls ( const din::GenericPath& parDirMan );
|
||||
} //unnamed namespace
|
||||
|
||||
int main (int parArgc, char* parArgv[]) {
|
||||
|
@ -53,25 +54,34 @@ namespace {
|
|||
bool on_exit() {
|
||||
return true;
|
||||
}
|
||||
void on_pwd (const din::DirManager& parDirMan) {
|
||||
|
||||
void on_pwd (const din::GenericPath& parDirMan) {
|
||||
std::cout << parDirMan.to_string() << '\n';
|
||||
}
|
||||
|
||||
void do_navigation() {
|
||||
void on_ls (const din::GenericPath& parDirMan) {
|
||||
|
||||
}
|
||||
|
||||
void do_navigation (din::DBSource& parDB) {
|
||||
auto& inp = std::cin;
|
||||
|
||||
bool running = true;
|
||||
std::string curr_line;
|
||||
din::CommandProcessor proc;
|
||||
din::DirManager dir_man;
|
||||
din::GenericPath dir_man;
|
||||
proc.add_command("exit", &on_exit, 0);
|
||||
proc.add_command("cd", std::function<void(const std::string&)>(std::bind(&din::DirManager::push_piece, &dir_man, std::placeholders::_1)), 1);
|
||||
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("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(dir_man))), 0);
|
||||
do {
|
||||
do {
|
||||
std::getline(inp, curr_line);
|
||||
} while (curr_line.empty());
|
||||
running = proc.exec_command(curr_line);
|
||||
} while (running);
|
||||
|
||||
parDB.disconnect();
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
|
Loading…
Reference in a new issue