9 #include <vxd/dataobjects/VxdID.h>
26 int getPart(istream& in)
31 if (next ==
'.') next = in.get();
33 if (next ==
'*' or in.eof()) {
39 if (next ==
'#')
return 0;
45 if (in.fail() && !in.eof()) {
46 throw runtime_error(
"Failed to parse Number");
54 VxdID::VxdID(
const std::string& sensor)
59 istringstream in(sensor);
62 m_id.parts.layer = getPart(in);
63 m_id.parts.ladder = getPart(in);
64 m_id.parts.sensor = getPart(in);
66 if (in.peek() ==
'#') {
68 m_id.parts.segment = getPart(in);
70 }
catch (runtime_error&) {
73 throw invalid_argument(
"Could not parse VxdID: '" + sensor +
"'");
81 getline(in, rest,
'\0');
82 throw invalid_argument(
"Trailing characters after VxdID " + (
string)*
this +
": '" + rest +
"'");
86 VxdID::operator string()
const
89 if (m_id.parts.layer) {
90 out << m_id.parts.layer;
94 if (m_id.parts.ladder || m_id.parts.sensor) {
96 if (m_id.parts.ladder) {
97 out << m_id.parts.ladder;
102 if (m_id.parts.sensor) {
103 out <<
"." << m_id.parts.sensor;
105 if (m_id.parts.segment) {
106 out <<
"#" << m_id.parts.segment;
Class to uniquely identify a any structure of the PXD and SVD.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Abstract base class for different kinds of events.