Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:38

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 #ifndef XML_DOCUMENTHANDLER_H
0015 #define XML_DOCUMENTHANDLER_H
0016 
0017 // Framework include files
0018 #include <XML/XMLElements.h>
0019 
0020 /// Namespace for the AIDA detector description toolkit
0021 namespace dd4hep {
0022 
0023   /// Namespace containing utilities to parse XML files using XercesC or TinyXML
0024   namespace xml {
0025 
0026     // Forward declarations
0027     class DocumentErrorHandle_tr;
0028     class UriReader;
0029 
0030     /// Class supporting to read and parse XML documents.
0031     /**
0032      *  Wrapper object around the document parser.
0033      *  Supports both, XercesC and TiXml.
0034      *
0035      *  \author   M.Frank
0036      *  \version  1.0
0037      *  \ingroup DD4HEP_XML
0038      */
0039     class DocumentHandler {
0040     public:
0041       /// Default constructor
0042       DocumentHandler();
0043       /// Default destructor
0044       virtual ~DocumentHandler();
0045       /// Default comment string
0046       static std::string defaultComment();
0047       // Create new XML document by parsing empty xml buffer
0048       Document create(const char* tag, const char* comment = 0) const;
0049       // Create new XML document by parsing empty xml buffer
0050       Document create(const std::string& tag, const std::string& comment) const;
0051       /// Load XML file and parse it.
0052       virtual Document load(const std::string& fname) const;
0053       /// Load XML file and parse it using URI resolver to read data.
0054       virtual Document load(const std::string& fname, UriReader* reader) const;
0055       /// Load secondary XML file with relative addressing with respect to handle
0056       virtual Document load(Handle_t base, const XmlChar* fname) const;
0057       /// Load secondary XML file with relative addressing with respect to handle
0058       virtual Document load(Handle_t base, const XmlChar* fname, UriReader* reader) const;
0059       /// Parse a standalong XML string into a document.
0060       virtual Document parse(const char* doc_string, size_t length) const;
0061       /// Parse a standalong XML string into a document using URI resolver to read data
0062       virtual Document parse(const char* doc_string, size_t length, const char* sys_id, UriReader* reader) const;
0063       /// Write xml document to output file (stdout if file name empty)
0064       virtual int output(Document doc, const std::string& fname) const;
0065 
0066       /// Set minimum print level
0067       static int setMinimumPrintLevel(int level);
0068       /// System ID of a given XML entity
0069       static std::string system_path(Handle_t base);
0070       /// System ID of a new XML entity in the same directory as base
0071       static std::string system_path(Handle_t base, const XmlChar* fname);
0072       /// System ID of a new XML entity in the same directory as base
0073       static std::string system_path(Handle_t base, const std::string& fname);
0074       /// System directory of a given XML entity
0075       static std::string system_directory(Handle_t base);
0076       /// System directory of a new XML entity in the same directory as base
0077       static std::string system_directory(Handle_t base, const XmlChar* fname);
0078 
0079     };
0080   }
0081 } /* End namespace dd4hep            */
0082 #endif // XML_DOCUMENTHANDLER_H