mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Add const to stream wrapper classes.
This commit is contained in:
parent
fb3b0f9f62
commit
8e7693076c
@ -75,12 +75,11 @@ void Tokenize(const char *str, const char delim,
|
||||
}
|
||||
|
||||
inputfilestream::inputfilestream(const std::string &filePath)
|
||||
: std::istream(0),
|
||||
m_streambuf(0)
|
||||
: std::istream(0), m_streambuf(0)
|
||||
{
|
||||
// check if file is readable
|
||||
std::filebuf* fb = new std::filebuf();
|
||||
_good=(fb->open(filePath.c_str(), std::ios::in)!=NULL);
|
||||
is_good = (fb->open(filePath.c_str(), std::ios::in) != NULL);
|
||||
|
||||
if (filePath.size() > 3 &&
|
||||
filePath.substr(filePath.size() - 3, 3) == ".gz") {
|
||||
@ -104,12 +103,11 @@ void inputfilestream::close()
|
||||
}
|
||||
|
||||
outputfilestream::outputfilestream(const std::string &filePath)
|
||||
: std::ostream(0),
|
||||
m_streambuf(0)
|
||||
: std::ostream(0), m_streambuf(0)
|
||||
{
|
||||
// check if file is readable
|
||||
std::filebuf* fb = new std::filebuf();
|
||||
_good=(fb->open(filePath.c_str(), std::ios::out)!=NULL);
|
||||
is_good = (fb->open(filePath.c_str(), std::ios::out) != NULL);
|
||||
|
||||
if (filePath.size() > 3 && filePath.substr(filePath.size() - 3, 3) == ".gz") {
|
||||
throw runtime_error("Output to a zipped file not supported!");
|
||||
|
12
mert/Util.h
12
mert/Util.h
@ -64,14 +64,12 @@ class inputfilestream : public std::istream
|
||||
{
|
||||
protected:
|
||||
std::streambuf *m_streambuf;
|
||||
bool _good;
|
||||
bool is_good;
|
||||
|
||||
public:
|
||||
explicit inputfilestream(const std::string &filePath);
|
||||
~inputfilestream();
|
||||
bool good() {
|
||||
return _good;
|
||||
}
|
||||
bool good() const { return is_good; }
|
||||
void close();
|
||||
};
|
||||
|
||||
@ -79,14 +77,12 @@ class outputfilestream : public std::ostream
|
||||
{
|
||||
protected:
|
||||
std::streambuf *m_streambuf;
|
||||
bool _good;
|
||||
bool is_good;
|
||||
|
||||
public:
|
||||
explicit outputfilestream(const std::string &filePath);
|
||||
~outputfilestream();
|
||||
bool good() {
|
||||
return _good;
|
||||
}
|
||||
bool good() const { return is_good; }
|
||||
void close();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user