ATLAS Offline Software
Loading...
Searching...
No Matches
ExpandedIdentifier Class Reference

#include <ExpandedIdentifier.h>

Collaboration diagram for ExpandedIdentifier:

Public Types

using id_type = ExpandedIdentifier
using element_type = int
using element_vector = boost::container::small_vector<element_type,12>
using size_type = boost::container::small_vector<element_type,12>::size_type

Public Member Functions

 ExpandedIdentifier ()=default
 ExpandedIdentifier (const ExpandedIdentifier &other, size_type start)
 Constructor from a subset of another ExpandedIdentifier.
 ExpandedIdentifier (const std::string &text)
 Constructor from a textual description.
void add (element_type value)
 Append a value into a new field.
ExpandedIdentifieroperator<< (element_type value)
element_typeoperator[] (size_type index)
void set (const std::string &text)
 build from a textual description
void clear ()
 Erase all fields.
element_type operator[] (size_type index) const
 Get the value stored into the specified field.
size_type fields () const
auto operator<=> (const ExpandedIdentifier &other) const
 Comparison operators.
bool operator== (const ExpandedIdentifier &other) const
bool match (const ExpandedIdentifier &other) const
 Test if the shorter of two ids is identical to the equivalent sub-id extracted from the longer.
 operator std::string () const
 String representation of the identifier using the input format.
bool isValid () const
 Returns whether the expanded Identifier contains any information.
void show (std::ostream &out) const
 Display detail to ostream.
void show (MsgStream &out) const
 Display detail to MsgStream.

Static Public Attributes

static constexpr element_type max_value = 0x3FFFFFFF

Private Attributes

element_vector m_fields

Detailed Description

Member Typedef Documentation

◆ element_type

◆ element_vector

using ExpandedIdentifier::element_vector = boost::container::small_vector<element_type,12>

◆ id_type

◆ size_type

using ExpandedIdentifier::size_type = boost::container::small_vector<element_type,12>::size_type

Constructor & Destructor Documentation

◆ ExpandedIdentifier() [1/3]

ExpandedIdentifier::ExpandedIdentifier ( )
default

◆ ExpandedIdentifier() [2/3]

ExpandedIdentifier::ExpandedIdentifier ( const ExpandedIdentifier & other,
size_type start )

Constructor from a subset of another ExpandedIdentifier.

◆ ExpandedIdentifier() [3/3]

ExpandedIdentifier::ExpandedIdentifier ( const std::string & text)

Constructor from a textual description.

Definition at line 27 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

27 {
28 set (text);
29}
void set(const std::string &text)
build from a textual description

Member Function Documentation

◆ add()

void ExpandedIdentifier::add ( element_type value)

Append a value into a new field.

◆ clear()

void ExpandedIdentifier::clear ( )

Erase all fields.

◆ fields()

size_type ExpandedIdentifier::fields ( ) const

◆ isValid()

bool ExpandedIdentifier::isValid ( ) const

Returns whether the expanded Identifier contains any information.

◆ match()

bool ExpandedIdentifier::match ( const ExpandedIdentifier & other) const

Test if the shorter of two ids is identical to the equivalent sub-id extracted from the longer.

◆ operator std::string()

ExpandedIdentifier::operator std::string ( ) const

String representation of the identifier using the input format.

Definition at line 56 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

56 {
57 return show_vector(m_fields);
58}
static std::string show_vector(const ExpandedIdentifier::element_vector &v, const std::string &sep="/")

◆ operator<<()

ExpandedIdentifier & ExpandedIdentifier::operator<< ( element_type value)

◆ operator<=>()

auto ExpandedIdentifier::operator<=> ( const ExpandedIdentifier & other) const

Comparison operators.

◆ operator==()

bool ExpandedIdentifier::operator== ( const ExpandedIdentifier & other) const

◆ operator[]() [1/2]

element_type & ExpandedIdentifier::operator[] ( size_type index)

◆ operator[]() [2/2]

element_type ExpandedIdentifier::operator[] ( size_type index) const

Get the value stored into the specified field.

◆ set()

void ExpandedIdentifier::set ( const std::string & text)

build from a textual description

Definition at line 33 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

33 {
34 clear ();
35 if (text.empty()) return;
36 const char *start = text.c_str();
37 const char *last = start+text.size();
38 static constexpr auto ok=std::errc{};
39 int v{};
40 bool foundNumber{};
41 for (const char * p=start;p<last;++p){
42 auto [ptr,ec] = std::from_chars(p, last,v);
43 p=ptr;
44 if (ec != ok) continue;
45 add ((element_type) v);
46 foundNumber = true;
47 }
48 if (not foundNumber){
49 const std::string msg = "ExpandedIdentifier::set: '"+ text + "' is not a valid input string.";
50 throw std::invalid_argument(msg);
51 }
52}
void add(element_type value)
Append a value into a new field.
void clear()
Erase all fields.
void * ptr(T *p)
Definition SGImplSvc.cxx:74
MsgStream & msg
Definition testRead.cxx:32

◆ show() [1/2]

void ExpandedIdentifier::show ( MsgStream & out) const

Display detail to MsgStream.

Definition at line 66 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

66 {
67 out<< "["<< show_vector (m_fields,".") <<"]";
68}

◆ show() [2/2]

void ExpandedIdentifier::show ( std::ostream & out) const

Display detail to ostream.

Definition at line 61 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

61 {
62 out<< "["<< show_vector (m_fields,".") <<"]";
63}

Member Data Documentation

◆ m_fields

element_vector ExpandedIdentifier::m_fields
private

◆ max_value

element_type ExpandedIdentifier::max_value = 0x3FFFFFFF
staticconstexpr

The documentation for this class was generated from the following files: