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 () const
 Send to std::cout.

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 26 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

26 {
27 set (text);
28}
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 55 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

55 {
56 return show_vector(m_fields);
57}
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 32 of file DetectorDescription/Identifier/src/ExpandedIdentifier.cxx.

32 {
33 clear ();
34 if (text.empty()) return;
35 const char *start = text.c_str();
36 const char *last = start+text.size();
37 static constexpr auto ok=std::errc{};
38 int v{};
39 bool foundNumber{};
40 for (const char * p=start;p<last;++p){
41 auto [ptr,ec] = std::from_chars(p, last,v);
42 p=ptr;
43 if (ec != ok) continue;
44 add ((element_type) v);
45 foundNumber = true;
46 }
47 if (not foundNumber){
48 const std::string msg = "ExpandedIdentifier::set: '"+ text + "' is not a valid input string.";
49 throw std::invalid_argument(msg);
50 }
51}
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()

void ExpandedIdentifier::show ( ) const

Send to std::cout.

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

60 {
61 std::cout<< "["<< show_vector (m_fields,".") <<"]";
62}

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: