1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-11-23 00:33:44 +00:00

Use stock std::string conversion.

This commit is contained in:
King_DuckZ 2017-06-07 00:19:53 +01:00
parent eaf8c0778d
commit 056e7dcde4
9 changed files with 22 additions and 41 deletions

@ -1 +1 @@
Subproject commit 4a2580231259f464674d8bd998e5fb378694c98d
Subproject commit 9470bdd3ec21c1158d066e49f724ed1dfcd1e698

View file

@ -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);
}

View file

@ -17,6 +17,7 @@
#include "settings_bag.hpp"
#include "duckhandy/lexical_cast.hpp"
#include "spdlog.hpp"
#include <ciso646>
#include <cassert>
#include <cstdint>
@ -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 <>

View file

@ -19,13 +19,13 @@
#include "ini_file.hpp"
#include "kakoune/safe_ptr.hh"
#if defined(SPDLOG_DEBUG_ON)
# include "spdlog.hpp"
#endif
#include <map>
#include <boost/utility/string_view.hpp>
#include <functional>
#include <string>
#if defined(SPDLOG_DEBUG_ON)
# include <spdlog/spdlog.h>
#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];
}

View file

@ -18,11 +18,4 @@
#pragma once
#include <spdlog/spdlog.h>
#include <boost/utility/string_view.hpp>
namespace spdlog {
template <typename OStream>
inline OStream& operator<< (OStream& parOS, const boost::string_view& parStr) {
return parOS << parStr;
}
} //namespace spdlog
#include <spdlog/fmt/ostr.h>

View file

@ -21,10 +21,10 @@
#include "num_to_token.hpp"
#include "tawashi_config.h"
#include "duckhandy/stringize.h"
#include "spdlog.hpp"
#include <cassert>
#include <ciso646>
#include <string>
#include <spdlog/spdlog.h>
#include <utility>
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;

View file

@ -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);

View file

@ -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));

View file

@ -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");
}
}