14 #include "msdevstudio/MSconfig.h"
33 using std::istringstream;
35 using std::istream_iterator;
40 using namespace hippodraw;
43 :
BaseXML (
"NTuple", controller ),
45 m_col_name (
"column" ),
46 m_data (
"NTupleData" ),
67 const void * addr = reinterpret_cast <
const void * > ( & ntuple );
71 const string & full_name = ntuple.
getName ();
72 tag -> setAttribute (
m_name, full_name );
75 namespace dp = hippodraw::DataPoint2DTuple;
81 unsigned int columns = ntuple.
columns ();
90 static unsigned int cols []
93 for (
unsigned int i = 0; i <
dp::SIZE; i++ ) {
97 const string & label = ntuple.
getLabelAt ( cols[i] );
98 element -> setAttribute (
m_label, label );
100 const vector < double > &
data = ntuple.
getColumn ( cols[i] );
104 for (
unsigned int j = 0; j <
size; j++ ) {
111 element -> appendChild ( *node );
114 tag -> appendChild ( *element );
127 tag -> appendChild ( *node );
137 #ifndef STRING_CLEAR_DEFECT // change to ifdef when M4 macro is implemented
138 if ( ! ok ) name.erase ( name.begin(), name.end() );
140 if ( ! ok ) name.clear();
148 list < XmlElement * > nodelist;
150 unsigned int size = nodelist.size ();
153 vector < vector < double > > columns ( size );
154 vector < string > labels ( size );
156 list < XmlElement * >::const_iterator first = nodelist.begin ();
157 while ( first != nodelist.end() ) {
160 bool ok = elem -> attribute (
m_col_name, column );
163 ok = elem -> attribute (
m_label, label );
166 const string & text = elem -> getText ();
167 istringstream stream ( text );
169 copy ( istream_iterator<double> ( stream ),
170 istream_iterator<double> (), back_inserter ( columns[column] ) );
174 for (
unsigned int i = 0; i <
size; i++ ) {
175 ntuple -> addColumn ( labels[i], columns[i] );