The Gaudi Framework
v41r0 (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
TypeNameString.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#pragma once
12
#include <ostream>
13
#include <string>
14
#include <utility>
15
16
namespace
Gaudi
{
17
namespace
Utils
{
19
class
TypeNameString
{
20
std::string
m_type
,
m_name
;
21
bool
m_haveType
;
22
23
public
:
24
template
<
size_t
N>
25
TypeNameString
(
const
char
( &tn )[N] ) :
TypeNameString
{
std
::string_view{ tn } } {}
26
TypeNameString
( std::string_view sv ) :
TypeNameString
{
std
::
string
{ sv } } {}
27
TypeNameString
( std::string tn ) :
m_type
{
std
::move( tn ) } {
28
const
auto
slash_pos =
m_type
.find_first_of(
"/"
);
29
m_haveType
= slash_pos != std::string::npos;
30
if
(
m_haveType
) {
31
m_name
=
m_type
.substr( slash_pos + 1 );
32
m_type
.resize( slash_pos );
33
}
else
34
m_name
=
m_type
;
35
}
36
37
TypeNameString
( std::string tn, std::string_view deftyp ) :
TypeNameString
(
std
::move( tn ) ) {
38
if
( !
m_haveType
)
m_type
= deftyp;
39
}
40
41
// support passing a Gaudi::Property<std::string> without having to include Property.h
42
// require that prop.value() can be used to construct a TypeNameString...
43
template
<
class
T>
44
requires
( std::is_constructible_v<TypeNameString, decltype( std::declval<const T&>().value() )> )
45
TypeNameString
(
const
T& prop ) :
TypeNameString
( prop.value() ) {}
46
47
const
std::string&
type
()
const
{
return
m_type
; }
48
const
std::string&
name
()
const
{
return
m_name
; }
49
bool
haveType
()
const
{
return
m_haveType
; }
50
};
51
53
inline
std::ostream&
operator<<
( std::ostream& s,
const
TypeNameString
& tn ) {
54
return
s << tn.
type
() <<
'/'
<< tn.
name
();
55
}
56
}
// namespace Utils
57
}
// namespace Gaudi
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition
TypeNameString.h:19
Gaudi::Utils::TypeNameString::m_name
std::string m_name
Definition
TypeNameString.h:20
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(std::string_view sv)
Definition
TypeNameString.h:26
Gaudi::Utils::TypeNameString::m_haveType
bool m_haveType
Definition
TypeNameString.h:21
Gaudi::Utils::TypeNameString::haveType
bool haveType() const
Definition
TypeNameString.h:49
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const char(&tn)[N])
Definition
TypeNameString.h:25
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(std::string tn, std::string_view deftyp)
Definition
TypeNameString.h:37
Gaudi::Utils::TypeNameString::type
const std::string & type() const
Definition
TypeNameString.h:47
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(std::string tn)
Definition
TypeNameString.h:27
Gaudi::Utils::TypeNameString::m_type
std::string m_type
Definition
TypeNameString.h:20
Gaudi::Utils::TypeNameString::name
const std::string & name() const
Definition
TypeNameString.h:48
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const T &prop)
Definition
TypeNameString.h:45
string
STL class.
Gaudi::Utils
Definition
Property.h:693
Gaudi::Utils::operator<<
std::ostream & operator<<(std::ostream &s, const TypeNameString &tn)
Output stream operator for TypeNameString instances.
Definition
TypeNameString.h:53
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
std
STL namespace.
GaudiKernel
include
GaudiKernel
TypeNameString.h
Generated on
for The Gaudi Framework by
1.17.0