diff --git a/lib/spdlog b/lib/spdlog index 4a25802..9470bdd 160000 --- a/lib/spdlog +++ b/lib/spdlog @@ -1 +1 @@ -Subproject commit 4a2580231259f464674d8bd998e5fb378694c98d +Subproject commit 9470bdd3ec21c1158d066e49f724ed1dfcd1e698 diff --git a/src/tawashi/escapist.cpp b/src/tawashi/escapist.cpp index af4783a..6caba6b 100644 --- a/src/tawashi/escapist.cpp +++ b/src/tawashi/escapist.cpp @@ -48,7 +48,7 @@ namespace tawashi { parURL.size() ); if (0 == escaped) - return std::string(parURL.data(), parURL.size()); + return std::string(parURL); else return std::string(buf->ptr, buf->size); } @@ -66,7 +66,7 @@ namespace tawashi { parURL.size() ); if (0 == escaped) - return std::string(parURL.data(), parURL.size()); + return std::string(parURL); else return std::string(buf->ptr, buf->size); } @@ -85,7 +85,7 @@ namespace tawashi { 1 ); if (0 == escaped) - return std::string(parHtml.data(), parHtml.size()); + return std::string(parHtml); else return std::string(buf->ptr, buf->size); } diff --git a/src/tawashi/settings_bag.cpp b/src/tawashi/settings_bag.cpp index 5ffa6b1..900b4de 100644 --- a/src/tawashi/settings_bag.cpp +++ b/src/tawashi/settings_bag.cpp @@ -17,6 +17,7 @@ #include "settings_bag.hpp" #include "duckhandy/lexical_cast.hpp" +#include "spdlog.hpp" #include #include #include @@ -63,7 +64,7 @@ namespace tawashi { template <> std::string SettingsBag::as (boost::string_view parIndex) const { auto& setting = this->at(parIndex); - return std::string(setting.data(), setting.size()); + return std::string(setting); } template <> diff --git a/src/tawashi/settings_bag.hpp b/src/tawashi/settings_bag.hpp index d95d8b9..301f16a 100644 --- a/src/tawashi/settings_bag.hpp +++ b/src/tawashi/settings_bag.hpp @@ -19,13 +19,13 @@ #include "ini_file.hpp" #include "kakoune/safe_ptr.hh" +#if defined(SPDLOG_DEBUG_ON) +# include "spdlog.hpp" +#endif #include #include #include #include -#if defined(SPDLOG_DEBUG_ON) -# include -#endif namespace tawashi { class SettingsBag : public Kakoune::SafeCountable { @@ -52,7 +52,7 @@ namespace tawashi { inline const boost::string_view& SettingsBag::at (boost::string_view parIndex) const { #if defined(SPDLOG_DEBUG_ON) - SPDLOG_DEBUG(spdlog::get("statuslog"), "Retrieving setting \"{}\"", std::string(parIndex.data(), parIndex.size())); + SPDLOG_DEBUG(spdlog::get("statuslog"), "Retrieving setting \"{}\"", parIndex); #endif return (*this)[parIndex]; } diff --git a/src/tawashi/spdlog.hpp b/src/tawashi/spdlog.hpp index 241cba9..3e608e6 100644 --- a/src/tawashi/spdlog.hpp +++ b/src/tawashi/spdlog.hpp @@ -18,11 +18,4 @@ #pragma once #include -#include - -namespace spdlog { - template - inline OStream& operator<< (OStream& parOS, const boost::string_view& parStr) { - return parOS << parStr; - } -} //namespace spdlog +#include diff --git a/src/tawashi/storage.cpp b/src/tawashi/storage.cpp index 4f349b6..ae5ba1a 100644 --- a/src/tawashi/storage.cpp +++ b/src/tawashi/storage.cpp @@ -21,10 +21,10 @@ #include "num_to_token.hpp" #include "tawashi_config.h" #include "duckhandy/stringize.h" +#include "spdlog.hpp" #include #include #include -#include #include namespace tawashi { @@ -131,17 +131,10 @@ namespace tawashi { #if defined(SPDLOG_DEBUG_ON) { auto statuslog = spdlog::get("statuslog"); - if (pastie) { - statuslog->debug("Retrieving pastie with token \"{}\" gave a result of size {}", - std::string(parToken.data(), parToken.size()), - pastie->size() - ); - } - else { - statuslog->debug("Retrieving pastie with token \"{}\" gave no results", - std::string(parToken.data(), parToken.size()) - ); - } + if (pastie) + statuslog->debug("Retrieving pastie with token \"{}\" gave a result of size {}", parToken, pastie->size()); + else + statuslog->debug("Retrieving pastie with token \"{}\" gave no results", parToken); } #endif return pastie; diff --git a/src/tawashi/submit_paste_response.cpp b/src/tawashi/submit_paste_response.cpp index d664d05..3775839 100644 --- a/src/tawashi/submit_paste_response.cpp +++ b/src/tawashi/submit_paste_response.cpp @@ -55,7 +55,7 @@ namespace tawashi { } boost::string_view get_value_from_post (const cgi::PostMapType& parPost, boost::string_view parKey) { - std::string key(parKey.data(), parKey.size()); + std::string key(parKey); auto post_data_it = parPost.find(key); if (parPost.end() == post_data_it) throw MissingPostVarError(parKey); diff --git a/test/simulation/fake_storage.cpp b/test/simulation/fake_storage.cpp index bd1a4da..1441eab 100644 --- a/test/simulation/fake_storage.cpp +++ b/test/simulation/fake_storage.cpp @@ -48,9 +48,9 @@ namespace tawashi { ) const { SubmittedPastie pastie; std::string token = num_to_token(m_submission_num++); - pastie.text = std::string(parText.data(), parText.size()); + pastie.text = std::string(parText); pastie.expiry = parExpiry; - pastie.lang = std::string(parLang.data(), parLang.size()); + pastie.lang = std::string(parLang); pastie.remote_ip = parRemoteIP; pastie.token = token; m_submitted_pasties.push_back(std::move(pastie)); diff --git a/test/unit/test_mime_split.cpp b/test/unit/test_mime_split.cpp index 5647f32..3ed0eaf 100644 --- a/test/unit/test_mime_split.cpp +++ b/test/unit/test_mime_split.cpp @@ -18,12 +18,6 @@ #include "catch.hpp" #include "mime_split.hpp" -namespace { - std::string to_string (const boost::string_ref& parRef) { - return std::string(parRef.data(), parRef.size()); - } -} //unnamed namespace - TEST_CASE ("Test the string_to_mime parser", "[mime][parser]") { using tawashi::SplitMime; using tawashi::string_to_mime; @@ -42,7 +36,7 @@ TEST_CASE ("Test the string_to_mime parser", "[mime][parser]") { REQUIRE(split.parameters.size() == 1); CHECK(split.parameters.find("charset") != split.parameters.end()); - curr_val = to_string(split.parameters.at("charset")); + curr_val = std::string(split.parameters.at("charset")); CHECK(curr_val == "UTF-8"); } @@ -58,11 +52,11 @@ TEST_CASE ("Test the string_to_mime parser", "[mime][parser]") { REQUIRE(split.parameters.size() == 2); CHECK(split.parameters.find("filename") != split.parameters.end()); - curr_val = to_string(split.parameters.at("filename")); + curr_val = std::string(split.parameters.at("filename")); CHECK(curr_val == "genome.jpeg"); CHECK(split.parameters.find("modification-date") != split.parameters.end()); - curr_val = to_string(split.parameters.at("modification-date")); + curr_val = std::string(split.parameters.at("modification-date")); CHECK(curr_val == "Wed, 12 Feb 1997 16:29:51 -0500"); } }