ATLAS Offline Software
InnerDetector
InDetValidation
InDetPhysValMonitoring
src
xmlUtilities.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
//
5
// xmlUtilities.h
6
// HDef
7
//
8
// Created by sroe on 15/03/2016.
9
//
10
11
#ifndef xmlUtilities_h
12
#define xmlUtilities_h
13
#include <memory>
14
#include <string>
15
#include <xercesc/util/PlatformUtils.hpp>
// Initialize, Terminate
16
#include <xercesc/util/XMLString.hpp>
// transcode
17
#include <xercesc/dom/DOM.hpp>
// DOMxxx
18
19
#include "
CxxUtils/checker_macros.h
"
20
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
;
// Not sure if usage of Xerces-C++ here is thread safe.
21
// The following warning message is given if checked:
22
// warning: Use of static expression 'xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
23
// of type 'xercesc_3_1::MemoryManager*' within function
24
// 'toNative(const XMLCh*)::<lambda(char*)>' may not be thread-safe.
25
//
26
// https://xerces.apache.org/xerces-c/faq-parse-3.html#faq-6
27
// Is Xerces-C++ thread-safe?
28
// The answer is yes if you observe the following rules for using Xerces-C++
29
// in a multi-threaded environment:
30
// ... ...
31
32
typedef
std::basic_string<XMLCh>
XercesString
;
33
inline
XercesString
34
fromNative
(
const
char
*
str
) {
35
auto
xDeleter = [&](XMLCh buf[]) {
36
xercesc::XMLString::release
(&buf);
37
};
38
39
std::unique_ptr<XMLCh[], decltype(xDeleter)>
ptr
(xercesc::XMLString::transcode(
str
), xDeleter);
40
41
return
XercesString
(
ptr
.get());
42
}
43
44
inline
XercesString
45
fromNative
(
const
std::string&
str
) {
46
return
fromNative
(
str
.c_str());
47
}
48
49
inline
std::string
50
toNative
(
const
XMLCh*
str
) {
51
auto
cDeleter = [&](
char
buf[]) {
52
xercesc::XMLString::release
(&buf);
53
};
54
55
std::unique_ptr<
char
[], decltype(cDeleter)>
ptr
(xercesc::XMLString::transcode(
str
), cDeleter);
56
57
return
std::string(
ptr
.get());
58
}
59
60
inline
std::string
61
toNative
(
const
XercesString
&
str
) {
62
return
toNative
(
str
.c_str());
63
}
64
65
namespace
myXerces
{
66
struct
Lib
{
67
Lib
() {
68
xercesc::XMLPlatformUtils::Initialize
();
69
}
70
71
~Lib
() {
72
xercesc::XMLPlatformUtils::Terminate();
73
}
74
};
75
}
// namespace myXerces
76
77
78
79
#endif
/* xmlUtilities_h */
toNative
std::string toNative(const XMLCh *str)
Definition:
xmlUtilities.h:50
myXerces::Lib::Lib
Lib()
Definition:
xmlUtilities.h:67
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition:
xmlUtilities.h:20
XercesString
std::basic_string< XMLCh > XercesString
Definition:
xmlUtilities.h:32
dbg::ptr
void * ptr(T *p)
Definition:
SGImplSvc.cxx:74
myXerces::Lib
Definition:
xmlUtilities.h:66
myXerces::Lib::~Lib
~Lib()
Definition:
xmlUtilities.h:71
fromNative
XercesString fromNative(const char *str)
Definition:
xmlUtilities.h:34
python.EventInfoMgtInit.release
release
Definition:
EventInfoMgtInit.py:24
myXerces
Definition:
xmlUtilities.h:65
jobOptions.Initialize
Initialize
Definition:
jobOptions.pA.py:28
str
Definition:
BTagTrackIpAccessor.cxx:11
checker_macros.h
Define macros for attributes used to control the static checker.
Generated on Mon Dec 23 2024 21:23:19 for ATLAS Offline Software by
1.8.18