mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 11:43:49 +00:00
2b443ba887
Summary: implemented a commond line shell to talk with leveldb thrift server, which is based on state pattern and can be easily extended. Test Plan: build and run Reviewers: dhruba, zshao, heyongqiang Differential Revision: https://reviews.facebook.net/D4713
52 lines
1,005 B
C++
52 lines
1,005 B
C++
#ifndef TOOLS_SHELL_SHELLCONTEXT
|
|
#define TOOLS_SHELL_SHELLCONTEXT
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <boost/utility.hpp>
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include "DB.h"
|
|
#include "DBClientProxy.h"
|
|
|
|
class ShellState;
|
|
|
|
class ShellContext : private boost::noncopyable {
|
|
public:
|
|
void changeState(ShellState * pState);
|
|
|
|
void stop(void);
|
|
|
|
bool ParseInput(void);
|
|
|
|
void connect(void);
|
|
|
|
void get(const std::string & db,
|
|
const std::string & key);
|
|
|
|
void put(const std::string & db,
|
|
const std::string & key,
|
|
const std::string & value);
|
|
|
|
void scan(const std::string & db,
|
|
const std::string & start_key,
|
|
const std::string & end_key,
|
|
const std::string & limit);
|
|
|
|
void create(const std::string & db);
|
|
|
|
void run(void);
|
|
|
|
ShellContext(int argc, char ** argv);
|
|
|
|
private:
|
|
ShellState * pShellState_;
|
|
bool exit_;
|
|
int argc_;
|
|
char ** argv_;
|
|
int port_;
|
|
boost::shared_ptr<leveldb::DBClientProxy> clientProxy_;
|
|
};
|
|
|
|
#endif
|