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 #pragma once
7 
8 
9 
10 
11 
16 {
17 public:
18  virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses
19 
21  virtual void Out(const AString & a_Text) = 0;
22 
24  void OutLn(const AString & aText)
25  {
26  Out(aText);
27  Out("\n");
28  }
29 
31  virtual void Finished() {}
32 } ;
33 
34 
35 
36 
37 
41 {
42  // cCommandOutputCallback overrides:
43  virtual void Out(const AString & a_Text) override
44  {
45  // Do nothing
46  UNUSED(a_Text);
47  }
48 } ;
49 
50 
51 
52 
53 
57 {
59 
60 public:
61 
62  // cCommandOutputCallback overrides:
63  virtual void Out(const AString & a_Text) override;
64  virtual void Finished() override {}
65 
67  const AString & GetAccum() const { return m_Accum; }
68 
69 protected:
72 } ;
73 
74 
75 
76 
77 
81 {
82 public:
83  // cStringAccumCommandOutputCallback overrides:
84  virtual void Finished() override;
85 } ;
86 
87 
88 
89 
90 
94 {
96 
97  virtual void Finished() override
98  {
100  delete this;
101  }
102 } ;
103 
104 
105 
106 
#define UNUSED
Definition: Globals.h:72
std::string AString
Definition: StringUtils.h:11
Interface for a callback that receives command output The Out() function is called for any output the...
Definition: CommandOutput.h:16
virtual void Finished()
Called when the command processing has been finished.
Definition: CommandOutput.h:31
void OutLn(const AString &aText)
Outputs the specified text, plus a newline.
Definition: CommandOutput.h:24
virtual ~cCommandOutputCallback()
Definition: CommandOutput.h:18
virtual void Out(const AString &a_Text)=0
Called when the command wants to output anything; may be called multiple times.
Class that discards all command output.
Definition: CommandOutput.h:41
virtual void Out(const AString &a_Text) override
Called when the command wants to output anything; may be called multiple times.
Definition: CommandOutput.h:43
Accumulates all command output into a string.
Definition: CommandOutput.h:57
AString m_Accum
Output is stored here until the command finishes processing.
Definition: CommandOutput.h:71
const AString & GetAccum() const
Returns the accumulated command output in a string.
Definition: CommandOutput.h:67
virtual void Finished() override
Called when the command processing has been finished.
Definition: CommandOutput.h:64
virtual void Out(const AString &a_Text) override
Called when the command wants to output anything; may be called multiple times.
Sends all command output to a log, line by line, when the command finishes processing.
Definition: CommandOutput.h:81
virtual void Finished() override
Called when the command processing has been finished.
Sends all command output to a log, line by line; deletes self when command finishes processing.
Definition: CommandOutput.h:94
virtual void Finished() override
Called when the command processing has been finished.
Definition: CommandOutput.h:97