Added option and flag parseing, now supports -p for port range.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@287 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-18 19:08:17 +00:00
parent 78d3d78ef3
commit e0f21cce78
7 changed files with 142 additions and 10 deletions
+39
View File
@@ -0,0 +1,39 @@
#ifndef RTORRENT_OPTION_PARSER_H
#define RTORRENT_OPTION_PARSER_H
#include <map>
#include <string>
#include <sigc++/slot.h>
// Throws std::runtime_error upon receiving bad input.
class OptionParser {
public:
typedef sigc::slot0<void> SlotFlag;
typedef sigc::slot1<void, const std::string&> SlotOption;
typedef sigc::slot2<void, int, int> SlotIntPair;
struct Node {
SlotOption m_slot;
bool m_useOption;
};
typedef std::map<char, Node> Container;
void insert_flag(char c, SlotFlag s);
void insert_option(char c, SlotOption s);
// Returns the index of the first non-option argument.
int process(int argc, char** argv);
static void call_int_pair(const std::string& str, SlotIntPair slot);
private:
std::string create_optstring();
void call_flag(char c, const std::string& arg);
Container m_container;
};
#endif