Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

xmlfileBuilder.cxx

Go to the documentation of this file.
00001 
00002 // $Id: xmlfileBuilder.cxx,v 1.1 2007/02/09 04:44:14 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #include "XMLInterface/xmlfileBuilder.h"
00009 extern "C" {
00010 #include <unistd.h>
00011 }
00012 #include <vector>
00013 #include <iostream>
00014 #include "XMLInterface/xmli.h"
00015 #include "XMLInterface/Stack.h"
00016 #include "XMLInterface/ChString.h"
00017 
00018 // Create and instance to be used by the XML parser
00019 static xmli::xmlfileBuilder gsBuilder("xmlfile");
00020 
00021 //......................................................................
00022 
00023 xmli::xmlfileBuilder::xmlfileBuilder(const char* tag) : xmli::Builder(tag) { }
00024 
00025 //......................................................................
00026 
00027 void xmli::xmlfileBuilder::Build(const xmli::AttributeList& /*attr*/, 
00028                                  const std::string& buffer) 
00029 {
00030 //======================================================================
00031 // Handle the xmlfile tag.
00032 //
00033 // At the end of the tag, parse each of the files listed in "buffer"
00034 //======================================================================
00035   
00036   // Split the string in to sub fields and extra the values from each
00037   // sub-field
00038   std::vector<std::string> files;
00039   xmli::ChString::Split(buffer.c_str()," ,\n\t\r",files);
00040 
00041   // Parse each file
00042   std::vector<std::string>::iterator itr(files.begin());  
00043   std::vector<std::string>::iterator itrEnd(files.end());
00044   for (; itr!=itrEnd; ++itr) { 
00045     int nread = xmli::ReadFile(itr->c_str()); 
00046     if (nread<1) {
00047       std::cerr << 
00048         "xmli::xmlfileBuilder: File '" << itr->c_str() << 
00049         "' does not exist." << std::endl;
00050       exit(1);
00051     }
00052   }
00053 }
00054 

Generated on Thu Sep 4 02:05:29 2008 for NOvA Offline by doxygen 1.3.5