From a96a346e4ab58729b1f257268f2d2af1ebdca890 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Apr 2015 09:10:10 +0200 Subject: Misc compilation fixes --- brep/diagnostics | 4 ++-- brep/diagnostics.cxx | 2 +- brep/module | 24 ++++++++++++++++-------- brep/module.cxx | 3 ++- brep/search.cxx | 4 ++-- 5 files changed, 23 insertions(+), 14 deletions(-) (limited to 'brep') diff --git a/brep/diagnostics b/brep/diagnostics index 70ddb2a..094a62b 100644 --- a/brep/diagnostics +++ b/brep/diagnostics @@ -233,7 +233,7 @@ namespace brep const diag_epilogue& e, const char* name = nullptr, const void* data = nullptr) - : sev_ (s), epilogue (e), name_ (name), data_ (data) {} + : sev_ (s), epilogue_ (e), name_ (name), data_ (data) {} simple_prologue operator() () const @@ -289,7 +289,7 @@ namespace brep operator() (const L& l) const { return location_prologue ( - epilogue_, severity::error, name, get_location (l, data_)); + epilogue_, severity::error, name_, get_location (l, data_)); } static void diff --git a/brep/diagnostics.cxx b/brep/diagnostics.cxx index 5ab34b6..36d409f 100644 --- a/brep/diagnostics.cxx +++ b/brep/diagnostics.cxx @@ -9,7 +9,7 @@ using namespace std; -namespace build +namespace brep { diag_record:: ~diag_record () noexcept(false) diff --git a/brep/module b/brep/module index dfcf7ad..f6144f2 100644 --- a/brep/module +++ b/brep/module @@ -6,6 +6,7 @@ #define BREP_MODULE #include +#include namespace brep { @@ -21,6 +22,8 @@ namespace brep //@@ Maybe optional "try again" link? // + invalid_request (const char* d, web::status_code s = 422) + : status (s), description (d) {} }; // And this exception indicated a server error (5XX). In particular, @@ -31,6 +34,8 @@ namespace brep struct server_error { diag_data data; + + server_error (diag_data&& d) : data (std::move (d)) {} }; // Every module member function that needs to produce any diagnostics @@ -46,7 +51,7 @@ namespace brep const basic_mark error (severity::error, \ this->log_writer_, \ __PRETTY_FUNCTION__); \ - const basic_mark warn (severity::warn, \ + const basic_mark warn (severity::warning, \ this->log_writer_, \ __PRETTY_FUNCTION__); \ const basic_mark info (severity::info, \ @@ -65,11 +70,13 @@ namespace brep // There will, however, most likely be a conflict between // web::module and our module. Or maybe not, need to try. // - using status_code; - using name_value; - using name_values; - using request; - using response; + + using web::status_code; + using web::name_value; + using web::name_values; + using web::request; + using web::response; + using web::log; class module: public web::module { @@ -90,8 +97,8 @@ namespace brep // std::uint16_t verb_ {0}; - template static void level1 (const F& f) {if (verb_ >= 1) f ();} - template static void level2 (const F& f) {if (verb_ >= 2) f ();} + template void level1 (const F& f) const {if (verb_ >= 1) f ();} + template void level2 (const F& f) const {if (verb_ >= 2) f ();} // Implementation details. // @@ -109,6 +116,7 @@ namespace brep void log_write (diag_data&&) const; + protected: const diag_epilogue log_writer_; }; } diff --git a/brep/module.cxx b/brep/module.cxx index 3420aa0..8a9d71a 100644 --- a/brep/module.cxx +++ b/brep/module.cxx @@ -7,6 +7,7 @@ #include // bind() using namespace std; +using namespace placeholders; namespace brep { @@ -26,7 +27,7 @@ namespace brep // rs.content (e.status, "text/html;charset=utf-8") << e.description; } - catch (const server_error& e) + catch (server_error& e) { // @@ Both log and return as 505. // diff --git a/brep/search.cxx b/brep/search.cxx index cc3cee2..683016c 100644 --- a/brep/search.cxx +++ b/brep/search.cxx @@ -21,10 +21,10 @@ namespace brep throw invalid_request ("search parameters expected"); if (ps.size () > 100) - fail << "too many parameters: " < ps.size () << + fail << "too many parameters: " << ps.size () << info << "are you crazy to specify so many?"; - info << "handling search request from " << rq.client_ip (); + info << "handling search request from "; // << rq.client_ip (); level2 ([&]{trace << "search request with " << ps.size () << " params";}); -- cgit v1.1