diff options
author | Alexander Batischev <eual.jp@gmail.com> | 2021-04-22 21:07:33 +0300 |
---|---|---|
committer | Alexander Batischev <eual.jp@gmail.com> | 2021-05-17 15:23:11 +0300 |
commit | 900ee8c943dfc6d665258fd629659a6a2cb99615 (patch) | |
tree | 7c9f4d22ee189d10321f6459bcdf26454aa71ea9 | |
parent | d8a7ed0ffbdc87ed4282e1ea1b7f33d3cf89ec83 (diff) |
Switch Download's storage to Utf8String
-rw-r--r-- | include/download.h | 10 | ||||
-rw-r--r-- | include/utf8string.h | 5 | ||||
-rw-r--r-- | mk/mk.deps | 11 | ||||
-rw-r--r-- | src/download.cpp | 14 |
4 files changed, 24 insertions, 16 deletions
diff --git a/include/download.h b/include/download.h index 1243aa5b..3cbe112a 100644 --- a/include/download.h +++ b/include/download.h @@ -4,6 +4,8 @@ #include <functional> #include <string> +#include "utf8string.h" + namespace podboat { enum class DlStatus { @@ -30,7 +32,7 @@ public: } const std::string& status_msg() const { - return msg; + return msg.to_utf8(); } const std::string filename() const; const std::string basename() const; @@ -53,10 +55,10 @@ public: } private: - std::string fn; - std::string url_; + newsboat::Utf8String fn; + newsboat::Utf8String url_; DlStatus download_status; - std::string msg; + newsboat::Utf8String msg; double cursize; double totalsize; double curkbps; diff --git a/include/utf8string.h b/include/utf8string.h index 11cfbefb..ba3f1c68 100644 --- a/include/utf8string.h +++ b/include/utf8string.h @@ -74,6 +74,11 @@ public: return inner.length(); } + size_type rfind(const Utf8String& str, size_type pos = npos ) const noexcept + { + return inner.rfind(str.inner, pos); + } + friend bool operator==(const Utf8String& lhs, const Utf8String& rhs); friend bool operator!=(const Utf8String& lhs, const Utf8String& rhs); friend bool operator<(const Utf8String& lhs, const Utf8String& rhs); @@ -254,10 +254,10 @@ src/dirbrowserformaction.o: src/dirbrowserformaction.cpp \ include/dirbrowserformaction.h include/feedlistformaction.h \ include/listformaction.h include/view.h include/filebrowserformaction.h \ include/htmlrenderer.h include/textformatter.h include/statusline.h -src/download.o: src/download.cpp include/download.h config.h \ - include/pbcontroller.h include/colormanager.h \ - include/configactionhandler.h include/utf8string.h \ - include/configcontainer.h include/download.h include/fslock.h \ +src/download.o: src/download.cpp include/download.h include/utf8string.h \ + config.h include/pbcontroller.h include/colormanager.h \ + include/configactionhandler.h include/configcontainer.h \ + include/download.h include/fslock.h \ target/cxxbridge/libnewsboat-ffi/src/fslock.rs.h include/keymap.h \ include/queueloader.h 3rd-party/optional.hpp src/downloadthread.o: src/downloadthread.cpp include/downloadthread.h \ @@ -973,7 +973,8 @@ test/configpaths.o: test/configpaths.cpp include/configpaths.h \ include/utils.h 3rd-party/expected.hpp include/configcontainer.h \ include/configactionhandler.h \ target/cxxbridge/libnewsboat-ffi/src/utils.rs.h -test/download.o: test/download.cpp include/download.h 3rd-party/catch.hpp +test/download.o: test/download.cpp include/download.h \ + include/utf8string.h 3rd-party/catch.hpp test/feedcontainer.o: test/feedcontainer.cpp 3rd-party/catch.hpp \ include/cache.h include/configcontainer.h include/configactionhandler.h \ include/utf8string.h include/configcontainer.h include/feedcontainer.h \ diff --git a/src/download.cpp b/src/download.cpp index 39c47754..a82ca814 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -26,7 +26,7 @@ Download::~Download() {} const std::string Download::filename() const { - return fn; + return fn.to_utf8(); } const std::string Download::basename() const @@ -34,19 +34,19 @@ const std::string Download::basename() const std::string::size_type start = fn.rfind(NEWSBOAT_PATH_SEP); if (start != std::string::npos) { - return fn.substr(start+1); + return fn.substr(start+1).to_utf8(); } - return fn; + return fn.to_utf8(); } const std::string Download::url() const { - return url_; + return url_.to_utf8(); } void Download::set_filename(const std::string& str) { - fn = str; + fn = newsboat::Utf8String::from_utf8(str); } double Download::percents_finished() const @@ -86,7 +86,7 @@ const std::string Download::status_text() const void Download::set_url(const std::string& u) { - url_ = u; + url_ = newsboat::Utf8String::from_utf8(u); } void Download::set_progress(double downloaded, double total) @@ -103,7 +103,7 @@ void Download::set_status(DlStatus dls, const std::string& msg_) if (download_status != dls) { cb_require_view_update(); } - msg = msg_; + msg = newsboat::Utf8String::from_utf8(msg_); download_status = dls; } |