aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transformation_facade.cc54
-rw-r--r--src/transformation_facade.h41
2 files changed, 62 insertions, 33 deletions
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 41ee458..07483c1 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -25,49 +25,43 @@ TransformationFacade::~TransformationFacade() {
);
}
-int TransformationFacade::generate(const std::string& target) {
- StylesheetParameterGuard guard(this->transformer_);
-
- return this->generate(target, guard);
-}
-
int TransformationFacade::generate(
- const std::string& target,
- const StylesheetParameterGuard::map& parameters
+ const std::string& targetPath,
+ StylesheetParameterGuard& parameters
) {
- StylesheetParameterGuard guard(this->transformer_, parameters);
-
- return this->generate(target, guard);
-}
+ const boost::filesystem::path targetPathHelper(
+ boost::filesystem::absolute(targetPath)
+ );
-int TransformationFacade::generate(
- const std::string& target,
- const xalan::XObjectPtr& parameter
-) {
- StylesheetParameterGuard guard(this->transformer_);
- guard.set("parameters", parameter);
+ parameters.set(
+ "target-file", targetPathHelper.filename().string()
+ );
+ parameters.set(
+ "parent-directory", targetPathHelper.parent_path().filename().string()
+ );
- return this->generate(target, guard);
+ return this->generate(
+ xalan::XSLTResultTarget(targetPath.data()),
+ parameters
+ );
}
int TransformationFacade::generate(
- const std::string& target,
+ std::basic_ostream<char>& targetStream,
StylesheetParameterGuard& parameters
) {
- const boost::filesystem::path targetFilePath(
- boost::filesystem::absolute(target)
- );
-
- parameters.set(
- "target-file", targetFilePath.filename().string()
- );
- parameters.set(
- "parent-directory", targetFilePath.parent_path().filename().string()
+ return this->generate(
+ xalan::XSLTResultTarget(targetStream),
+ parameters
);
+}
+int TransformationFacade::generate(
+ xalan::XSLTResultTarget&& outputTarget,
+ StylesheetParameterGuard&
+) {
std::stringstream emptyStream("<dummy/>");
xalan::XSLTInputSource inputSource(emptyStream);
- xalan::XSLTResultTarget outputTarget(target.data());
const int resultCode = this->transformer_.transform(
inputSource,
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index be06d07..7fb0926 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -15,9 +15,14 @@ class TransformationFacade {
explicit TransformationFacade(const std::string&);
~TransformationFacade();
- int generate(const std::string&);
- int generate(const std::string&, const StylesheetParameterGuard::map&);
- int generate(const std::string&, const xalan::XObjectPtr&);
+ template <typename Target>
+ int generate(Target&);
+
+ template <typename Target>
+ int generate(Target&, const StylesheetParameterGuard::map&);
+
+ template <typename Target>
+ int generate(Target&, const xalan::XObjectPtr&);
private:
const xalan::XalanCompiledStylesheet* transformation_;
@@ -25,9 +30,39 @@ class TransformationFacade {
xalan::XalanTransformer transformer_;
int generate(const std::string&, StylesheetParameterGuard&);
+ int generate(std::basic_ostream<char>&, StylesheetParameterGuard&);
+ int generate(xalan::XSLTResultTarget&&, StylesheetParameterGuard&);
};
+template <typename Target>
+int TransformationFacade::generate(Target& target) {
+ StylesheetParameterGuard guard(this->transformer_);
+
+ return this->generate(target, guard);
+}
+
+template <typename Target>
+int TransformationFacade::generate(
+ Target& target,
+ const StylesheetParameterGuard::map& parameters
+) {
+ StylesheetParameterGuard guard(this->transformer_, parameters);
+
+ return this->generate(target, guard);
+}
+
+template <typename Target>
+int TransformationFacade::generate(
+ Target& target,
+ const xalan::XObjectPtr& parameter
+) {
+ StylesheetParameterGuard guard(this->transformer_);
+ guard.set("parameters", parameter);
+
+ return this->generate(target, guard);
+}
+
}
#endif // INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_