11 : _mask(0), _offset( fieldOffset ), _width(
abs( signedWidth ) ), _minVal(0), _maxVal(0), _isSigned( signedWidth < 0 ), _name( fieldName )
17 s <<
" BitFieldValue '" <<
_name <<
"': out of range - offset : " 20 throw( std::runtime_error( s.str() ) ) ;
44 if( ( val & ( 1LL << (
_width - 1 ) ) ) != 0 )
62 if( in < _minVal || in >
_maxVal ) {
65 s <<
" BitFieldValue '" <<
_name <<
"': out of range : " << in
66 <<
" for width " <<
_width ;
68 throw( std::runtime_error( s.str() ) );
82 if( it != _map.end() )
87 throw std::runtime_error(
" BitFieldValue: unknown name: " + name ) ;
95 for(
unsigned i=0;i<_fields.size();i++){
97 if( hb < ( _fields[i].
offset() + _fields[i].
width() ) )
98 hb = _fields[i].
offset() + _fields[i].width() ;
106 std::stringstream os ;
108 for(
unsigned i=0;i<_fields.size();i++){
110 if( i != 0 ) os <<
"," ;
112 os << _fields[i].name() <<
":" << _fields[i].value(bitfield) ;
121 std::stringstream os ;
123 for(
unsigned i=0;i<_fields.size();i++){
125 if( i != 0 ) os <<
"," ;
127 os << _fields[i].name() <<
":" 128 << _fields[i].offset() <<
":" ;
133 os << _fields[i].width() ;
148 _map[
name ] = _fields.size()-1 ;
150 if( _joined & bfv.
mask() ) {
152 std::stringstream
s ;
153 s <<
" BitFieldValue::addField(" << name <<
"): bits already used " <<
std::hex << _joined
154 <<
" for mask " << bfv.
mask() ;
156 throw( std::runtime_error( s.str() ) ) ;
160 _joined |= bfv.
mask() ;
170 std::vector<std::string> fieldDescriptors ;
173 std::for_each( initString.begin(), initString.end(),
t ) ;
175 for(
unsigned i=0; i< fieldDescriptors.size() ; i++ ){
177 std::vector<std::string> subfields ;
180 std::for_each( fieldDescriptors[i].
begin(), fieldDescriptors[i].
end(), ts );
184 unsigned thisOffset ;
186 switch( subfields.size() ){
190 name = subfields[0] ;
191 width = atol( subfields[1].c_str() ) ;
194 offset +=
abs( width ) ;
199 name = subfields[0] ;
200 thisOffset = atol( subfields[1].c_str() ) ;
201 width = atol( subfields[2].c_str() ) ;
203 offset = thisOffset +
abs( width ) ;
209 std::stringstream
s ;
210 s <<
" BitFieldCoder: invalid number of subfields " 211 << fieldDescriptors[i] ;
213 throw( std::runtime_error( s.str() ) ) ;
216 addField( name , thisOffset, width ) ;
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
BitFieldValue()=default
Default constructor.
Helper class for BitFieldCoder that corresponds to one field value.
std::string fieldDescription() const
QTextStream & hex(QTextStream &s)
unsigned highestBit() const
void set(long64 &bitfield, long64 value) const
void init(const std::string &initString)
void addField(const std::string &name, unsigned offset, int width)
long64 value(long64 bitfield) const
calculate this field's value given an external 64 bit bitmap
std::string valueString(ulong64 bitfield) const
General GArSoft Utilities.
size_t index(const std::string &name) const
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
const std::string & name() const
LArSoft geometry interface.
unsigned long long ulong64