D.4   Example

The following C++ example uses the event base API to print out an entire event log in text form.

Example D-1:  Event Base API Query

/* WindView 2.0 API Example Code */ 
 
/* Copyright (c) 1998 Wind River Systems, Inc. */ 
 
// 
// Sample / exmaple code for basic usage of WindView 2.0 API 
// libs. Dumps out the contents of a .WVR file given on the command 
// line. 
// 
 
#include <iostream> 
#include "wvapi.h" 
 
int main (int argc, char ** argv) 
    { 
    if (argc != 2) 
        { 
        cout << "usage:" << argv [0] << " <logfile.wvr>" << endl; 
        exit (1); 
        } 
     
    try 
        { 
        WVEventBase     eb; 
 
        if (eb.load (argv [1]) == OK) 
            { 
            WVEventBase::iterator       i; 
 
            for (i = eb.begin (); i != eb.end (); ++i) 
                { 
                WVContext               ctx; 
                WVContext::iterator     j; 
 
                ctx = *i; 
                for (j = ctx.begin (); j != ctx.end (); ++j) 
                    { 
                    cout << eb.eventAsString (*j) << endl; 
                    } 
                } 
            } 
        else 
            { 
            cout << "Could not load eventbase " << argv [1] << endl; 
            } 
        } 
    catch (const wv_error &e) 
        { 
        cout << "WVAPI Error:" << e.what () << " code=" 
             << e.errorCode () << endl; 
        exit (1); 
        } 
     
    return 0; 
    }