ATLAS Offline Software
Loading...
Searching...
No Matches
DetectorDescription
Identifier
src
Identifier.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "Identifier/Identifier.h"
7
#include <charconv>
8
#include <iostream>
9
#include <format>
10
11
12
void
Identifier::set
(
const
std::string&
id
){
13
const
auto
start =
id
.data();
14
const
auto
end = start +
id
.size();
15
static
constexpr
int
base
= 16;
16
//add 2 to start to get past the Ox prefix.
17
const
auto
[p,ec] = std::from_chars(start+2, end,
m_id
,
base
);
18
if
(ec != std::errc()){
19
throw
std::runtime_error(
"Number was not parsed in Identifier::set"
);
20
}
21
}
22
23
24
std::string
25
Identifier::getString
()
const
{
26
return
std::format(
"0x{:0x}"
,
m_id
);
27
}
28
29
void
30
Identifier::show
()
const
{
31
const
Identifier
& me = *
this
;
32
std::cout << me.
getString
();
33
}
34
35
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition
Identifier.cxx:25
Identifier::m_id
value_type m_id
The only data member.
Definition
DetectorDescription/Identifier/Identifier/Identifier.h:130
Identifier::show
void show() const
Print out in hex form.
Definition
Identifier.cxx:30
Identifier::set
void set(const std::string &id)
build from a string form - hexadecimal
Definition
Identifier.cxx:12
base
std::string base
Definition
hcg.cxx:81
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.14.0