9# pragma GCC diagnostic ignored "-Wstringop-overread"
15#include "GaudiKernel/MsgStream.h"
40 if (start < other.fields ()) {
41 field_vector::const_iterator it = other.m_fields.begin ();
48 if (text.empty())
return;
49 std::istringstream in(text);
61 if (text.empty())
return;
62 std::istringstream in(text);
70 for (
size_type i = 0; i < root.fields (); ++i){
101 for (
size_t i = 0; i < subrange.
fields (); ++i) {
102 const field& f = subrange[i];
111 size_t sz = subrange.m_fields.size();
113 for (
size_t i = 0; i <
sz; ++i) {
114 m_fields.emplace_back (std::move(subrange.m_fields[i]));
131 const size_type id_fields =
id.fields ();
138 size_type nfields = (my_fields > id_fields) ? id_fields : my_fields;
140 for (
size_type field_number = 0; field_number < nfields; field_number++) {
142 if (!f.match (
id[field_number]))
return (0);
155 for (
size_type field_number = 0; field_number < my_fields; field_number++) {
158 result << f.get_minimum ();
168 for (
size_type field_number = 0; field_number < my_fields; field_number++) {
171 result << f.get_maximum ();
178 const Range& me = *
this;
180 const field& f = me[i];
181 result *= f.get_indices ();
193 const Range& me = *
this;
198 std::vector<size_type> indices(
id.
fields (), 0);
199 bool is_match =
true;
201 for (; level <
id.fields (); ++level) {
202 const field& f = me[level];
204 if (f.empty())
return 0;
205 if (f.isEnumerated()) {
208 if (f.get_values()[
max] <
id[level]) {
211 indices[level] =
max + 1;
213 for (
size_type j = 0; j < f.get_values().size(); ++j) {
214 if (
id[level] <= f.get_values()[j]) {
215 if (
id[level] != f.get_values()[j]) {
225 if (f.get_maximum() <
id[level]) {
228 indices[level] = f.get_maximum() - f.get_minimum() + 1;
229 }
else if (
id[level] < f.get_minimum()) {
234 indices[level] =
id[level] - f.get_minimum();
237 if (!is_match)
break;
241 if (level <
id.
fields ()) ++level;
244 for (
size_type k = j + 1; k <
id.fields(); ++k) {
245 const field& f = me[k];
246 card *= f.get_indices();
261 const Range& me = *
this;
262 if ((
fields () == 0) || (other.fields () == 0))
return (
false);
264 const field& f1 = me[i];
265 const field& f2 = other[i];
266 if (!f1.overlaps_with (f2))
return (
false);
275 const Range& me = *
this;
276 s << (std::string) me <<
" (";
279 const field& f = me[i];
294 s <<
"=" << allbits <<
") ";
299 std::ostringstream os;
305Range::operator std::string ()
const {
308 if (my_fields == 0)
return (result);
310 for (
size_type field_number = 0; field_number < my_fields; field_number++) {
312 if (field_number > 0) result +=
"/";
313 result += (std::string) f;
321 if (
m_fields.size() != other.m_fields.size())
return false;
322 field_vector::const_iterator it1 =
m_fields.begin();
323 field_vector::const_iterator it2 = other.m_fields.begin();
324 field_vector::const_iterator last =
m_fields.end();
325 for (; it1 != last; ++it1, ++it2) {
326 if ((*it1) != (*it2))
return false;
345 for (
int c{}; c!=EOF;c=in.peek()){
349 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.
void show(std::ostream &s) const
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 clear()
Modifications.