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

xmli::floatBuilder Class Reference

Builder for vector<float> from XML data. More...

#include <floatBuilder.h>

Inheritance diagram for xmli::floatBuilder:

xmli::Builder List of all members.

Public Member Functions

 floatBuilder (const char *tag)
void Build (const AttributeList &attr, const std::string &buffer)

Detailed Description

Builder for vector<float> from XML data.

Definition at line 13 of file floatBuilder.h.


Constructor & Destructor Documentation

xmli::floatBuilder::floatBuilder const char *  tag  ) 
 

Definition at line 19 of file floatBuilder.cxx.

00019 : xmli::Builder(tag) { }


Member Function Documentation

void xmli::floatBuilder::Build const AttributeList attr,
const std::string &  buffer
 

Definition at line 23 of file floatBuilder.cxx.

References xmli::AttributeList, and xmli::ChString::Split().

00025 {
00026 //======================================================================
00027 // Build a vector<float> from XML data and add it to the stack
00028 //  attr - unused
00029 //  buffer - list of space-separated floating point numbers
00030 //======================================================================
00031   float                    f;
00032   std::vector<std::string> vs;
00033   std::vector<float>       vf;
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     f = atof(itr->c_str());
00042     vf.push_back(f);
00043   }
00044   
00045   // Add this vector of floatean values into the "global" stack
00046   xmli::Stack<std::vector<float> >::Instance().push(vf);
00047 }


The documentation for this class was generated from the following files:
Generated on Fri Jul 25 02:05:55 2008 for NOvA Offline by doxygen 1.3.5