ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
XMLCoreParser
src
XMLParserUtilities.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
#include "
XMLParserUtilities.h
"
12
13
#include <filesystem>
14
15
namespace
fs
= std::filesystem;
16
17
namespace
XmlParser
{
18
std::string
19
xmlFileName
(
const
std::string & fname,
const
std::string & prefix){
20
if
(fs::exists(fname) )
return
fname;
21
std::string fileWithPrefix = prefix +
"/"
+ fname;
22
if
(fs::exists(fileWithPrefix) )
return
fileWithPrefix;
23
//
24
const
char
* xmlpathenv = std::getenv (
"XMLPATH"
);
25
if
(xmlpathenv ==
nullptr
)
return
""
;
26
std::string xmlpath = xmlpathenv;
27
std::string::size_type pos = 0;
28
std::string temp_name;
29
while
(pos != std::string::npos){
30
std::string::size_type sep = xmlpath.find (
":"
, pos);
31
if
(sep == std::string::npos){
32
temp_name = xmlpath.substr (pos);
33
pos = std::string::npos;
34
}
else
{
35
temp_name = xmlpath.substr (pos, sep - pos);
36
pos = sep + 1;
37
}
38
if
(temp_name.empty())
continue
;
39
std::string last_temp_name = temp_name;
40
temp_name +=
"/"
;
41
temp_name += fname;
42
if
(fs::exists (temp_name))
return
temp_name;
43
// Test whether prefix is a relative path and if so use it
44
if
(prefix !=
""
&&
'/'
!= prefix[0]) {
45
temp_name = std::move(last_temp_name);
46
temp_name +=
"/"
;
47
temp_name += prefix;
48
temp_name +=
"/"
;
49
temp_name += fname;
50
if
(fs::exists (temp_name))
return
temp_name;
51
}
52
}
53
return
""
;
54
}
55
56
57
}
fs
static Double_t fs
Definition
LArPhysWaveHECTool.cxx:37
XMLParserUtilities.h
Various text/ptr utilities to use in the ExpatCoreParser.
XmlParser
Definition
XMLParserUtilities.cxx:17
XmlParser::xmlFileName
std::string xmlFileName(const std::string &fname, const std::string &prefix)
find the xml file locally or on the datapath, return the full filename
Definition
XMLParserUtilities.cxx:19
Generated on
for ATLAS Offline Software by
1.17.0