00001 00002 // $Id: uintBuilder.cxx,v 1.1 2007/02/09 04:44:14 fmwk Exp $ 00003 // 00005 // 00006 // messier@indiana.edu 00008 #include "XMLInterface/uintBuilder.h" 00009 #include "XMLInterface/Stack.h" 00010 #include "XMLInterface/ChString.h" 00011 #include <cstdlib> 00012 #include <cstring> 00013 #include <vector> 00014 00015 // Create and instance to be used by the XML parser 00016 static xmli::uintBuilder gsBuilder("uint"); 00017 00018 //...................................................................... 00019 00020 xmli::uintBuilder::uintBuilder(const char* tag) : xmli::Builder(tag) { } 00021 00022 //...................................................................... 00023 00024 void xmli::uintBuilder::Build(const xmli::AttributeList& /*attr*/, 00025 const std::string& buffer) 00026 { 00027 //====================================================================== 00028 // Build a vector<unsigned int> and place it on the XMLIStack 00029 // attr - list of attributes (none used...) 00030 // buffer - space separated unsigned integers 00031 //====================================================================== 00032 unsigned int i; 00033 std::vector<std::string> vs; 00034 std::vector<unsigned int> vi; 00035 00036 // Split the string in to sub fields and extra the values from each 00037 // sub-field 00038 xmli::ChString::Split(buffer.c_str()," ,\n\t\r",vs); 00039 std::vector<std::string>::iterator itr(vs.begin()); 00040 std::vector<std::string>::iterator itrEnd(vs.end()); 00041 for (; itr!=itrEnd; ++itr) { 00042 const char* c1 = itr->c_str(); 00043 char* c2 = 0; 00044 i = strtoul(c1,&c2,0); 00045 vi.push_back(i); 00046 } 00047 00048 // Add this vector of unsigned int's into the "global" stack 00049 xmli::Stack<std::vector<unsigned int> >::Instance().push(vi); 00050 } 00051
1.3.9.1