diff options
author | Oz Linden <oz@lindenlab.com> | 2015-04-07 17:59:28 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2015-04-07 17:59:28 -0400 |
commit | 8b42c7898ef756a4a81daa08b2a5acce2894f4b8 (patch) | |
tree | 57011bc24cc27df7b436c1edda7957ac3530fa57 /indra/llcommon | |
parent | 3a57b18896eacb6fea6680d0eccaaeddb0b700b0 (diff) |
replace llifstream and llofstream with std::ifstream and std::ofstream respectively
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-x | indra/llcommon/llerror.cpp | 4 | ||||
-rwxr-xr-x | indra/llcommon/llfile.cpp | 239 | ||||
-rwxr-xr-x | indra/llcommon/llfile.h | 162 | ||||
-rwxr-xr-x | indra/llcommon/llliveappconfig.cpp | 2 | ||||
-rwxr-xr-x | indra/llcommon/llstring.cpp | 2 |
5 files changed, 4 insertions, 405 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 2100989316..3cb81b4e47 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -135,7 +135,7 @@ namespace { } private: - llofstream mFile; + std::ofstream mFile; }; @@ -335,7 +335,7 @@ namespace LLSD configuration; { - llifstream file(filename().c_str()); + std::ifstream file(filename().c_str()); if (file.is_open()) { LLSDSerialize::fromXML(configuration, file); diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index 77a9657306..ab432a923d 100755 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -865,242 +865,3 @@ int llstdio_filebuf::sync() } #endif -#if 0 // @TBDeleted -/************** input file stream ********************************/ - - -llifstream::llifstream() : _M_filebuf(), -#if LL_WINDOWS - std::istream(&_M_filebuf) {} -#else - std::istream() -{ - this->init(&_M_filebuf); -} -#endif - -// explicit -llifstream::llifstream(const std::string& _Filename, - ios_base::openmode _Mode) : _M_filebuf(), -#if LL_WINDOWS - std::istream(&_M_filebuf) -{ - llutf16string wideName = utf8str_to_utf16str( _Filename ); - if (_M_filebuf.open(wideName.c_str(), _Mode | ios_base::in) == 0) - { - _Myios::setstate(ios_base::failbit); - } -} -#else - std::istream() -{ - this->init(&_M_filebuf); - this->open(_Filename.c_str(), _Mode | ios_base::in); -} -#endif - -// explicit -llifstream::llifstream(const char* _Filename, - ios_base::openmode _Mode) : _M_filebuf(), -#if LL_WINDOWS - std::istream(&_M_filebuf) -{ - llutf16string wideName = utf8str_to_utf16str( _Filename ); - if (_M_filebuf.open(wideName.c_str(), _Mode | ios_base::in) == 0) - { - _Myios::setstate(ios_base::failbit); - } -} -#else - std::istream() -{ - this->init(&_M_filebuf); - this->open(_Filename, _Mode | ios_base::in); -} -#endif - - -bool llifstream::is_open() const -{ // test if C stream has been opened - return _M_filebuf.is_open(); -} - -void llifstream::open(const char* _Filename, ios_base::openmode _Mode) -{ // open a C stream with specified mode - -#if LL_WINDOWS - llutf16string wideName = utf8str_to_utf16str( _Filename ); - if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::in) == 0) - { - _Myios::setstate(ios_base::failbit); - } - else - { - _Myios::clear(); - } -#else - if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0) - { - this->setstate(ios_base::failbit); - } - else - { - this->clear(); - } -#endif -} - -void llifstream::close() -{ // close the C stream - if (_M_filebuf.close() == 0) - { -#if LL_WINDOWS - _Myios::setstate(ios_base::failbit); -#else - this->setstate(ios_base::failbit); -#endif - } -} - - -/************** output file stream ********************************/ - - -llofstream::llofstream() : _M_filebuf(), -#if LL_WINDOWS - std::ofstream(&_M_filebuf) {} -#else - std::ofstream() -{ - this->init(&_M_filebuf); -} -#endif - -// explicit -llofstream::llofstream(const std::string& _Filename, - ios_base::openmode _Mode) : _M_filebuf(), -#if LL_WINDOWS - std::ofstream(&_M_filebuf) -{ - llutf16string wideName = utf8str_to_utf16str( _Filename ); - if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::out) == 0) - { - _Myios::setstate(ios_base::failbit); - } -} -#else - std::ofstream() -{ - this->init(&_M_filebuf); - this->open(_Filename.c_str(), _Mode | ios_base::out); -} -#endif - -// explicit -llofstream::llofstream(const char* _Filename, - ios_base::openmode _Mode) : _M_filebuf(), -#if LL_WINDOWS - std::ofstream(&_M_filebuf) -{ - llutf16string wideName = utf8str_to_utf16str( _Filename ); - if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::out) == 0) - { - _Myios::setstate(ios_base::failbit); - } -} -#else - std::ofstream() -{ - this->init(&_M_filebuf); - this->open(_Filename, _Mode | ios_base::out); -} -#endif - -bool llofstream::is_open() const -{ // test if C stream has been opened - return _M_filebuf.is_open(); -} - -void llofstream::open(const char* _Filename, ios_base::openmode _Mode) -{ // open a C stream with specified mode -#if LL_WINDOWS - llutf16string wideName = utf8str_to_utf16str( _Filename ); - if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::out) == 0) - { - _Myios::setstate(ios_base::failbit); - } - else - { - _Myios::clear(); - } -#else - if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0) - { - this->setstate(ios_base::failbit); - } - else - { - this->clear(); - } -#endif -} - -void llofstream::close() -{ // close the C stream - if (_M_filebuf.close() == 0) - { -#if LL_WINDOWS - _Myios::setstate(ios_base::failbit); -#else - this->setstate(ios_base::failbit); -#endif - } -} - -void llofstream::~llofstream() -{ - try: - { - if ( is_open() ) - { - flush(); - } - } - catch (std::exception& e) - { - LL_WARNS() << "llofstream std::exception: " << e.what() << LL_ENDL; - } - catch (...) - { - LL_WARNS() << "llofstream non-std exception" << LL_ENDL; - } -} - -/************** helper functions ********************************/ - -std::streamsize llifstream_size(llifstream& ifstr) -{ - if(!ifstr.is_open()) return 0; - std::streampos pos_old = ifstr.tellg(); - ifstr.seekg(0, ios_base::beg); - std::streampos pos_beg = ifstr.tellg(); - ifstr.seekg(0, ios_base::end); - std::streampos pos_end = ifstr.tellg(); - ifstr.seekg(pos_old, ios_base::beg); - return pos_end - pos_beg; -} - -std::streamsize llofstream_size(llofstream& ofstr) -{ - if(!ofstr.is_open()) return 0; - std::streampos pos_old = ofstr.tellp(); - ofstr.seekp(0, ios_base::beg); - std::streampos pos_beg = ofstr.tellp(); - ofstr.seekp(0, ios_base::end); - std::streampos pos_end = ofstr.tellp(); - ofstr.seekp(pos_old, ios_base::beg); - return pos_end - pos_beg; -} - - -#endif // @TBDeleted diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h index bd750b8c3c..e310d47325 100755 --- a/indra/llcommon/llfile.h +++ b/indra/llcommon/llfile.h @@ -192,166 +192,4 @@ protected: #endif }; -typedef std::ifstream llifstream; -typedef std::ofstream llofstream; -#if 0 /* @TBDeleted */ -/** - * @brief Controlling input for files. - * - * This class supports reading from named files, using the inherited - * functions from std::basic_istream. To control the associated - * sequence, an instance of std::basic_filebuf (or a platform-specific derivative) - * which allows construction using a pre-exisintg file stream buffer. - * We refer to this std::basic_filebuf (or derivative) as @c sb. -*/ -class LL_COMMON_API llifstream : public std::istream -{ - // input stream associated with a C stream -public: - // Constructors: - /** - * @brief Default constructor. - * - * Initializes @c sb using its default constructor, and passes - * @c &sb to the base class initializer. Does not open any files - * (you haven't given it a filename to open). - */ - llifstream(); - - /** - * @brief Create an input file stream. - * @param Filename String specifying the filename. - * @param Mode Open file in specified mode (see std::ios_base). - * - * @c ios_base::in is automatically included in @a mode. - */ - explicit llifstream(const std::string& _Filename, - ios_base::openmode _Mode = ios_base::in); - explicit llifstream(const char* _Filename, - ios_base::openmode _Mode = ios_base::in); - - /** - * @brief The destructor does nothing. - * - * The file is closed by the filebuf object, not the formatting - * stream. - */ - virtual ~llifstream() {} - - // Members: - /** - * @brief Wrapper to test for an open file. - * @return @c rdbuf()->is_open() - */ - bool is_open() const; - - /** - * @brief Opens an external file. - * @param Filename The name of the file. - * @param Node The open mode flags. - * - * Calls @c llstdio_filebuf::open(s,mode|in). If that function - * fails, @c failbit is set in the stream's error state. - */ - void open(const std::string& _Filename, - ios_base::openmode _Mode = ios_base::in) - { open(_Filename.c_str(), _Mode); } - void open(const char* _Filename, - ios_base::openmode _Mode = ios_base::in); - - /** - * @brief Close the file. - * - * Calls @c llstdio_filebuf::close(). If that function - * fails, @c failbit is set in the stream's error state. - */ - void close(); - -private: - llstdio_filebuf _M_filebuf; -}; - - -/** - * @brief Controlling output for files. - * - * This class supports writing to named files, using the inherited - * functions from std::basic_ostream. To control the associated - * sequence, an instance of std::basic_filebuf (or a platform-specific derivative) - * which allows construction using a pre-exisintg file stream buffer. - * We refer to this std::basic_filebuf (or derivative) as @c sb. -*/ -class LL_COMMON_API llofstream : public std::ofstream -{ -public: - // Constructors: - /** - * @brief Default constructor. - * - * Initializes @c sb using its default constructor, and passes - * @c &sb to the base class initializer. Does not open any files - * (you haven't given it a filename to open). - */ - llofstream(); - - /** - * @brief Create an output file stream. - * @param Filename String specifying the filename. - * @param Mode Open file in specified mode (see std::ios_base). - * - * @c ios_base::out|ios_base::trunc is automatically included in - * @a mode. - */ - explicit llofstream(const std::string& _Filename, - ios_base::openmode _Mode = ios_base::out|ios_base::trunc); - explicit llofstream(const char* _Filename, - ios_base::openmode _Mode = ios_base::out|ios_base::trunc); - - /** - * @brief The destructor does nothing. - * - * The file is closed by the filebuf object, not the formatting - * stream. - */ - virtual ~llofstream(); - - // Members: - /** - * @brief Opens an external file. - * @param Filename The name of the file. - * @param Node The open mode flags. - * - * Calls @c llstdio_filebuf::open(s,mode|out). If that function - * fails, @c failbit is set in the stream's error state. - */ - void open(const std::string& _Filename, - ios_base::openmode _Mode = ios_base::out|ios_base::trunc) - { open(_Filename.c_str(), _Mode); } - void open(const char* _Filename, - ios_base::openmode _Mode = ios_base::out|ios_base::trunc); - - /** - * @brief Close the file. - * - * Calls @c llstdio_filebuf::close(). If that function - * fails, @c failbit is set in the stream's error state. - */ - void close(); - -private: - llstdio_filebuf _M_filebuf; -}; - - -/** - * @breif filesize helpers. - * - * The file size helpers are not considered particularly efficient, - * and should only be used for config files and the like -- not in a - * loop. - */ -std::streamsize LL_COMMON_API llifstream_size(llifstream& fstr); -std::streamsize LL_COMMON_API llofstream_size(llofstream& fstr); -#endif /* @TBDeleted */ - #endif // not LL_LLFILE_H diff --git a/indra/llcommon/llliveappconfig.cpp b/indra/llcommon/llliveappconfig.cpp index a9b1cdf4f6..f955194009 100755 --- a/indra/llcommon/llliveappconfig.cpp +++ b/indra/llcommon/llliveappconfig.cpp @@ -49,7 +49,7 @@ bool LLLiveAppConfig::loadFile() { LL_INFOS() << "LLLiveAppConfig::loadFile(): reading from " << filename() << LL_ENDL; - llifstream file(filename().c_str()); + std::ifstream file(filename().c_str()); LLSD config; if (file.is_open()) { diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index f3b8999883..227f81e88f 100755 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -107,7 +107,7 @@ bool iswindividual(llwchar elem) bool _read_file_into_string(std::string& str, const std::string& filename) { - llifstream ifs(filename.c_str(), llifstream::binary); + std::ifstream ifs(filename.c_str(), std::ifstream::binary); if (!ifs.is_open()) { LL_INFOS() << "Unable to open file " << filename << LL_ENDL; |