Back to index

nordugrid-arc-nox  1.1.0~rc6
Functions
query.cpp File Reference
#include <glibmm/random.h>
#include <string>
#include <iostream>
#include <fstream>
#include <list>
#include <arc/XMLNode.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 13 of file query.cpp.

{
    if(argc < 3) return -1;
    int filenum = atoi(argv[1]);
    int attrnum = atoi(argv[2]);

    for (int i = 0; i < filenum; i++) { 
           // load content of file
        char fname[200];
        snprintf(fname, sizeof(fname), "file%d.xml", i);
        
        std::string xml_str = "";
        std::string str;
           std::ifstream f(fname);
           while (f >> str) {
               xml_str.append(str);
               xml_str.append(" ");
           }
           f.close();
           Arc::XMLNode doc(xml_str);
           Arc::NS ns;
       Glib::Rand r; 
        int n = r.get_int_range(0, attrnum);
       char query[200];
        snprintf(query, sizeof(query), "//AttributeName%d", n);
        
        std::cout << "Query: " << query << std::endl;
        std::list<Arc::XMLNode> result = doc.XPathLookup(query, ns);
           std::list<Arc::XMLNode>::iterator it;
       
           for (it = result.begin(); it != result.end(); it++) {
               std::cout << fname << ":" << (*it).Name() << ":" << std::string(*it) << std::endl;
           }
    }
    return 0;
}

Here is the call graph for this function: