Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Framework include files
0015 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
0016 #include <JSON/Helper.h>
0017 #include <JSON/DocumentHandler.h>
0018 
0019 // C/C++ include files
0020 #include <boost/property_tree/json_parser.hpp>
0021 #include <memory>
0022 #include <stdexcept>
0023 
0024 using namespace dd4hep::json;
0025 
0026 /// Default constructor
0027 DocumentHandler::DocumentHandler()  {
0028 }
0029                                     
0030 /// Default destructor
0031 DocumentHandler::~DocumentHandler()   {
0032 }
0033 
0034 /// Load XML file and parse it.
0035 Document DocumentHandler::load(const std::string& fname) const   {
0036   std::string fn = fname;
0037   if ( fname.find("://") != std::string::npos ) fn = fname.substr(fname.find("://")+3);
0038   //std::string cmd = "cat "+fn;
0039   //::printf("\n\n+++++ Dump json file: %s\n\n\n",fn.c_str());
0040   //::system(cmd.c_str());
0041   std::unique_ptr<JsonElement> doc(new JsonElement(fn, ptree()));
0042   boost::property_tree::read_json(fn,doc->second);
0043   return doc.release();
0044 }
0045 
0046 /// Parse a standalong XML string into a document.
0047 Document DocumentHandler::parse(const char* doc_string, size_t length) const   {
0048   if ( doc_string && length ) {}
0049   throw std::runtime_error("Bla");
0050 }