From 272b34c1a4639cd0f909bfb52d30339c93b0c42b Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Fri, 6 Jun 2014 22:00:39 +0200 Subject: Implemented WarningCapacitor as a counterpart to ErrorCapacitor * in difference to ErrorCapacitor this class doesn't throw an exception on "discharge" but returns the gathered warnings * adapted FunctionTransform and frontend error handling to include warnings * added static "try_create" method to TransformationFacade ** wraps construction error handling ** custom logic may be embedded using the std::function argument *** this was implemented to prevent unneccessary code duplication for handling both construction and generation errors * adapted FunctionTransform to return warning as "warning" nodes in the result tree ** added functional lambda expression factory method "handleErrors" *** returns a error handling lambda expression for a given ResultNodeFacade * implemented WarningGuard class in frontend executable ** guarantees warnings to be printed to std::cerr independent of any exceptions --- src/support/error/warning_capacitor.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/support/error/warning_capacitor.cc (limited to 'src/support/error/warning_capacitor.cc') diff --git a/src/support/error/warning_capacitor.cc b/src/support/error/warning_capacitor.cc new file mode 100644 index 0000000..f8d2b99 --- /dev/null +++ b/src/support/error/warning_capacitor.cc @@ -0,0 +1,26 @@ +#include "warning_capacitor.h" + +namespace InputXSLT { + +WarningCapacitor::WarningCapacitor(ErrorMultiplexer* multiplexer): + ErrorMultiplexer::receiver(multiplexer), + warning_cache_(new warning_cache()) { } + +auto WarningCapacitor::discharge() -> warning_cache_ptr { + warning_cache_ptr tmp(std::move(this->warning_cache_)); + + this->warning_cache_.reset(new warning_cache()); + + return std::move(tmp); +} + +void WarningCapacitor::receive( + const ErrorMultiplexer::error_type type, + const std::string& message +) { + if ( type == ErrorMultiplexer::error_type::warning ) { + this->warning_cache_->emplace_back(message); + } +} + +} -- cgit v1.2.3