Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

IdOpCompress.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/xmlUtil/src/id/IdOpCompress.cxx,v 1.2 2001/09/25 21:43:04 jrb Exp $
00002 
00003 #include "xmlUtil/id/IdOpCompress.h"
00004 #include "xml/Dom.h"
00005 
00006 namespace xmlUtil {
00007   IdOpCompress::IdOpCompress(DOM_Element cmprss) {
00008     from = xml::Dom::getAttribute(cmprss, "from");
00009     to = xml::Dom::getAttribute(cmprss, "to");
00010   }
00011 
00012   NamedId *IdOpCompress::convert(const NamedId& inputId) {
00013 
00014     int fromIx = inputId.hasField(from);
00015     int toIx = inputId.hasField(to);
00016 
00017     // For now if input id doesn't have "from" and "to" fields
00018     // in the proper order, return null pointer.  Another
00019     // possible response in this case would be to return a copy
00020     // of the input id.
00021 
00022     if (toIx < fromIx) return 0;
00023     if (fromIx < 0) return 0;
00024 
00025     NamedId *newId = new NamedId(inputId, fromIx + 1);
00026 
00027     NamedId::Fields *newFields = newId->m_fields;
00028     NamedId::Fields *inFields = inputId.m_fields;
00029 
00030     for (unsigned int ix = toIx; ix < inFields->size(); ix++ ) {
00031       NamedId::IdField * aField = new NamedId::IdField( *((*inFields)[ix]) );
00032       newFields->push_back(aField);
00033     }
00034     return newId;
00035   }
00036 }

Generated on Wed Oct 16 14:02:48 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001