MeVisLab Toolbox Reference
mlXMLParserSystem.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_XMLPARSER_SYSTEM_H
14#define ML_XMLPARSER_SYSTEM_H
15
16#include <memory>
17#include <xercesc/util/XMLString.hpp>
18#include <xercesc/util/XercesVersion.hpp>
19
20XERCES_CPP_NAMESPACE_USE
21
22// ---------------------------------------------------------------------------
24// ---------------------------------------------------------------------------
26{
27public:
28 // -----------------------------------------------------------------------
30 // -----------------------------------------------------------------------
31 StringX(const XMLCh* const toTranscode = nullptr)
32 {
34 fLocalForm = toTranscode ? XMLString::transcode(toTranscode) : nullptr;
35 }
36
37 // -----------------------------------------------------------------------
39 // -----------------------------------------------------------------------
41 {
42 delete[] fLocalForm;
43 fLocalForm = nullptr;
44 }
45
46
47 // -----------------------------------------------------------------------
49 // -----------------------------------------------------------------------
50 void operator=(const XMLCh* const toTranscode)
51 {
52 delete[] fLocalForm;
53 fLocalForm = nullptr;
54 fLocalForm = toTranscode ? XMLString::transcode(toTranscode) : nullptr;
55 }
56
57
58 // -----------------------------------------------------------------------
60 // -----------------------------------------------------------------------
61 const char* localForm() const
62 {
63 return fLocalForm;
64 }
65
66
67private:
68 // -----------------------------------------------------------------------
69 // Private data members
70 //
72 // -----------------------------------------------------------------------
73 const char* fLocalForm;
74};
75
76
77// ---------------------------------------------------------------------------
79// ---------------------------------------------------------------------------
81{
82public:
83 // -----------------------------------------------------------------------
85 // -----------------------------------------------------------------------
86 XString(const char* const toTranscode)
87 {
88 // Call the private transcoding method
89 fUnicodeForm = XMLString::transcode(toTranscode);
90 }
91
92 // -----------------------------------------------------------------------
94 // -----------------------------------------------------------------------
96 {
97 delete[] fUnicodeForm;
98 fUnicodeForm = nullptr;
99 }
100
101
102 // -----------------------------------------------------------------------
104 // -----------------------------------------------------------------------
105 const XMLCh* unicodeForm() const
106 {
107 return fUnicodeForm;
108 }
109
110private:
111 // -----------------------------------------------------------------------
112 // Private data members
113 //
115 // -----------------------------------------------------------------------
116 const XMLCh* fUnicodeForm;
117};
118
119
120// ---------------------------------------------------------------------------
122// ---------------------------------------------------------------------------
123
125{
126 class DOMLSOutput;
127 class DOMLSSerializer;
128} // namespace XERCES_CPP_NAMESPACE
129
131{
132 void operator()(XMLCh* ptr) const
133 {
134 if (ptr) {
135 XMLString::release(&ptr);
136 }
137 }
138};
139
141{
142 template <typename T> void operator()(T* ptr) const
143 {
144 if (ptr) {
145 ptr->release();
146 }
147 }
148};
149
150using UniqueXMLCh = std::unique_ptr<XMLCh, XMLStringDeleter>;
151using UniqueDOMLSOutput = std::unique_ptr<XERCES_CPP_NAMESPACE::DOMLSOutput, DOMReleaseDeleter>;
152using UniqueDOMLSSerializer = std::unique_ptr<XERCES_CPP_NAMESPACE::DOMLSSerializer, DOMReleaseDeleter>;
153
154
155#endif
@ T
Class for easy (though not terribly efficient) transcoding of XMLCh data to local code page for displ...
const char * localForm() const
Getter methods.
StringX(const XMLCh *const toTranscode=nullptr)
Constructors.
~StringX()
Destructor.
void operator=(const XMLCh *const toTranscode)
Assignment.
Class transcoding local code page to XMLCh data for display.
~XString()
Destructor.
XString(const char *const toTranscode)
Constructors.
const XMLCh * unicodeForm() const
Getter methods.
std::unique_ptr< XERCES_CPP_NAMESPACE::DOMLSOutput, DOMReleaseDeleter > UniqueDOMLSOutput
std::unique_ptr< XMLCh, XMLStringDeleter > UniqueXMLCh
std::unique_ptr< XERCES_CPP_NAMESPACE::DOMLSSerializer, DOMReleaseDeleter > UniqueDOMLSSerializer
Custom deleters around Xerces resources with std::unique_ptr.
void operator()(T *ptr) const
void operator()(XMLCh *ptr) const