1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-11-27 00:43:47 +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 { namespace {
} //unnamed 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 bool already_read = false;
static PostMapType map; static PostMapType map;
static std::string original_data; static std::string original_data;
@ -45,7 +45,7 @@ namespace tawashi {
if (input_len > 0) { if (input_len > 0) {
original_data.reserve(input_len); original_data.reserve(input_len);
std::copy_n( std::copy_n(
std::istream_iterator<char>(std::cin), std::istream_iterator<char>(parSrc),
input_len, input_len,
std::back_inserter(original_data) std::back_inserter(original_data)
); );

View file

@ -19,6 +19,7 @@
#include <boost/container/flat_map.hpp> #include <boost/container/flat_map.hpp>
#include <string> #include <string>
#include <istream>
namespace tawashi { namespace tawashi {
@ -27,6 +28,6 @@ namespace tawashi {
typedef boost::container::flat_map<std::string, std::string> PostMapType; 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 cgi
} //namespace tawashi } //namespace tawashi

View file

@ -70,7 +70,7 @@ namespace tawashi {
} }
void SubmitPasteResponse::on_process() { 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 pastie;
boost::string_ref lang; boost::string_ref lang;
boost::string_ref duration; boost::string_ref duration;