diff options
author | Alexander Harkness <bearbin@gmail.com> | 2013-07-29 13:13:03 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2013-07-29 13:13:03 +0200 |
commit | 53e22b11857fed62e2313d6d84d90f88ed412ffb (patch) | |
tree | c61e56725da7dff0154d566722651e2c39c9d6c6 /source/CommandOutput.cpp | |
parent | WebAdmin: Removed the duplicate memory usage querying (diff) | |
download | cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.gz cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.bz2 cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.lz cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.xz cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.zst cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.zip |
Diffstat (limited to 'source/CommandOutput.cpp')
-rw-r--r-- | source/CommandOutput.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/source/CommandOutput.cpp b/source/CommandOutput.cpp index 49102b38c..c221682a1 100644 --- a/source/CommandOutput.cpp +++ b/source/CommandOutput.cpp @@ -1,71 +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();
-}
-
-
-
-
+ +// 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(); +} + + + + |