ITK  6.0.0
Insight Toolkit
itkDOMNodeXMLReader.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef itkDOMNodeXMLReader_h
20#define itkDOMNodeXMLReader_h
21
22#include "itkDOMNode.h"
23#include "itkObject.h"
24#include "ITKIOXMLExport.h"
25
26#include <istream>
27
28namespace itk
29{
30
61class ITKIOXML_EXPORT DOMNodeXMLReader : public Object
62{
63public:
64 ITK_DISALLOW_COPY_AND_MOVE(DOMNodeXMLReader);
72
74 itkNewMacro(Self);
75
77 itkOverrideGetNameOfClassMacro(DOMNodeXMLReader);
78
81
83 itkSetStringMacro(FileName);
84
86 itkGetStringMacro(FileName);
87
92 itkSetObjectMacro(DOMNodeXML, OutputType);
93#if !defined(ITK_LEGACY_REMOVE)
94 // Provide backwards compatible interface
95 virtual void
96 SetOutput(OutputType * _arg)
97 {
98 this->SetDOMNodeXML(_arg);
99 }
100#endif
110 // NOTE: The m_DOMNodeXML is only
111 // exposed via the Source generation interface
112 // by the GetOutput() method that mimics
113 // a process object.
114 virtual const OutputType *
115 GetOutput() const
116 {
117 return this->m_DOMNodeXML.GetPointer();
118 }
119 virtual OutputType *
121 {
122 return this->m_DOMNodeXML.GetPointer();
123 }
126#if !defined(ITK_LEGACY_REMOVE)
127 // This interface was exposed in ITKv4 when the itkGetModifiableObjectMacro was used
128 virtual OutputType *
129 GetModifiedOutput()
130 {
131 return this->m_DOMNodeXML.GetPointer();
132 }
133#endif
134
139 void
140 Update(std::istream & is);
141
145 virtual void
147
151 virtual void
152 StartElement(const char * name, const char ** atts);
153
157 virtual void
158 EndElement(const char * name);
159
163 virtual void
164 CharacterDataHandler(const char * text, int len);
165
166protected:
168
169private:
171 std::string m_FileName{};
172
174 OutputPointer m_DOMNodeXML{};
175
177 OutputType * m_Context{ nullptr };
178};
179
180} // namespace itk
181
183inline std::istream &
184operator>>(std::istream & is, itk::DOMNode & object)
185{
186 auto reader = itk::DOMNodeXMLReader::New();
187 reader->SetDOMNodeXML(&object);
188 reader->Update(is);
189 return is;
190}
193#endif // itkDOMNodeXMLReader_h
Class to read a DOM object from an XML file or an input stream.
virtual void StartElement(const char *name, const char **atts)
static Pointer New()
virtual OutputType * GetOutput()
virtual void EndElement(const char *name)
virtual void CharacterDataHandler(const char *text, int len)
void Update(std::istream &is)
virtual void Update()
virtual const OutputType * GetOutput() const
Class to represent a node in a Document Object Model (DOM) tree structure.
Definition: itkDOMNode.h:54
Light weight base class for most itk classes.
Base class for most ITK classes.
Definition: itkObject.h:62
SmartPointer< Self > Pointer
std::istream & operator>>(std::istream &is, itk::DOMNode &object)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....