If the record contains subrecords, it is possible to use fields in those subrecords (or subsubrecords, etc.) by specifying all parts of the full field name separated by dots (as shown in the example). Array fields can also be handled in the expression.
The GlishRecord given to the matches function must in principle have the same structure as the prototype record, otherwise bad things (like an exception, or even worse a segmentation fault) can happen when evaulating the expression, because checking would take too much time. However, by using the TaQL function isdefined one can explicitly check if a field is defined and has the data type as defined in the prototype record.
void someFunc (const Block<GlishRecord>& recs) { AlwaysAssert (recs.nelements() > 0, AipsError); GlishRecordExpr expr("ant_data.ON_SOURCE", recs[0]); for (uInt i=0; i<recs.nelements(); i++) { cout << expr.matches (recs[i]) << endl; } }The following example is the same as above, but uses the isdefined function in the expression to make sure no unexpected things can happen.
void someFunc (const Block<GlishRecord>& recs) { AlwaysAssert (recs.nelements() > 0, AipsError); GlishRecordExpr expr ("isdefined(ant_data.ON_SOURCE) && ant_data.ON_SOURCE", recs[0]); for (uInt i=0; i<recs.nelements(); i++) { cout << expr.matches (recs[i]) << endl; } }
Construct it from an already created expression tree.
The proto Record should be the same as the one used to create
the expression (in the
Construct it from an expression which gets parsed.
The proto Record is used to get a description of the records
to be compared with the expression.
Copy constructor (copy semantics).
Assignment (copy semantics).
Does this record match the expression?
The record must have the same description as the proto record
used when constructing the object.
Get a scalar in the given type.
Get the shape of the of the given (array) field.
Get the data type of the given field.
GlishRecordExpr (const GlishRecordExpr&)
virtual ~GlishRecordExpr()
GlishRecordExpr& operator= (const GlishRecordExpr&)
Bool matches (const GlishRecord& record)
It is not checked if the description is the same, because it
is too time-consuming.
virtual Bool getBool (const Block<Int>& fieldNrs) const
virtual Double getDouble (const Block<Int>& fieldNrs) const
virtual DComplex getDComplex (const Block<Int>& fieldNrs) const
virtual String getString (const Block<Int>& fieldNrs) const
virtual Array<Bool> getArrayBool (const Block<Int>& fieldNrs) const
virtual Array<Double> getArrayDouble (const Block<Int>& fieldNrs) const
virtual Array<DComplex> getArrayDComplex (const Block<Int>& fieldNrs) const
virtual Array<String> getArrayString (const Block<Int>& fieldNrs) const
virtual IPosition shape (const Block<Int>& fieldNrs) const
virtual DataType dataType (const Block<Int>& fieldNrs) const
GlishArray getValue (const Block<Int>& fieldNrs) const
Get the value of the given field in the subject GlishRecord.