Etterna 0.74.4
Loading...
Searching...
No Matches
Command.h
1/* Commands - Actor command parsing and reading helpers. */
2
3#ifndef Commands_H
4#define Commands_H
5
6#include <string>
7#include <vector>
8
9class Command
10{
11 public:
12 void Load(const std::string& sCommand);
13
14 [[nodiscard]] auto GetOriginalCommandString() const
15 -> std::string; // used when reporting an error in number of args
16 [[nodiscard]] auto GetName() const
17 -> std::string; // the command name is the first argument in all-lowercase
18
19 void Clear() { m_vsArgs.clear(); }
20
21 struct Arg
22 {
23 std::string s;
24 Arg()
25 : s("")
26 {
27 }
28 };
29
30 [[nodiscard]] auto GetArg(unsigned index) const -> Arg;
31
32 std::vector<std::string> m_vsArgs;
33
34 Command() = default;
35};
36
38{
39 public:
40 std::vector<Command> v;
41
42 [[nodiscard]] auto GetOriginalCommandString() const
43 -> std::string; // used when reporting an error in number of args
44};
45
46// Take a command list string and return pointers to each of the tokens in the
47// string. sCommand list is a list of commands separated by ';'.
48// TODO(Sam): This is expensive to do during the game. Eventually, move all
49// calls to ParseCommands to happen during load, then execute from the parsed
50// Command structures.
51void
52ParseCommands(const std::string& sCmds, Commands& vCmdsOut, bool bLegacy);
53auto
54ParseCommands(const std::string& sCmds) -> Commands;
55
56#endif
Definition Command.h:10
Definition Command.h:38
Definition Command.h:22