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 <iostream>
10#include <format>
11
12
13void Identifier::set (const std::string& id){
14 const auto start = id.data();
15 const auto end = start + id.size();
16 static constexpr int base = 16;
17 //add 2 to start to get past the Ox prefix.
18 const auto [p,ec] = std::from_chars(start+2, end, m_id, base);
19 if (ec != std::errc()){
20 throw std::runtime_error("Number was not parsed in Identifier::set");
21 }
22}
23
24
25std::string
27 return std::format("0x{:0x}", m_id);
28}
29
30void
31Identifier::show (std::ostream & out) const{
32 out << getString();
33}
34
35void
36Identifier::show (MsgStream & out) const{
37 out << getString();
38}
39
40MsgStream&
41operator<<(MsgStream& f, const Identifier& id){
42 f << id.getString();
43 return f;
44}
45
46std::ostream&
47operator<<(std::ostream& os, const Identifier& id){
48 os << id.getString();
49 return os;
50}
51
52
53
MsgStream & operator<<(MsgStream &f, const Identifier &id)
std::string getString() const
Provide a string form of the identifier - hexadecimal.
void show(std::ostream &out) 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