blob: e1df8025f57fd336732f463d4c3fcbbbf07a22d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include <fstream>
#include <string>
#include "OutputFileStream.h"
namespace MosesTraining {
namespace Syntax {
/*! Base class for command-line based tools.
*/
class Tool {
public:
virtual ~Tool() {}
//! Get the name of the tool.
const std::string &name() const { return name_; }
//! Virtual main function to be provided by subclass.
virtual int Main(int argc, char *argv[]) = 0;
protected:
Tool(const std::string &name) : name_(name) {}
//! Returns a boost::program_options style that is consistent with other
//! Moses tools (extract-rules, score, etc.).
static int MosesOptionStyle();
//! Write a formatted warning message to standard error.
void Warn(const std::string &) const;
//! Write a formatted error message to standard error and call exit(1).
void Error(const std::string &msg) const;
//! Opens the named input file using the supplied ifstream. Calls Error() if
//! the file cannot be opened for reading.
void OpenInputFileOrDie(const std::string &, std::ifstream &);
//! Opens the named output file using the supplied ofstream. Calls Error() if
//! the file cannot be opened for writing.
void OpenOutputFileOrDie(const std::string &, std::ofstream &);
//! Opens the named output file using the supplied OutputFileStream. Calls
//! Error() if the file cannot be opened for writing.
void OpenOutputFileOrDie(const std::string &, Moses::OutputFileStream &);
private:
std::string name_;
};
} // namespace Syntax
} // namespace MosesTraining
|