DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
DDCore
src
JSON
DocumentHandler.cpp
Go to the documentation of this file.
1
//==========================================================================
2
// AIDA Detector description implementation
3
//--------------------------------------------------------------------------
4
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5
// All rights reserved.
6
//
7
// For the licensing terms see $DD4hepINSTALL/LICENSE.
8
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9
//
10
// Author : M.Frank
11
//
12
//==========================================================================
13
14
// Framework include files
15
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
16
#include <
JSON/Helper.h
>
17
#include <
JSON/DocumentHandler.h
>
18
19
// C/C++ include files
20
#include <boost/property_tree/json_parser.hpp>
21
#include <memory>
22
#include <stdexcept>
23
24
using namespace
dd4hep::json
;
25
27
DocumentHandler::DocumentHandler
() {
28
}
29
31
DocumentHandler::~DocumentHandler
() {
32
}
33
35
Document
DocumentHandler::load
(
const
std::string& fname)
const
{
36
std::string fn = fname;
37
if
( fname.find(
"://"
) != std::string::npos ) fn = fname.substr(fname.find(
"://"
)+3);
38
//std::string cmd = "cat "+fn;
39
//::printf("\n\n+++++ Dump json file: %s\n\n\n",fn.c_str());
40
//::system(cmd.c_str());
41
std::unique_ptr<JsonElement> doc(
new
JsonElement
(fn,
ptree
()));
42
boost::property_tree::read_json(fn,doc->second);
43
return
doc.release();
44
}
45
47
Document
DocumentHandler::parse
(
const
char
* doc_string,
size_t
length)
const
{
48
if
( doc_string && length ) {}
49
throw
std::runtime_error(
"Bla"
);
50
}
dd4hep::json::DocumentHandler::parse
virtual Document parse(const char *doc_string, size_t length) const
Parse a standalong XML string into a document.
Definition:
DocumentHandler.cpp:47
Helper.h
dd4hep::json::DocumentHandler::~DocumentHandler
virtual ~DocumentHandler()
Default destructor.
Definition:
DocumentHandler.cpp:31
dd4hep::json::JsonElement
boost::property_tree::ptree::value_type JsonElement
Definition:
config.h:33
dd4hep::json::DocumentHandler::load
virtual Document load(const std::string &fname) const
Load XML file and parse it.
Definition:
DocumentHandler.cpp:35
dd4hep::json::Document
Class supporting the basic functionality of an JSON document.
Definition:
Elements.h:296
dd4hep::json
Namespace for the AIDA detector description toolkit supporting JSON utilities.
Definition:
Factories.h:35
dd4hep::json::ptree
boost::property_tree::ptree ptree
Definition:
config.h:30
dd4hep::json::DocumentHandler::DocumentHandler
DocumentHandler()
Default constructor.
Definition:
DocumentHandler.cpp:27
DocumentHandler.h
Generated on Tue Dec 10 2024 18:30:06 for DD4hep by
1.8.18