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
00032
00033
00034
00035 #ifndef DSRXMLD_H
00036 #define DSRXMLD_H
00037
00038 #include "dcmtk/config/osconfig.h"
00039
00040 #include "dcmtk/ofstd/ofstream.h"
00041 #include "dcmtk/dcmsr/dsrtypes.h"
00042 #include "dcmtk/dcmsr/dsrxmlc.h"
00043
00044
00045
00046
00047
00048
00049 #ifndef WITH_LIBXML
00050
00051 typedef void (*xmlDocPtr);
00052 typedef void (*xmlCharEncodingHandlerPtr);
00053 typedef char xmlChar;
00054 #endif
00055
00056
00057
00058
00059
00060
00067 class DSRXMLDocument
00068 : protected DSRTypes
00069 {
00070
00071 public:
00072
00073
00074
00077 DSRXMLDocument();
00078
00081 virtual ~DSRXMLDocument();
00082
00083
00084
00085
00088 void clear();
00089
00093 OFBool valid() const;
00094
00099 OFConsole *getLogStream() const;
00100
00107 void setLogStream(OFConsole *stream);
00108
00109
00110
00111
00119 OFCondition read(const OFString &filename,
00120 const size_t flags = 0);
00121
00122
00123
00124
00129 OFBool encodingHandlerValid() const;
00130
00136 OFCondition setEncodingHandler(const char *charset);
00137
00138
00139
00140
00144 DSRXMLCursor getRootNode() const;
00145
00156 DSRXMLCursor getNamedNode(const DSRXMLCursor &cursor,
00157 const char *name,
00158 const OFBool required = OFTrue) const;
00159
00165 OFBool matchNode(const DSRXMLCursor &cursor,
00166 const char *name) const;
00167
00173 OFCondition checkNode(const DSRXMLCursor &cursor,
00174 const char *name) const;
00175
00176
00177
00178
00184 OFBool hasAttribute(const DSRXMLCursor &cursor,
00185 const char *name) const;
00186
00198 OFString &getStringFromAttribute(const DSRXMLCursor &cursor,
00199 OFString &stringValue,
00200 const char *name,
00201 const OFBool encoding = OFFalse,
00202 const OFBool required = OFTrue) const;
00203
00214 OFCondition getElementFromAttribute(const DSRXMLCursor &cursor,
00215 DcmElement &delem,
00216 const char *name,
00217 const OFBool encoding = OFFalse,
00218 const OFBool required = OFTrue) const;
00219
00228 OFString &getStringFromNodeContent(const DSRXMLCursor &cursor,
00229 OFString &stringValue,
00230 const char *name = NULL,
00231 const OFBool encoding = OFFalse,
00232 const OFBool clearString = OFTrue) const;
00233
00241 OFCondition getElementFromNodeContent(const DSRXMLCursor &cursor,
00242 DcmElement &delem,
00243 const char *name = NULL,
00244 const OFBool encoding = OFFalse) const;
00245
00253 E_ValueType getValueTypeFromNode(const DSRXMLCursor &cursor) const;
00254
00261 E_RelationshipType getRelationshipTypeFromNode(const DSRXMLCursor &cursor) const;
00262
00263
00264
00265
00269 void printUnexpectedNodeWarning(const DSRXMLCursor &cursor) const;
00270
00275 void printGeneralNodeError(const DSRXMLCursor &cursor,
00276 const OFCondition &result) const;
00277
00278 protected:
00279
00285 OFBool convertUtf8ToCharset(const xmlChar *fromString,
00286 OFString &toString) const;
00287
00292 void printMissingAttributeError(const DSRXMLCursor &cursor,
00293 const char *name) const;
00294
00295
00296
00303 static OFString &getFullNodePath(const DSRXMLCursor &cursor,
00304 OFString &stringValue,
00305 const OFBool omitCurrent = OFFalse);
00306
00307
00308 private:
00309
00311 xmlDocPtr Document;
00313 xmlCharEncodingHandlerPtr EncodingHandler;
00314
00316 OFConsole *LogStream;
00317
00318
00319
00320 DSRXMLDocument(const DSRXMLDocument &);
00321 DSRXMLDocument &operator=(const DSRXMLDocument &);
00322 };
00323
00324
00325 #endif
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349