1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-12-27 21:35:41 +00:00

Pass the istream to read_post instead of assuming std::cin.

This commit is contained in:
King_DuckZ 2017-05-10 20:42:42 +01:00
parent c907e5dd49
commit ed1343bd7b
3 changed files with 5 additions and 4 deletions

View file

@ -32,7 +32,7 @@ namespace tawashi {
namespace {
} //unnamed namespace
const PostMapType& read_post (const Env& parEnv) {
const PostMapType& read_post (std::istream& parSrc, const Env& parEnv) {
static bool already_read = false;
static PostMapType map;
static std::string original_data;
@ -45,7 +45,7 @@ namespace tawashi {
if (input_len > 0) {
original_data.reserve(input_len);
std::copy_n(
std::istream_iterator<char>(std::cin),
std::istream_iterator<char>(parSrc),
input_len,
std::back_inserter(original_data)
);

View file

@ -19,6 +19,7 @@
#include <boost/container/flat_map.hpp>
#include <string>
#include <istream>
namespace tawashi {
@ -27,6 +28,6 @@ namespace tawashi {
typedef boost::container::flat_map<std::string, std::string> PostMapType;
const PostMapType& read_post (const Env& parEnv);
const PostMapType& read_post (std::istream& parSrc, const Env& parEnv);
} //namespace cgi
} //namespace tawashi

View file

@ -70,7 +70,7 @@ namespace tawashi {
}
void SubmitPasteResponse::on_process() {
auto post = cgi::read_post(cgi_env());
auto post = cgi::read_post(std::cin, cgi_env());
boost::string_ref pastie;
boost::string_ref lang;
boost::string_ref duration;