ATLAS Offline Software
Loading...
Searching...
No Matches
ExpandedIdentifier.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------
6inline ExpandedIdentifier::ExpandedIdentifier(const ExpandedIdentifier& other,
7 size_type start){
8 if (start < other.fields()) {
9 element_vector::const_iterator it = other.m_fields.begin();
10 it += start;
11 m_fields.insert(m_fields.end(), it, other.m_fields.end());
12 }
13}
14
15// Modifications
16inline void
17ExpandedIdentifier::add(element_type value){
18 // Max size of id levels should be < 12
19 m_fields.push_back(value);
20}
21
22inline ExpandedIdentifier&
23ExpandedIdentifier::operator<<(element_type value){
24 // Max size of id levels should be < 12
25 m_fields.push_back(value);
26 return (*this);
27}
28
29inline ExpandedIdentifier::element_type& ExpandedIdentifier::operator[](
30 size_type index){
31 // Raises an exception if index is out-of-bounds.
32 return m_fields.at(index);
33}
34
35inline void
36ExpandedIdentifier::clear(){
37 m_fields.clear();
38}
39
40inline ExpandedIdentifier::element_type ExpandedIdentifier::operator[](
41 size_type index) const{
42 // Raises an exception if index is out-of-bounds.
43 return m_fields.at(index);
44}
45
46inline ExpandedIdentifier::size_type
47ExpandedIdentifier::fields() const{
48 return (m_fields.size());
49}
50
51// Comparison operators
52inline bool
53ExpandedIdentifier::operator==(const ExpandedIdentifier& other) const{
54 if (fields() != other.fields()) return false;
55 return (m_fields == other.m_fields);
56}
57
58inline auto ExpandedIdentifier::operator <=>( const ExpandedIdentifier& other) const{
59 return std::lexicographical_compare_three_way(m_fields.begin(), m_fields.end(),
60 other.m_fields.begin(), other.m_fields.end());
61}
62inline bool ExpandedIdentifier::isValid() const {
63 return m_fields.size();
64}
65
66
67inline bool
68ExpandedIdentifier::match(const ExpandedIdentifier& other) const{
69 const auto &[vsmall, vbig] = std::minmax(m_fields, other.m_fields,
70 [](const auto & a1, const auto& a2){return a1.size()<a2.size();});
71 return std::equal(vsmall.begin(), vsmall.end(), vbig.begin());
72}
73