aboutsummaryrefslogtreecommitdiff
path: root/src/transformation_facade.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-06-06 22:00:39 +0200
committerAdrian Kummerländer2014-06-06 22:00:39 +0200
commit272b34c1a4639cd0f909bfb52d30339c93b0c42b (patch)
treed3bed13ddf28e86f8de319222daf535305082431 /src/transformation_facade.cc
parent78bb3387b15d15d766fb5d17a99612f0480f2bee (diff)
downloadInputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.gz
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.bz2
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.lz
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.xz
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.tar.zst
InputXSLT-272b34c1a4639cd0f909bfb52d30339c93b0c42b.zip
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
Diffstat (limited to 'src/transformation_facade.cc')
-rw-r--r--src/transformation_facade.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 6d7b7a3..3c94bdd 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -7,17 +7,33 @@
#include <sstream>
-#include "support/error/error_capacitor.h"
-
namespace InputXSLT {
+auto TransformationFacade::try_create(
+ const std::string& transformation,
+ IncludeEntityResolver* resolver,
+ const std::function<void(const ErrorCapacitor::error_cache&)>& handleErrors
+) -> ptr{
+ try {
+ return ptr(
+ new InputXSLT::TransformationFacade(transformation, resolver)
+ );
+ }
+ catch (const ErrorCapacitor::exception& exception) {
+ handleErrors(*exception);
+
+ return ptr();
+ }
+}
+
TransformationFacade::TransformationFacade(
const std::string& transformation,
IncludeEntityResolver* resolver
):
transformation_{},
transformer_(),
- error_multiplexer_(&transformer_) {
+ error_multiplexer_(&transformer_),
+ warning_capacitor_(&error_multiplexer_) {
this->transformer_.setEntityResolver(resolver);
ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
@@ -36,6 +52,10 @@ TransformationFacade::~TransformationFacade() {
);
}
+WarningCapacitor::warning_cache_ptr TransformationFacade::getCachedWarnings() {
+ return this->warning_capacitor_.discharge();
+}
+
void TransformationFacade::generate(
const std::string& targetPath,
StylesheetParameterGuard& parameters