00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef DSRXMLD_H
00032 #define DSRXMLD_H
00033
00034 #include "dcmtk/config/osconfig.h"
00035
00036 #include "dcmtk/ofstd/ofstream.h"
00037 #include "dcmtk/dcmsr/dsrtypes.h"
00038 #include "dcmtk/dcmsr/dsrxmlc.h"
00039
00040
00041
00042
00043
00044
00045 #ifndef WITH_LIBXML
00046
00047 typedef void (*xmlDocPtr);
00048 typedef void (*xmlCharEncodingHandlerPtr);
00049 typedef char xmlChar;
00050 #endif
00051
00052
00053
00054
00055
00056
00063 class DSRXMLDocument
00064 : protected DSRTypes
00065 {
00066
00067 public:
00068
00069
00070
00073 DSRXMLDocument();
00074
00077 virtual ~DSRXMLDocument();
00078
00079
00080
00081
00084 void clear();
00085
00089 OFBool valid() const;
00090
00091
00092
00099 OFCondition read(const OFString &filename,
00100 const size_t flags = 0);
00101
00102
00103
00104
00109 OFBool encodingHandlerValid() const;
00110
00116 OFCondition setEncodingHandler(const char *charset);
00117
00118
00119
00120
00124 DSRXMLCursor getRootNode() const;
00125
00135 DSRXMLCursor getNamedNode(const DSRXMLCursor &cursor,
00136 const char *name,
00137 const OFBool required = OFTrue) const;
00138
00144 OFBool matchNode(const DSRXMLCursor &cursor,
00145 const char *name) const;
00146
00152 OFCondition checkNode(const DSRXMLCursor &cursor,
00153 const char *name) const;
00154
00155
00156
00157
00163 OFBool hasAttribute(const DSRXMLCursor &cursor,
00164 const char *name) const;
00165
00177 OFString &getStringFromAttribute(const DSRXMLCursor &cursor,
00178 OFString &stringValue,
00179 const char *name,
00180 const OFBool encoding = OFFalse,
00181 const OFBool required = OFTrue) const;
00182
00193 OFCondition getElementFromAttribute(const DSRXMLCursor &cursor,
00194 DcmElement &delem,
00195 const char *name,
00196 const OFBool encoding = OFFalse,
00197 const OFBool required = OFTrue) const;
00198
00207 OFString &getStringFromNodeContent(const DSRXMLCursor &cursor,
00208 OFString &stringValue,
00209 const char *name = NULL,
00210 const OFBool encoding = OFFalse,
00211 const OFBool clearString = OFTrue) const;
00212
00220 OFCondition getElementFromNodeContent(const DSRXMLCursor &cursor,
00221 DcmElement &delem,
00222 const char *name = NULL,
00223 const OFBool encoding = OFFalse) const;
00224
00232 E_ValueType getValueTypeFromNode(const DSRXMLCursor &cursor) const;
00233
00240 E_RelationshipType getRelationshipTypeFromNode(const DSRXMLCursor &cursor) const;
00241
00242
00243
00244
00248 void printUnexpectedNodeWarning(const DSRXMLCursor &cursor) const;
00249
00254 void printGeneralNodeError(const DSRXMLCursor &cursor,
00255 const OFCondition &result) const;
00256
00257 protected:
00258
00264 OFBool convertUtf8ToCharset(const xmlChar *fromString,
00265 OFString &toString) const;
00266
00271 void printMissingAttributeError(const DSRXMLCursor &cursor,
00272 const char *name) const;
00273
00274
00275
00282 static OFString &getFullNodePath(const DSRXMLCursor &cursor,
00283 OFString &stringValue,
00284 const OFBool omitCurrent = OFFalse);
00285
00286
00287 private:
00288
00290 xmlDocPtr Document;
00292 xmlCharEncodingHandlerPtr EncodingHandler;
00293
00294
00295
00296 DSRXMLDocument(const DSRXMLDocument &);
00297 DSRXMLDocument &operator=(const DSRXMLDocument &);
00298 };
00299
00300
00301 #endif
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331