ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
StoreGate
src
DecorKeyHelpers.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
StoreGate/DecorKeyHelpers.h
"
13
#include "
StoreGate/exceptions.h
"
14
#include "
StoreGate/VarHandleKey.h
"
15
#include "
CxxUtils/StringUtilsTemplates.h
"
16
17
18
namespace
SG
{
19
20
27
std::string
contKeyFromKey
(
const
std::string& key)
28
{
29
std::string::size_type ipos = key.find (
'.'
);
30
if
(ipos == std::string::npos)
31
return
key;
32
return
key.substr (0, ipos);
33
}
34
35
43
std::string
decorKeyFromKey
(
const
std::string& key,
const
std::string& deflt
/*= ""*/
)
44
{
45
std::string::size_type ipos = key.find (
'.'
);
46
if
(ipos == std::string::npos)
47
return
deflt;
48
return
key.substr (ipos+1, std::string::npos);
49
}
50
51
60
std::string
makeContDecorKey
(
const
std::string& cont,
const
std::string& decor)
61
{
62
if
(cont.empty())
return
decor;
63
if
(decor.empty())
return
cont;
64
return
CxxUtils::strcat
(cont,
'.'
, decor);
65
}
66
67
78
std::string
makeContDecorKey
(
const
VarHandleKey
& contKey,
const
std::string& key)
79
{
80
if
(key.empty() || key.ends_with (
'+'
)) {
81
return
""
;
82
}
83
if
(key.find(
'.'
) != std::string::npos) {
84
throw
SG::ExcBadHandleKey
(key +
" (DecorHandleKey has been declared with a parent container. "
85
"Its value should not contain any container name.)"
);
86
}
87
88
// Note: VHK::fullKey().key() contains the store prefix, key() does not.
89
return
makeContDecorKey
( contKey.fullKey().
key
(), key);
90
}
91
92
100
void
removeContFromDecorKey
(
const
VarHandleKey
& contKey, std::string& key)
101
{
102
// Remove container name from key
103
const
std::string toerase =
CxxUtils::strcat
(contKey.fullKey().
key
(),
'.'
);
104
const
size_t
pos = key.find(toerase);
105
if
(pos != std::string::npos) {
106
key.erase(pos, toerase.size());
107
}
108
109
}
110
111
}
// namespace SG
exceptions.h
Exceptions that can be thrown from StoreGate.
DecorKeyHelpers.h
Some common helper functions used by decoration handles.
VarHandleKey.h
A property holding a SG store/key/clid from which a VarHandle is made.
StringUtilsTemplates.h
SG::ExcBadHandleKey
Exception — Bad key format for VarHandleKey.
Definition
Control/StoreGate/StoreGate/exceptions.h:62
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition
StoreGate/StoreGate/VarHandleKey.h:61
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CxxUtils::strcat
constexpr std::string strcat(Args &&... args)
Definition
StringUtilsTemplates.h:203
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::removeContFromDecorKey
void removeContFromDecorKey(const VarHandleKey &contKey, std::string &key)
Remove container name from decoration key.
Definition
DecorKeyHelpers.cxx:100
SG::makeContDecorKey
std::string makeContDecorKey(const std::string &cont, const std::string &decor)
Make a StoreGate key from container and decoration name.
Definition
DecorKeyHelpers.cxx:60
SG::contKeyFromKey
std::string contKeyFromKey(const std::string &key)
Extract the container part of key.
Definition
DecorKeyHelpers.cxx:27
SG::decorKeyFromKey
std::string decorKeyFromKey(const std::string &key, const std::string &deflt)
Extract the decoration part of key.
Definition
DecorKeyHelpers.cxx:43
Generated on
for ATLAS Offline Software by
1.17.0