ATLAS Offline Software
Loading...
Searching...
No Matches
Identifier.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "Identifier/Identifier.h"
7#include "GaudiKernel/MsgStream.h"
8#include <charconv>
9#include <format>
10
11
12void 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
24std::string
26 return std::format("0x{:0x}", m_id);
27}
28
29void
30Identifier::show (std::ostream & out) const{
31 out << getString();
32}
33
34void
35Identifier::show (MsgStream & out) const{
36 out << getString();
37}
38
39MsgStream&
40operator<<(MsgStream& f, const Identifier& id){
41 f << id.getString();
42 return f;
43}
44
45std::ostream&
46operator<<(std::ostream& os, const Identifier& id){
47 os << id.getString();
48 return os;
49}
50
51
52
MsgStream & operator<<(MsgStream &f, const Identifier &id)
std::string getString() const
Provide a string form of the identifier - hexadecimal.
void show(std::ostream &out=std::cout) const
Print out in hex form.
void set(const std::string &id)
build from a string form - hexadecimal
std::string base
Definition hcg.cxx:81