9# pragma GCC diagnostic ignored "-Wstringop-overread"
15#include "GaudiKernel/MsgStream.h"
39 if (start < other.fields ()) {
40 field_vector::const_iterator it = other.m_fields.begin ();
47 if (text.empty())
return;
48 std::istringstream in(text);
60 if (text.empty())
return;
61 std::istringstream in(text);
69 for (
size_type i = 0; i < root.fields (); ++i){
100 for (
size_t i = 0; i < subrange.
fields (); ++i) {
101 const field& f = subrange[i];
110 size_t sz = subrange.m_fields.size();
112 for (
size_t i = 0; i <
sz; ++i) {
113 m_fields.emplace_back (std::move(subrange.m_fields[i]));
130 const size_type id_fields =
id.fields ();
137 size_type nfields = (my_fields > id_fields) ? id_fields : my_fields;
139 for (
size_type field_number = 0; field_number < nfields; field_number++) {
141 if (!f.match (
id[field_number]))
return (0);
154 for (
size_type field_number = 0; field_number < my_fields; field_number++) {
157 result << f.get_minimum ();
167 for (
size_type field_number = 0; field_number < my_fields; field_number++) {
170 result << f.get_maximum ();
177 const Range& me = *
this;
179 const field& f = me[i];
180 result *= f.get_indices ();
192 const Range& me = *
this;
197 std::vector<size_type> indices(
id.
fields (), 0);
198 bool is_match =
true;
200 for (; level <
id.fields (); ++level) {
201 const field& f = me[level];
203 if (f.empty())
return 0;
204 if (f.isEnumerated()) {
207 if (f.get_values()[
max] <
id[level]) {
210 indices[level] =
max + 1;
212 for (
size_type j = 0; j < f.get_values().size(); ++j) {
213 if (
id[level] <= f.get_values()[j]) {
214 if (
id[level] != f.get_values()[j]) {
224 if (f.get_maximum() <
id[level]) {
227 indices[level] = f.get_maximum() - f.get_minimum() + 1;
228 }
else if (
id[level] < f.get_minimum()) {
233 indices[level] =
id[level] - f.get_minimum();
236 if (!is_match)
break;
240 if (level <
id.
fields ()) ++level;
243 for (
size_type k = j + 1; k <
id.fields(); ++k) {
244 const field& f = me[k];
245 card *= f.get_indices();
260 const Range& me = *
this;
261 if ((
fields () == 0) || (other.fields () == 0))
return (
false);
263 const field& f1 = me[i];
264 const field& f2 = other[i];
265 if (!f1.overlaps_with (f2))
return (
false);
274 const Range& me = *
this;
275 s << (std::string) me <<
" (";
278 const field& f = me[i];
293 s <<
"=" << allbits <<
") ";
298 std::ostringstream os;
304Range::operator std::string ()
const {
307 if (my_fields == 0)
return (
result);
309 for (
size_type field_number = 0; field_number < my_fields; field_number++) {
311 if (field_number > 0)
result +=
"/";
312 result += (std::string) f;
320 if (
m_fields.size() != other.m_fields.size())
return false;
321 field_vector::const_iterator it1 =
m_fields.begin();
322 field_vector::const_iterator it2 = other.m_fields.begin();
323 field_vector::const_iterator last =
m_fields.end();
324 for (; it1 != last; ++it1, ++it2) {
325 if ((*it1) != (*it2))
return false;
344 for (
int c{}; c!=EOF;c=in.peek()){
348 if (
int c = in.peek();(c ==
'/') or (c ==
' ')){
std::ostream & operator<<(std::ostream &out, const Range &r)
std::istream & operator>>(std::istream &in, Range &r)
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
ExpandedIdentifier maximum() const
int match(const ExpandedIdentifier &id) const
Match an identifier.
ExpandedIdentifier minimum() const
min and max ExpandedIdentifiers (if they exist, ie.
bool operator==(const Range &other) const
void add(element_type value)
Add a required value. (ie. low = high = value)
ExpandedIdentifier::element_type element_type
size_type cardinalityUpTo(const ExpandedIdentifier &id) const
Get the cardinality from the beginning up to the given ExpandedIdentifier.
ExpandedIdentifier::size_type size_type
void build(const std::string &text)
Build Range from a textual description.
const field & operator[](size_type index) const
Access the field elements.
bool overlaps_with(const Range &other) const
Check if two Ranges overlap.
size_type cardinality() const
Computes a possible cardinality :
void show(std::ostream &s=std::cout) const
void clear()
Modifications.