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> #include <siena/types.h> using namespace std; using namespace siena; class smart_message: public message { // this class implements the message interface // ... } int main(int argc, char * argv[]) { smart_message m; // ... // here we do something with m // // and here we print out the message // message::iterator * i = m.first(); if (i != NULL) { do { cout << "attribute: " << i->name(); switch (i->type()) { case string_id: cout << "string = " << i->string_value(); break; case int_id: cout << "int = " << i->int_value(); break; case bool_id: cout << "bool = " << i->bool_value(); break; case double_id: cout << "double = " << i->double_value(); break; } cout << endl; } while (i->next()); delete(i); } else { cout << "empty message!" << endl; } }