Add const to stream wrapper classes.

This commit is contained in:
Tetsuo Kiso 2011-11-12 11:35:20 +09:00
parent fb3b0f9f62
commit 8e7693076c
2 changed files with 8 additions and 14 deletions

View File

@ -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!");

View File

@ -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();
};