src/rcrt/loaders/XMLLoader.cpp

Go to the documentation of this file.
00001 #include "XMLLoader.h"
00002 #include "conversion.hpp"
00003 
00004 
00005 using namespace std;
00006 using namespace boost::iostreams;
00007 
00008 namespace rcrt
00009 {
00010 
00011 XMLLoader::XMLLoader(string path):file(path),in(),parser(in),currentFrame(-1),eof(false)
00012 {
00013         string::size_type loc = path.find(".bz2", path.length()-4);
00014         if(loc != string::npos) {
00015                 //cout << "[XMLLoader] loading bz2 file:" << path << endl;
00016                 isCompressed = true;
00017                 in.push(bzip2_decompressor());
00018         } else {
00019                 loc = path.find(".xml", path.length()-4);
00020                 if(loc == string::npos)
00021                         throw runtime_error("[XMLLoader] could not load file: "+
00022                                         path+" does not end in .xml or .bz2.");
00023                 isCompressed = false;
00024         }
00025         in.push(file);
00026 }
00027 
00028 XMLLoader::~XMLLoader()
00029 {
00030 }
00031 
00032 bool XMLLoader::nextStartTag(string tagName)
00033 {
00034         parser.next();
00035         int eventType = parser.getEventType();
00036         
00037         if(tagName.empty()){
00038                 
00039                 while(eventType != XmlPullParser::START_TAG
00040                                 && eventType != XmlPullParser::END_DOCUMENT){
00041                         parser.next();
00042                         eventType = parser.getEventType();
00043                 }
00044         } else {
00045                 while((eventType != XmlPullParser::START_TAG
00046                                 || parser.getName() != tagName)
00047                                 && eventType != XmlPullParser::END_DOCUMENT){
00048                         parser.next();
00049                         eventType = parser.getEventType();
00050                 }
00051         }
00052         if(eventType == XmlPullParser::END_DOCUMENT){
00053                 return false;
00054         }
00055         return true;
00056 }
00057 
00058 const int& XMLLoader::getFrame()
00059 {
00060         return currentFrame;
00061 }
00062 
00063 }

Generated on Thu Jan 31 19:26:19 2008 for RenderingCompetitionRayTracer by  doxygen 1.5.3