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

boolBuilder.cxx

Go to the documentation of this file.
00001 
00002 // $Id: boolBuilder.cxx,v 1.1 2007/02/09 04:44:14 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #include "XMLInterface/boolBuilder.h"
00009 #include "XMLInterface/Stack.h"
00010 #include "XMLInterface/ChString.h"
00011 #include <vector>
00012 #include <iostream>
00013 
00014 // Create and instance to be used by the XML parser
00015 static xmli::boolBuilder gsBuilder("bool");
00016 
00017 //......................................................................
00018 
00019 xmli::boolBuilder::boolBuilder(const char* tag) : xmli::Builder(tag) { }
00020 
00021 //......................................................................
00022 
00023 void xmli::boolBuilder::Build(const xmli::AttributeList& /*attr*/, 
00024                               const std::string& buffer) 
00025 {
00026 //======================================================================
00027 // Construct a vector<bool> from XML data
00028 //  attr - unused...
00029 //  buffer - space-separated tokens representing bool values
00030 //======================================================================
00031   bool                     b;
00032   std::vector<std::string> vs;
00033   std::vector<bool>        vb;
00034 
00035   // Split the string in to sub fields and extra the values from each
00036   // sub-field
00037   xmli::ChString::Split(buffer.c_str()," ,\n\t\r",vs);
00038   std::vector<std::string>::iterator itr(vs.begin());  
00039   std::vector<std::string>::iterator itrEnd(vs.end());
00040   for (; itr!=itrEnd; ++itr) {
00041     if      (xmli::ChString::IsTrue(*itr))  b = 1;
00042     else if (xmli::ChString::IsFalse(*itr)) b = 0;
00043     else abort();
00044     vb.push_back(b);
00045   }
00046   
00047   // Add this vector of boolean values into the "global" stack
00048   xmli::Stack<std::vector<bool> >::Instance().push(vb);
00049 }
00050 

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