The applications which want to use another format for the information presentation or to use ISInfoAny for another purpose have to parse the content of the ISInfoAny object. The ISInfoAny class provides access for the information value in a stream manner: attribute by attribute. It has a number of input operators which can be used to get the value of a single-value attribute, and a number of get methods which can be used to read an array attribute values. Each input operation (if it was successful) advances the "current position" in the stream to the value of the next attribute. There is a method which returns type of the attribute at the current stream position. "Listing 7.3" shows how to print to the standard output the value of an information object using operators and methods of the ISInfoAny class.
First this program gets the number of the information attributes using the countAttributes method of the ISInfoAny class (line 6). Then, for each attribute it finds out the attribute type (line 11) and calls the put method of the ISOut<T> template class. This method reads the value of that attribute from the ISInfoAny object, and prints this value to the standard output stream. The ISOut<T> template class is shown in "Listing 7.4".
The template class is used here to simplify the code. Alternatively one can explicitly define a number of functions to handle different attribute types.
2 July 1998 - WebMaster | Copyright © CERN 1998 |