aboutsummaryrefslogtreecommitdiff
path: root/src/support/xerces_string_guard.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/support/xerces_string_guard.h')
-rw-r--r--src/support/xerces_string_guard.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/support/xerces_string_guard.h b/src/support/xerces_string_guard.h
index f64a53e..7b9517a 100644
--- a/src/support/xerces_string_guard.h
+++ b/src/support/xerces_string_guard.h
@@ -7,15 +7,33 @@
namespace InputXSLT {
+template <typename Type>
class XercesStringGuard {
public:
- XercesStringGuard(const std::string&);
- ~XercesStringGuard();
-
- XMLCh* operator*();
+ XercesStringGuard(const Type* src):
+ string_(src) { }
+
+ XercesStringGuard(
+ const std::basic_string<
+ typename std::remove_pointer<decltype(
+ xercesc::XMLString::transcode(new Type[1])
+ )>::type
+ >& src
+ ):
+ string_(xercesc::XMLString::transcode(src.data())) { }
+
+ ~XercesStringGuard() {
+ xercesc::XMLString::release(
+ const_cast<Type**>(&this->string_)
+ );
+ }
+
+ inline const Type* operator*() const {
+ return this->string_;
+ }
private:
- XMLCh* const string_;
+ const Type* const string_;
};