From c1c799117e7076046182e12d71d06e2c9444e9be Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 8 Nov 2011 10:26:04 +0100 Subject: changed all wstring/wchar_t to string/char --- src/utils/locale_independent_float.cpp | 18 ++++----- src/utils/locale_independent_float.hpp | 8 ++-- src/utils/text_file.cpp | 69 ++++++++++++++++++++++++++++++++++ src/utils/text_file.hpp | 51 +++++++++++++++++++++++++ src/utils/unicode_file.cpp | 69 ---------------------------------- src/utils/unicode_file.hpp | 51 ------------------------- 6 files changed, 133 insertions(+), 133 deletions(-) create mode 100644 src/utils/text_file.cpp create mode 100644 src/utils/text_file.hpp delete mode 100644 src/utils/unicode_file.cpp delete mode 100644 src/utils/unicode_file.hpp (limited to 'src/utils') diff --git a/src/utils/locale_independent_float.cpp b/src/utils/locale_independent_float.cpp index 606ec998..e0015cee 100644 --- a/src/utils/locale_independent_float.cpp +++ b/src/utils/locale_independent_float.cpp @@ -38,7 +38,7 @@ namespace usdx { } - LocaleIndependentFloat::LocaleIndependentFloat(std::wstring& value) + LocaleIndependentFloat::LocaleIndependentFloat(std::string& value) { this->operator=(value); } @@ -65,27 +65,27 @@ namespace usdx return *this; } - LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::wstring& value) + LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::string& value) { - std::size_t found = value.find(L','); - if (found != std::wstring::npos) { - value[found] = L'.'; + std::size_t found = value.find(','); + if (found != std::string::npos) { + value[found] = '.'; } - std::wistringstream str(value); + std::istringstream str(value); str >> this->value; return *this; } - std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat& float_value) + std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value) { return is >> &float_value; } - std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat* float_value) + std::istream& operator>> (std::istream& is, LocaleIndependentFloat* float_value) { - std::wstring str_value; + std::string str_value; is >> str_value; *float_value = str_value; diff --git a/src/utils/locale_independent_float.hpp b/src/utils/locale_independent_float.hpp index f3674695..82801868 100644 --- a/src/utils/locale_independent_float.hpp +++ b/src/utils/locale_independent_float.hpp @@ -37,7 +37,7 @@ namespace usdx float value; public: LocaleIndependentFloat(); - LocaleIndependentFloat(std::wstring& value); + LocaleIndependentFloat(std::string& value); virtual ~LocaleIndependentFloat(); @@ -46,11 +46,11 @@ namespace usdx LocaleIndependentFloat& operator= (const LocaleIndependentFloat& value); LocaleIndependentFloat& operator= (const float& vaule); - LocaleIndependentFloat& operator= (std::wstring& vaule); + LocaleIndependentFloat& operator= (std::string& vaule); }; - std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat& float_value); - std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat* float_value); + std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value); + std::istream& operator>> (std::istream& is, LocaleIndependentFloat* float_value); }; diff --git a/src/utils/text_file.cpp b/src/utils/text_file.cpp new file mode 100644 index 00000000..b84c667f --- /dev/null +++ b/src/utils/text_file.cpp @@ -0,0 +1,69 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#include "text_file.hpp" +#include +#include + +#include + +namespace usdx +{ + TextFile::TextFile(const std::string& filename) : file(filename.c_str(), std::ifstream::in) + { + std::locale global_loc = std::locale(); + std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet()); + file.imbue(loc); + } + + TextFile::TextFile(const boost::filesystem::wpath& path) : file(path, std::wifstream::in) + { + std::locale global_loc = std::locale(); + std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet()); + file.imbue(loc); + } + + TextFile::~TextFile(void) + { + file.close(); + } + + boost::filesystem::ifstream &TextFile::stream(void) + { + return file; + } + + const std::streamsize TextFile::get_filesize(void) + { + std::streampos position = stream().tellg(); + + stream().seekg (0, std::ios::end); + std::streamsize length = stream().tellg(); + stream().seekg (position); + + return length; + } +}; diff --git a/src/utils/text_file.hpp b/src/utils/text_file.hpp new file mode 100644 index 00000000..b5249035 --- /dev/null +++ b/src/utils/text_file.hpp @@ -0,0 +1,51 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef TEXT_FILE_HPP +#define TEXT_FILE_HPP + +#include +#include +#include "file.hpp" + +namespace usdx +{ + class TextFile : public File + { + private: + boost::filesystem::ifstream file; + + public: + TextFile(const std::string& filename); + TextFile(const boost::filesystem::wpath& path); + virtual ~TextFile(void); + + boost::filesystem::ifstream &stream(void); + const std::streamsize get_filesize(void); + }; +}; + +#endif diff --git a/src/utils/unicode_file.cpp b/src/utils/unicode_file.cpp deleted file mode 100644 index c47bfd36..00000000 --- a/src/utils/unicode_file.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#include "unicode_file.hpp" -#include -#include - -#include - -namespace usdx -{ - UnicodeFile::UnicodeFile(const std::string& filename) : file(filename.c_str(), std::wifstream::in) - { - std::locale global_loc = std::locale(); - std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet()); - file.imbue(loc); - } - - UnicodeFile::UnicodeFile(const boost::filesystem::wpath& path) : file(path, std::wifstream::in) - { - std::locale global_loc = std::locale(); - std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet()); - file.imbue(loc); - } - - UnicodeFile::~UnicodeFile(void) - { - file.close(); - } - - boost::filesystem::wifstream &UnicodeFile::stream(void) - { - return file; - } - - const std::streamsize UnicodeFile::get_filesize(void) - { - std::streampos position = stream().tellg(); - - stream().seekg (0, std::ios::end); - std::streamsize length = stream().tellg(); - stream().seekg (position); - - return length; - } -}; diff --git a/src/utils/unicode_file.hpp b/src/utils/unicode_file.hpp deleted file mode 100644 index d135d796..00000000 --- a/src/utils/unicode_file.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef UNICODE_FILE_HPP -#define UNICODE_FILE_HPP - -#include -#include -#include "file.hpp" - -namespace usdx -{ - class UnicodeFile : public File - { - private: - boost::filesystem::wifstream file; - - public: - UnicodeFile(const std::string& filename); - UnicodeFile(const boost::filesystem::wpath& path); - virtual ~UnicodeFile(void); - - boost::filesystem::wifstream &stream(void); - const std::streamsize get_filesize(void); - }; -}; - -#endif -- cgit v1.2.3