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

xmlUtil::NamedId Class Reference

#include <NamedId.h>

List of all members.

Public Methods

 NamedId (const int len=0)
 When length is known, best to allocate all at once at start. More...

 NamedId (const NamedId &toCopy)
 Copy constructor (should also have assignment operator). More...

 NamedId (const NamedId &toCopy, unsigned int n)
 Just copy first n fields to a new NamedId. More...

 ~NamedId ()
void addField (std::string name, unsigned value)
 Build a NamedId incrementally. More...

void addField (const IdField &newField)
unsigned int size () const
void popField (unsigned int n=1)
 Delete field on the end. More...

bool hasSubpath (const NameSeq &subpath) const
 Return true if initial field names are compatible with subpath. More...

int hasField (std::string name) const
 Return index of first occurrence of specified field, or -1 if no occurrences. More...

IdentifierstripNames ()

Protected Types

typedef std::vector< IdField * > Fields
typedef Fields::iterator FieldIt

Protected Attributes

Fieldsm_fields

Friends

class DictNode
class IdOperation
class IdOpCompress
std::ostream & operator<< (std::ostream &s, const NamedId &nId)
 Output to an ostream. More...


Member Typedef Documentation

typedef Fields::iterator xmlUtil::NamedId::FieldIt [protected]
 

Definition at line 86 of file NamedId.h.

typedef std::vector<IdField* > xmlUtil::NamedId::Fields [protected]
 

Definition at line 85 of file NamedId.h.

Referenced by NamedId().


Constructor & Destructor Documentation

xmlUtil::NamedId::NamedId const int    len = 0
 

When length is known, best to allocate all at once at start.

Definition at line 10 of file NamedId.cxx.

References Fields, and m_fields.

00010                                 {
00011     /* For now -- until I understand how to change
00012        addField to make use of pre-allocation, always
00013        allocate 0-length vector.
00014     */
00015     m_fields = new Fields(0);
00016   }

xmlUtil::NamedId::NamedId const NamedId &    toCopy
 

Copy constructor (should also have assignment operator).

Definition at line 22 of file NamedId.cxx.

References Fields, and m_fields.

00022                                         {
00023     m_fields = new Fields(*(toCopy.m_fields));
00024   }

xmlUtil::NamedId::NamedId const NamedId &    toCopy,
unsigned int    n
 

Just copy first n fields to a new NamedId.

Definition at line 27 of file NamedId.cxx.

References Fields, and m_fields.

00027                                                         {
00028     unsigned int ix;
00029     m_fields = new Fields(0);
00030 
00031     for (ix = 0; ix < n; ix++) {
00032       //      (*m_fields)[ix] = new IdField(*(*(toCopy.m_fields))[ix]);
00033       m_fields->push_back(new IdField(*(*(toCopy.m_fields))[ix]));
00034     }
00035 
00036   }

xmlUtil::NamedId::~NamedId  
 

Definition at line 18 of file NamedId.cxx.

References m_fields.

00018                     {
00019     delete m_fields;
00020   }


Member Function Documentation

void xmlUtil::NamedId::addField const IdField   newField
 

Definition at line 45 of file NamedId.cxx.

References m_fields.

00045                                                 {
00046     IdField* field = new IdField(newField);
00047     m_fields->push_back(field);
00048   }

void xmlUtil::NamedId::addField std::string    name,
unsigned    value
 

Build a NamedId incrementally.

Definition at line 38 of file NamedId.cxx.

References m_fields.

Referenced by testConverter().

00038                                                        {
00039     IdField* field = new IdField;
00040     field->name = name;
00041     field->value = value;
00042     m_fields->push_back(field);
00043   }

int xmlUtil::NamedId::hasField std::string    fname const
 

Return index of first occurrence of specified field, or -1 if no occurrences.

Definition at line 71 of file NamedId.cxx.

References m_fields.

00071                                              {
00072     for (unsigned int ix = 0; ix < m_fields->size(); ix++) {
00073       if (!(fname.compare(((*m_fields)[ix])->name) ) ) return ix;
00074     }
00075     return -1;
00076   }

bool xmlUtil::NamedId::hasSubpath const NameSeq   subpath const
 

Return true if initial field names are compatible with subpath.

Definition at line 57 of file NamedId.cxx.

References m_fields, and xmlUtil::NameSeq.

00057                                                        {
00058     unsigned int pathLen = subpath.size();
00059     if (pathLen > m_fields->size()) return false;
00060 
00061     // Else check one by one
00062     //    FieldIt idIt = m_fields->begin();
00063     //    NameSeq::iterator pathIt = path.begin();
00064 
00065     for (unsigned int ix = 0; ix < pathLen; ix++) {
00066       if (subpath[ix]->compare(((*m_fields)[ix])->name) ) return false;
00067     }
00068     return true;
00069   }

void xmlUtil::NamedId::popField unsigned int    n = 1
 

Delete field on the end.

Definition at line 50 of file NamedId.cxx.

References m_fields.

Referenced by testConverter().

00050                                        { 
00051     while (n > 0) {
00052       m_fields->pop_back();
00053       --n;
00054     }
00055   }

unsigned int xmlUtil::NamedId::size   const [inline]
 

Definition at line 50 of file NamedId.h.

References m_fields, and xmlUtil::NameSeq.

00050 {return m_fields->size();}

Identifier * xmlUtil::NamedId::stripNames  
 

Definition at line 78 of file NamedId.cxx.

References m_fields.

Referenced by testConverter().

00078                                   {
00079     Identifier *stripped = new Identifier();
00080 
00081     for (unsigned int ix = 0; ix < m_fields->size(); ix++) {
00082       stripped->push_back((*m_fields)[ix]->value);
00083     }
00084     return stripped;
00085   }


Friends And Related Function Documentation

friend class DictNode [friend]
 

Definition at line 80 of file NamedId.h.

friend class IdOpCompress [friend]
 

Definition at line 82 of file NamedId.h.

friend class IdOperation [friend]
 

Definition at line 81 of file NamedId.h.

std::ostream& operator<< std::ostream &    s,
const NamedId &    nId
[friend]
 

Output to an ostream.

Definition at line 88 of file NamedId.cxx.

00088                                                             {
00089     if (nId.size() == 0) {
00090       s << "()" << std::endl;
00091       return s;
00092     }
00093     NamedId::Fields::const_iterator it = nId.m_fields->begin();
00094     s << "(" << (*it)->name << "=" << (*it)->value;
00095     ++it;
00096     while (it != nId.m_fields->end()) {
00097       s << ", " << std::endl << (*it)->name << "=" << (*it)->value;
00098       ++it;
00099     }
00100     s << ")" << std::endl;
00101     return s;
00102   }


Member Data Documentation

Fields* xmlUtil::NamedId::m_fields [protected]
 

Definition at line 88 of file NamedId.h.

Referenced by addField(), hasField(), hasSubpath(), NamedId(), popField(), size(), stripNames(), and ~NamedId().


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:02:50 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001