diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-29 17:30:05 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-29 17:30:05 +0200 |
commit | 7b75aaea7c538f61518a60fe4af363383020e0bc (patch) | |
tree | a4ee92f7763ca9931e6c1e5b96a2b5275206ab46 /source/CommandOutput.cpp | |
parent | Added a function that allows you to change the /back coordinates. (diff) | |
download | cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.tar cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.tar.gz cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.tar.bz2 cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.tar.lz cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.tar.xz cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.tar.zst cuberite-7b75aaea7c538f61518a60fe4af363383020e0bc.zip |
Diffstat (limited to '')
-rw-r--r-- | source/CommandOutput.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/source/CommandOutput.cpp b/source/CommandOutput.cpp new file mode 100644 index 000000000..49102b38c --- /dev/null +++ b/source/CommandOutput.cpp @@ -0,0 +1,71 @@ +
+// CommandOutput.cpp
+
+// Implements the various classes that process command output
+
+#include "Globals.h"
+#include "CommandOutput.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cCommandOutputCallback:
+
+void cCommandOutputCallback::Out(const char * a_Fmt, ...)
+{
+ AString Output;
+ va_list args;
+ va_start(args, a_Fmt);
+ AppendVPrintf(Output, a_Fmt, args);
+ va_end(args);
+ Output.append("\n");
+ Out(Output);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cLogCommandOutputCallback:
+
+void cLogCommandOutputCallback::Out(const AString & a_Text)
+{
+ m_Buffer.append(a_Text);
+}
+
+
+
+
+
+void cLogCommandOutputCallback::Finished(void)
+{
+ // Log each line separately:
+ size_t len = m_Buffer.length();
+ size_t last = 0;
+ for (size_t i = 0; i < len; i++)
+ {
+ switch (m_Buffer[i])
+ {
+ case '\n':
+ {
+ LOG(m_Buffer.substr(last, i - last).c_str());
+ last = i + 1;
+ break;
+ }
+ }
+ } // for i - m_Buffer[]
+ if (last < len)
+ {
+ LOG(m_Buffer.substr(last).c_str());
+ }
+
+ // Clear the buffer for the next command output:
+ m_Buffer.clear();
+}
+
+
+
+
|