Cuberite
A lightweight, fast and extensible game server for Minecraft
CommandOutput.h
Go to the documentation of this file.
1 
2 // CommandOutput.h
3 
4 // Declares various classes that process command output
5 
6 
7 
8 
9 
14 {
15 public:
16  virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses
17 
19  void Out(const char * a_Fmt, fmt::ArgList);
20  FMT_VARIADIC(void, Out, const char *)
21 
22 
23  virtual void Out(const AString & a_Text) = 0;
24 
26  virtual void Finished(void) {}
27 } ;
28 
29 
30 
31 
32 
36 {
37  // cCommandOutputCallback overrides:
38  virtual void Out(const AString & a_Text) override
39  {
40  // Do nothing
41  UNUSED(a_Text);
42  }
43 } ;
44 
45 
46 
47 
48 
52 {
54 
55 public:
56  // cCommandOutputCallback overrides:
57  virtual void Out(const AString & a_Text) override;
58  virtual void Finished(void) override {}
59 
61  const AString & GetAccum(void) const { return m_Accum; }
62 
63 protected:
66 } ;
67 
68 
69 
70 
71 
75 {
76 public:
77  // cStringAccumCommandOutputCallback overrides:
78  virtual void Finished(void) override;
79 } ;
80 
81 
82 
83 
84 
88 {
90 
91  virtual void Finished(void) override
92  {
93  super::Finished();
94  delete this;
95  }
96 } ;
97 
98 
99 
100 
AString m_Accum
Output is stored here until the command finishes processing.
Definition: CommandOutput.h:65
virtual ~cCommandOutputCallback()
Definition: CommandOutput.h:16
const AString & GetAccum(void) const
Returns the accumulated command output in a string.
Definition: CommandOutput.h:61
Accumulates all command output into a string.
Definition: CommandOutput.h:50
virtual void Out(const AString &a_Text) override
Called when the command wants to output anything; may be called multiple times.
Definition: CommandOutput.h:38
Sends all command output to a log, line by line, when the command finishes processing.
Definition: CommandOutput.h:73
virtual void Finished(void)
Called when the command processing has been finished.
Definition: CommandOutput.h:26
void Out(const char *a_Fmt, fmt::ArgList)
Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline".
Class that discards all command output.
Definition: CommandOutput.h:34
virtual void Finished(void) override
Called when the command processing has been finished.
Definition: CommandOutput.h:58
#define UNUSED
Definition: Globals.h:152
std::string AString
Definition: StringUtils.h:13
Sends all command output to a log, line by line; deletes self when command finishes processing...
Definition: CommandOutput.h:86
virtual void Finished(void) override
Called when the command processing has been finished.
Definition: CommandOutput.h:91
cCommandOutputCallback super
Definition: CommandOutput.h:53
Interface for a callback that receives command output The Out() function is called for any output the...
Definition: CommandOutput.h:13
cLogCommandOutputCallback super
Definition: CommandOutput.h:89