blob: 9f36aa45276d032a00dbdf54a1352ca9662fa782 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/**-*-C++-*-
* \file
* \author Guillaume Papin <guillaume.papin@epitech.eu>
*
* \brief Command parser declarations.
*
* This file is distributed under the GNU General Public License. See
* COPYING for details.
*/
#ifndef IRONY_MODE_SERVER_COMMAND_H_
#define IRONY_MODE_SERVER_COMMAND_H_
#include "support/CIndex.h"
#include "support/TemporaryFile.h"
#include "Style.h"
#include <iosfwd>
#include <string>
#include <vector>
class TemporaryFile;
// TODO: a tagged union?
struct Command {
Command() {
clear();
}
void clear() {
action = Unknown;
flags.clear();
file.clear();
unsavedFile.clear();
dir.clear();
prefix.clear();
style = PrefixMatchStyle::Exact;
line = 0;
column = 0;
opt = false;
}
#define X(sym, str, desc) sym,
enum Action {
#include "Commands.def"
} action;
std::vector<std::string> flags;
std::string file;
std::string unsavedFile;
std::string dir;
std::string prefix;
PrefixMatchStyle style;
unsigned line;
unsigned column;
bool opt;
};
std::ostream &operator<<(std::ostream &os, const Command::Action &action);
std::ostream &operator<<(std::ostream &os, const Command &command);
class CommandParser {
public:
CommandParser();
Command *parse(const std::vector<std::string> &argv);
private:
Command command_;
TemporaryFile tempFile_;
};
#endif // IRONY_MODE_SERVER_COMMAND_H_
|