Clean up some header files
[lsnes.git] / command.hpp
blobace4d7d3d78ab5491cbeaf5c73d1fd3a0a49b09d
1 #ifndef _command__hpp__included__
2 #define _command__hpp__included__
4 #include <stdexcept>
5 #include <string>
8 class window;
10 /**
11 * A command.
13 class command
15 public:
16 /**
17 * Register a new command.
19 * parameter cmd: The command to register.
20 * throws std::bad_alloc: Not enough memory.
22 command(const std::string& cmd) throw(std::bad_alloc);
24 /**
25 * Deregister a command.
27 virtual ~command() throw();
29 /**
30 * Invoke a command.
32 * parameter arguments: Arguments to command.
33 * parameter window: Handle to graphics system.
34 * throws std::bad_alloc: Not enough memory.
35 * throws std::runtime_error: Command execution failed.
37 virtual void invoke(const std::string& arguments, window* win) throw(std::bad_alloc, std::runtime_error) = 0;
39 /**
40 * Look up and invoke a command. The command will undergo alias expansion and recursion checking.
42 * parameter cmd: Command to exeucte.
43 * parameter window: Handle to graphics system.
45 static void invokeC(const std::string& cmd, window* win) throw();
47 /**
48 * Get short help for command.
50 virtual std::string get_short_help() throw(std::bad_alloc);
52 /**
53 * Get long help for command.
55 virtual std::string get_long_help() throw(std::bad_alloc);
56 private:
57 command(const command&);
58 command& operator=(const command&);
59 std::string commandname;
62 /**
63 * Splits string to fields on ' ' and '\t', with multiple whitespace collapsed into one.
65 class tokensplitter
67 public:
68 /**
69 * Create a new splitter.
71 * parameter _line: The line to start splitting.
72 * throws std::bad_alloc: Not enough memory.
74 tokensplitter(const std::string& _line) throw(std::bad_alloc);
75 /**
76 * Is there more coming?
78 * returns: True if there is more, false otherwise.
79 * throws std::bad_alloc: Not enough memory.
81 operator bool() throw();
82 /**
83 * Get the next token.
85 * returns: The next token from line. If there is no more tokens, returns "".
86 * throws std::bad_alloc: Not enough memory.
88 operator std::string() throw(std::bad_alloc);
89 /**
90 * Get all that is remaining.
92 * returns: All remaining parts of line as-is.
93 * throws std::bad_alloc: Not enough memory.
95 std::string tail() throw(std::bad_alloc);
96 private:
97 std::string line;
98 size_t position;
102 #endif