Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Germann <Ulrich.Germann@gmail.com>2015-08-07 03:45:29 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-08-07 03:45:29 +0300
commita2eacb9d3d73c1dd6b57b3e5175a12bbb9d6fdb4 (patch)
tree1837dd28c654bd9a0b3a56086ac4ccf434fe2406 /moses/OutputCollector.h
parent6c1d9e2431a1dbc270ea5ab401f47c2c32621103 (diff)
Construct OutputCollector directly from string(s).
Diffstat (limited to 'moses/OutputCollector.h')
-rw-r--r--moses/OutputCollector.h42
1 files changed, 39 insertions, 3 deletions
diff --git a/moses/OutputCollector.h b/moses/OutputCollector.h
index 4ca0f5ac1..71bc90369 100644
--- a/moses/OutputCollector.h
+++ b/moses/OutputCollector.h
@@ -42,9 +42,45 @@ namespace Moses
class OutputCollector
{
public:
- OutputCollector(std::ostream* outStream= &std::cout, std::ostream* debugStream=&std::cerr) :
- m_nextOutput(0),m_outStream(outStream),m_debugStream(debugStream),
- m_isHoldingOutputStream(false), m_isHoldingDebugStream(false) {}
+ OutputCollector(std::ostream* outStream= &std::cout,
+ std::ostream* debugStream=&std::cerr)
+ : m_nextOutput(0)
+ , m_outStream(outStream)
+ , m_debugStream(debugStream)
+ , m_isHoldingOutputStream(false)
+ , m_isHoldingDebugStream(false) {}
+
+ OutputCollector(std::string xout, std::string xerr = "")
+ : m_nextOutput(0)
+ {
+ // TO DO open magic streams instead of regular ofstreams! [UG]
+
+ if (xout == "/dev/stderr") {
+ m_outStream = &std::cerr;
+ m_isHoldingOutputStream = false;
+ } else if (xout.size() && xout != "/dev/stdout" && xout != "-") {
+ m_outStream = new std::ofstream(xout.c_str());
+ UTIL_THROW_IF2(!m_outputStream->good(), "Failed to open output file"
+ << xout << std::endl);
+ m_isHoldingOutputStream = true;
+ } else {
+ m_outStream = &std::cout;
+ m_isHoldingOutputStream = false;
+ }
+
+ if (xerr == "/dev/stdout") {
+ m_debugStream = &std::cout;
+ m_isHoldingDebugStream = false;
+ } else if (xerr.size() && xerr != "/dev/stderr") {
+ m_debugStream = new std::ofstream(xerr.c_str());
+ UTIL_THROW_IF2(!m_debugStream->good(), "Failed to open debug stream"
+ << xerr << std::endl);
+ m_isHoldingDebugStream = true;
+ } else {
+ m_debugStream = &std::cerr;
+ m_isHoldingDebugStream = false;
+ }
+ }
~OutputCollector() {
if (m_isHoldingOutputStream)