OFFIS DCMTK  Version 3.6.0
dsrxmld.h
1 /*
2  *
3  * Copyright (C) 2003-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmsr
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose:
19  * classes: DSRXMLDocument
20  *
21  * Last Update: $Author: joergr $
22  * Update Date: $Date: 2010-10-14 13:16:33 $
23  * CVS/RCS Revision: $Revision: 1.7 $
24  * Status: $State: Exp $
25  *
26  * CVS/RCS Log at end of file
27  *
28  */
29 
30 
31 #ifndef DSRXMLD_H
32 #define DSRXMLD_H
33 
34 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
35 
36 #include "dcmtk/ofstd/ofstream.h"
37 #include "dcmtk/dcmsr/dsrtypes.h"
38 #include "dcmtk/dcmsr/dsrxmlc.h"
39 
40 
41 /*--------------------*
42  * type definitions *
43  *--------------------*/
44 
45 #ifndef WITH_LIBXML
46 // define types if 'libxml' absent
47 typedef void (*xmlDocPtr);
48 typedef void (*xmlCharEncodingHandlerPtr);
49 typedef char xmlChar;
50 #endif
51 
52 
53 /*---------------------*
54  * class declaration *
55  *---------------------*/
56 
64  : protected DSRTypes
65 {
66 
67  public:
68 
69  // --- constructors and destructor ---
70 
74 
77  virtual ~DSRXMLDocument();
78 
79 
80  // --- misc routines ---
81 
84  void clear();
85 
89  OFBool valid() const;
90 
91  // --- input and output ---
92 
99  OFCondition read(const OFString &filename,
100  const size_t flags = 0);
101 
102 
103  // --- character encoding ---
104 
109  OFBool encodingHandlerValid() const;
110 
116  OFCondition setEncodingHandler(const char *charset);
117 
118 
119  // --- navigation and checking ---
120 
124  DSRXMLCursor getRootNode() const;
125 
135  DSRXMLCursor getNamedNode(const DSRXMLCursor &cursor,
136  const char *name,
137  const OFBool required = OFTrue) const;
138 
144  OFBool matchNode(const DSRXMLCursor &cursor,
145  const char *name) const;
146 
152  OFCondition checkNode(const DSRXMLCursor &cursor,
153  const char *name) const;
154 
155 
156  // --- get attributes and node content ---
157 
163  OFBool hasAttribute(const DSRXMLCursor &cursor,
164  const char *name) const;
165 
178  OFString &stringValue,
179  const char *name,
180  const OFBool encoding = OFFalse,
181  const OFBool required = OFTrue) const;
182 
194  DcmElement &delem,
195  const char *name,
196  const OFBool encoding = OFFalse,
197  const OFBool required = OFTrue) const;
198 
208  OFString &stringValue,
209  const char *name = NULL,
210  const OFBool encoding = OFFalse,
211  const OFBool clearString = OFTrue) const;
212 
221  DcmElement &delem,
222  const char *name = NULL,
223  const OFBool encoding = OFFalse) const;
224 
232  E_ValueType getValueTypeFromNode(const DSRXMLCursor &cursor) const;
233 
241 
242 
243  // --- error/warning messages ---
244 
248  void printUnexpectedNodeWarning(const DSRXMLCursor &cursor) const;
249 
254  void printGeneralNodeError(const DSRXMLCursor &cursor,
255  const OFCondition &result) const;
256 
257  protected:
258 
264  OFBool convertUtf8ToCharset(const xmlChar *fromString,
265  OFString &toString) const;
266 
271  void printMissingAttributeError(const DSRXMLCursor &cursor,
272  const char *name) const;
273 
274  // --- static function ---
275 
282  static OFString &getFullNodePath(const DSRXMLCursor &cursor,
283  OFString &stringValue,
284  const OFBool omitCurrent = OFFalse);
285 
286 
287  private:
288 
290  xmlDocPtr Document;
292  xmlCharEncodingHandlerPtr EncodingHandler;
293 
294 // --- declaration copy constructor and assignment operator
295 
297  DSRXMLDocument &operator=(const DSRXMLDocument &);
298 };
299 
300 
301 #endif
302 
303 
304 /*
305  * CVS/RCS Log:
306  * $Log: dsrxmld.h,v $
307  * Revision 1.7 2010-10-14 13:16:33 joergr
308  * Updated copyright header. Added reference to COPYRIGHT file.
309  *
310  * Revision 1.6 2009-10-13 14:57:51 uli
311  * Switched to logging mechanism provided by the "new" oflog module.
312  *
313  * Revision 1.5 2005-12-08 16:05:36 meichel
314  * Changed include path schema for all DCMTK header files
315  *
316  * Revision 1.4 2004/01/05 14:35:44 joergr
317  * Renamed XML attribute "ref_id" to "ref".
318  *
319  * Revision 1.3 2003/12/01 15:46:18 joergr
320  * Changed XML encoding of by-reference relationships if flag
321  * XF_valueTypeAsAttribute is set.
322  *
323  * Revision 1.2 2003/08/07 17:31:00 joergr
324  * Removed libxml dependency from header files. Simplifies linking (MSVC).
325  *
326  * Revision 1.1 2003/08/07 12:16:37 joergr
327  * Added interface classes hiding the access to libxml (document and cursor
328  * class).
329  *
330  *
331  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2