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

xmli::ushortBuilder Class Reference

Build a vector of shorts from XML data. More...

#include <ushortBuilder.h>

Inheritance diagram for xmli::ushortBuilder:

xmli::Builder List of all members.

Public Member Functions

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

Detailed Description

Build a vector of shorts from XML data.

Definition at line 14 of file ushortBuilder.h.


Constructor & Destructor Documentation

xmli::ushortBuilder::ushortBuilder const char *  tag  ) 
 

Definition at line 20 of file ushortBuilder.cxx.

00020 : xmli::Builder(tag) { }


Member Function Documentation

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

Definition at line 24 of file ushortBuilder.cxx.

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

00026 {
00027 //======================================================================
00028 // Build a vector<int> and place it on the XMLIStack
00029 //   attr - list of attributes (none used...)
00030 //   buffer - space separated integers
00031 //======================================================================
00032   int                         i;
00033   int                         s;
00034   std::vector<std::string>    vs;
00035   std::vector<unsigned short> vsh;
00036 
00037   // Split the string in to sub fields and extra the values from each
00038   // sub-field
00039   xmli::ChString::Split(buffer.c_str()," ,\n\t\r",vs);
00040   std::vector<std::string>::iterator itr(vs.begin());  
00041   std::vector<std::string>::iterator itrEnd(vs.end());
00042   for (; itr!=itrEnd; ++itr) {
00043     const char* c1 = itr->c_str();
00044     char*       c2 = 0;
00045     i = strtol(c1,&c2,0);
00046     s = (unsigned short)i;
00047     vsh.push_back(s);
00048   }
00049   
00050   // Add this vector of unsigned short values into the "global" stack
00051   xmli::Stack<std::vector<unsigned short> >::Instance().push(vsh);
00052 }


The documentation for this class was generated from the following files:
Generated on Thu Jul 24 12:01:21 2008 for NOvA Offline by doxygen 1.3.5