OLD | NEW |
| 1 |
1 #ifndef COMMAND_H | 2 #ifndef COMMAND_H |
2 #define COMMAND_H | 3 #define COMMAND_H |
3 | 4 |
4 #include <map> | 5 #include <map> |
5 #include <stdexcept> | 6 #include <stdexcept> |
6 #include <string> | 7 #include <string> |
7 | 8 |
8 class Command | 9 class Command |
9 { | 10 { |
10 public: | 11 public: |
11 const std::string name; | 12 const std::string name; |
12 | 13 |
13 explicit Command(const std::string& name); | 14 explicit Command(const std::string& name); |
14 virtual ~Command(); | 15 virtual ~Command(); |
15 virtual void operator()(const std::string& arguments) = 0; | 16 virtual void operator()(const std::string& arguments) = 0; |
16 virtual std::string GetDescription() const = 0; | 17 virtual std::string GetDescription() const = 0; |
17 virtual std::string GetUsage() const = 0; | 18 virtual std::string GetUsage() const = 0; |
| 19 |
| 20 protected: |
| 21 void ShowUsage() const; |
18 }; | 22 }; |
19 | 23 |
20 typedef std::map<const std::string, Command*> CommandMap; | 24 typedef std::map<const std::string, Command*> CommandMap; |
21 | 25 |
22 class NoSuchCommandError : public std::runtime_error | 26 class NoSuchCommandError : public std::runtime_error |
23 { | 27 { |
24 public: | 28 public: |
25 explicit NoSuchCommandError(const std::string& commandName); | 29 explicit NoSuchCommandError(const std::string& commandName); |
26 }; | 30 }; |
27 | 31 |
28 #endif | 32 #endif |
OLD | NEW |