ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
31 const Identifier& me = *this;
32 std::cout << me.getString();
33}
34
35
std::string getString() const
Provide a string form of the identifier - hexadecimal.
void show() 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