Siena Fast Forwarding Documentation (v. 2.0.1)
message_iteration.cc

This example shows how to iterate through a message. The same iteration model used in this example can be also be applied to Filter and Predicate objects.

#include <iostream>
using namespace std;
using namespace siena;
void print_message(const Message & m) {
String s;
if (i != NULL) {
do {
cout << "attribute: " << i->name().to_string() << endl;
switch (i->type()) {
case STRING: cout << "string = " << i->string_value().to_string(s); break;
case INT: cout << "int = " << i->int_value(); break;
case BOOL: cout << "bool = " << i->bool_value(); break;
case DOUBLE: cout << "double = " << i->double_value(); break;
case ANYTYPE:
cout << "(generic value)" << endl;
cout << "Generic values are used in Constraints, not Messages." << endl;
break;
}
cout << endl;
} while (i->next());
delete(i);
} else {
cout << "empty message!" << endl;
}
}