ATLAS Offline Software
Loading...
Searching...
No Matches
IdentifierField.cxx File Reference
#include "Identifier/IdentifierField.h"
#include "GaudiKernel/MsgStream.h"
#include "src/IdentifierFieldParser.h"
#include <algorithm>
#include <sstream>
#include <bit>
#include <array>
#include <cctype>
#include <format>
#include <tuple>
#include <functional>

Go to the source code of this file.

Functions

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

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 & is,
IdentifierField & idf )

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
void clear()
Set methods.
void add_value(element_type value)
void set(element_type minimum, element_type maximum)
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