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>
#include <iostream>

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 490 of file IdentifierField.cxx.

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

◆ operator>>()

std::istream & operator>> ( std::istream & is,
IdentifierField & idf )

Definition at line 498 of file IdentifierField.cxx.

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