Put the always-stdin symbol in the right place.
This commit is contained in:
parent
5d2c5863a5
commit
494364c22e
2 changed files with 14 additions and 13 deletions
|
@ -24,12 +24,6 @@
|
|||
#include <utility>
|
||||
#include <iostream>
|
||||
|
||||
//#define HTML_ALWAYS_STDIN
|
||||
|
||||
#if !defined(NDEBUG) && defined(HTML_ALWAYS_STDIN)
|
||||
# define HTML_ALWAYS_STDIN_ENABLED
|
||||
#endif
|
||||
|
||||
namespace duck {
|
||||
HtmlPool::HtmlPool (std::string&& agent_name) :
|
||||
m_agent(std::move(agent_name))
|
||||
|
@ -39,13 +33,9 @@ namespace duck {
|
|||
auto HtmlPool::OnResourceLoad (ResourceObjectParameterType parRes) -> ResourceType* {
|
||||
std::unique_ptr<std::string> html;
|
||||
|
||||
std::cout << "Fetching html from \"" << parRes << "\"\n";
|
||||
std::cout << "OnResourceLoad(): fetching html from \"" << parRes << "\"\n";
|
||||
|
||||
#if defined(HTML_ALWAYS_STDIN_ENABLED)
|
||||
if (true) {
|
||||
#else
|
||||
if (parRes == "-") {
|
||||
#endif
|
||||
html = std::make_unique<std::string>(read_all(std::cin));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
//#define HTML_ALWAYS_STDIN
|
||||
|
||||
#if !defined(NDEBUG) && defined(HTML_ALWAYS_STDIN)
|
||||
# define HTML_ALWAYS_STDIN_ENABLED
|
||||
#endif
|
||||
|
||||
namespace duck { namespace sl {
|
||||
struct XPathRunner::XPathKey {
|
||||
XPathKey (const std::string_view& parSrc, const std::string_view& parQuery) :
|
||||
|
@ -53,17 +59,22 @@ namespace duck { namespace sl {
|
|||
std::string_view parSrc,
|
||||
std::string_view parQuery
|
||||
) {
|
||||
std::cout << "XPathRunner::query() - \"" << parQuery << "\"\n";
|
||||
std::cout << "XPathRunner::query(\"" << parSrc << "\", \"" << parQuery << "\")\"\n";
|
||||
auto ins_retval = m_cached_results.insert(std::make_pair(XPathKey(parSrc, parQuery), std::vector<std::string>()));
|
||||
const bool inserted = ins_retval.second;
|
||||
assert(ins_retval.first != m_cached_results.end());
|
||||
std::vector<std::string>& curr_vec = ins_retval.first->second;
|
||||
|
||||
if (inserted) {
|
||||
const auto id = m_pool->AddResource(parSrc);
|
||||
#if defined(HTML_ALWAYS_STDIN_ENABLED)
|
||||
const auto id = m_pool->GetOrAdd("-");
|
||||
#else
|
||||
const auto id = m_pool->GetOrAdd(parSrc);
|
||||
#endif
|
||||
const std::string* html = m_pool->GetByID(id);
|
||||
|
||||
curr_vec = xpath_query(*html, std::string(parQuery));
|
||||
std::cout << "First time for this query, result cached now\n";
|
||||
}
|
||||
|
||||
std::cout << "returning " << curr_vec.size() << " items: ";
|
||||
|
|
Loading…
Reference in a new issue