ATLAS Offline Software
Loading...
Searching...
No Matches
IdentifierField.h File Reference
#include <Identifier/ExpandedIdentifier.h>
#include <vector>
#include <string>
#include <stdexcept>
#include <iostream>
#include <limits>
#include <utility>
#include <variant>
Include dependency graph for IdentifierField.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  IdentifierField
 This is the individual specification for the range of one ExpandedIdentifier IdentifierField. More...

Functions

std::ostream & operator<< (std::ostream &out, const IdentifierField &c)
std::istream & operator>> (std::istream &in, IdentifierField &c)

Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream & out,
const IdentifierField & c )

Definition at line 489 of file IdentifierField.cxx.

490 {
491 out<<std::string(c);
492 return out;
493}

◆ operator>>()

std::istream & operator>> ( std::istream & in,
IdentifierField & c )

Definition at line 497 of file IdentifierField.cxx.

497 {
498 idf.clear();
499 while (std::isspace(is.peek())){is.ignore();}
500 char c = is.peek();
501 if (c =='*'){
502 is.ignore();
503 //do nothing; the 'clear' set idf to unbounded
504 } else if (isDigit(c)){
505 if (c =='+') is.ignore();
506 int v = parseStreamDigits(is);//'is' ptr is incremented
507 c = is.peek();
508 //possible: bound, list
509 if (c == ','){ //found comma, so definitely list
510 is.ignore();
511 std::vector<int> vec(1,v);
512 const auto & restOfList = parseStreamList(is);
513 vec.insert(vec.end(), restOfList.begin(), restOfList.end());
514 idf.set(vec);
515 } else if (c == ':'){ //bounded
516 is.ignore();
517 c=is.peek(); //peek char after the colon
518 if (isDigit(c)){ //bounded
519 int v1 = parseStreamDigits(is);
520 idf.set(v,v1);
521 }
522 } else { //remaining alternative: single number
523 idf.add_value(v);
524 }
525 } else {
526 std::string msg{"Stream extraction for IdentifierField: "};
527 std::string remains;
528 is >> remains;
529 msg+=remains;
530 throw std::invalid_argument(msg);
531 }
532 return is;
533}
std::vector< size_t > vec
bool isDigit(const char c)
IdentifierField::element_type parseStreamDigits(std::istream &is)
IdentifierField::element_vector parseStreamList(std::istream &is)
MsgStream & msg
Definition testRead.cxx:32