Commit b82b355e authored by Davis King's avatar Davis King

Added an openmode argument to the basic_utf8_ifstream.

parent de6109a0
...@@ -544,41 +544,45 @@ namespace dlib ...@@ -544,41 +544,45 @@ namespace dlib
) : std::basic_istream<charT>(&buf), buf(fin) {} ) : std::basic_istream<charT>(&buf), buf(fin) {}
basic_utf8_ifstream ( basic_utf8_ifstream (
const char* file_name const char* file_name,
std::ios_base::openmode mode = std::ios::in
) : ) :
std::basic_istream<charT>(&buf), std::basic_istream<charT>(&buf),
buf(fin) buf(fin)
{ {
fin.open(file_name); fin.open(file_name,mode);
// make this have the same error state as fin // make this have the same error state as fin
this->clear(fin.rdstate()); this->clear(fin.rdstate());
} }
basic_utf8_ifstream ( basic_utf8_ifstream (
const std::string& file_name const std::string& file_name,
std::ios_base::openmode mode = std::ios::in
) : ) :
std::basic_istream<charT>(&buf), std::basic_istream<charT>(&buf),
buf(fin) buf(fin)
{ {
fin.open(file_name.c_str()); fin.open(file_name.c_str(),mode);
// make this have the same error state as fin // make this have the same error state as fin
this->clear(fin.rdstate()); this->clear(fin.rdstate());
} }
void open( void open(
const std::string& file_name const std::string& file_name,
std::ios_base::openmode mode = std::ios::in
) )
{ {
open(file_name.c_str()); open(file_name.c_str(),mode);
} }
void open ( void open (
const char* file_name const char* file_name,
std::ios_base::openmode mode = std::ios::in
) )
{ {
fin.close(); fin.close();
fin.clear(); fin.clear();
fin.open(file_name); fin.open(file_name,mode);
// make this have the same error state as fin // make this have the same error state as fin
this->clear(fin.rdstate()); this->clear(fin.rdstate());
} }
......
...@@ -170,35 +170,47 @@ namespace dlib ...@@ -170,35 +170,47 @@ namespace dlib
!*/ !*/
basic_utf8_ifstream ( basic_utf8_ifstream (
const char* file_name const char* file_name,
std::ios_base::openmode mode = std::ios::in
); );
/*! /*!
ensures ensures
- tries to open the given file for reading by this stream - tries to open the given file for reading by this stream
- mode is interpreted exactly the same was as the open mode
argument used by std::ifstream.
!*/ !*/
basic_utf8_ifstream ( basic_utf8_ifstream (
const std::string& file_name const std::string& file_name,
std::ios_base::openmode mode = std::ios::in
); );
/*! /*!
ensures ensures
- tries to open the given file for reading by this stream - tries to open the given file for reading by this stream
- mode is interpreted exactly the same was as the open mode
argument used by std::ifstream.
!*/ !*/
void open( void open(
const std::string& file_name const std::string& file_name,
std::ios_base::openmode mode = std::ios::in
); );
/*! /*!
ensures ensures
- tries to open the given file for reading by this stream - tries to open the given file for reading by this stream
- mode is interpreted exactly the same was as the open mode
argument used by std::ifstream.
!*/ !*/
void open ( void open (
const char* file_name const char* file_name,
std::ios_base::openmode mode = std::ios::in
); );
/*! /*!
ensures ensures
- tries to open the given file for reading by this stream - tries to open the given file for reading by this stream
- mode is interpreted exactly the same was as the open mode
argument used by std::ifstream.
!*/ !*/
void close ( void close (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment