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

NamedId.h

Go to the documentation of this file.
00001 //$Header: /nfs/slac/g/glast/ground/cvs/xmlUtil/xmlUtil/id/NamedId.h,v 1.10 2002/01/03 21:07:27 jrb Exp $
00002 #ifndef XMLUTIL_NAMEDID_H
00003 #define XMLUTIL_NAMEDID_H
00004 
00005 #include <vector>
00006 #include <string>
00007 #include <iostream>
00008 #include "xmlUtil/id/Identifier.h"
00009 
00010 namespace xmlUtil {
00011 
00013   //  typedef std::vector<unsigned> Identifier;
00014 
00017   typedef std::vector<std::string * > NameSeq;
00018 
00019   class NamedId;
00020 
00021   std::ostream& operator<<(std::ostream& s, const NameSeq& seq);
00022   std::ostream& operator<<(std::ostream& s, const Identifier& seq);
00023   std::ostream& operator<<(std::ostream& s, const NamedId& nId);
00024 
00025   class NamedId {
00026   public:
00027     friend std::ostream& operator<<(std::ostream& s, const NamedId& nId);
00028 
00030     NamedId(const int len = 0);
00031 
00033     NamedId(const NamedId& toCopy);
00034 
00036     NamedId(const NamedId& toCopy, unsigned int n);
00037 
00038     ~NamedId();
00039 
00040     struct IdField {
00041       std::string name;
00042       unsigned value;
00043     };
00044 
00046     void addField(std::string name, unsigned value);
00047 
00048     void addField(const IdField& newField);
00049 
00050     unsigned int size() const {return m_fields->size();}
00052     // Should it be returned rather than void?
00053     void popField(unsigned int n = 1);
00054 
00056     bool hasSubpath(const NameSeq& subpath) const;
00057 
00060     int hasField(std::string name) const;
00061 
00062     Identifier *stripNames();
00063 
00064     // Retrieve the sequence of names
00065     // So far this is just here for symmetry.  Can't think of a
00066     // good reason why anyone would want to do it.
00067     // NameSeq *stripValues() const;
00068     /* Return subsequence from field with name \b name1 to field with
00069       name \b name2, inclusive.  If these fields don't exist or don't
00070       occur in the proper order, return null.    */
00071     // NamedId *extract(const std::string& name1, const std::string& name2);
00072 
00073     /* Return a subsequence from field with name \b name1 until the
00074       end of the NamedId.  If \b name1 doesn't occur return null. */
00075     // NamedId *extract(const std::string& name1);
00076 
00077     // Append fields in order from \a toAppend 
00078     //void append(const NamedId& toAppend);
00079 
00080     friend class DictNode;
00081     friend class IdOperation;
00082     friend class IdOpCompress;
00083 
00084   protected:
00085     typedef std::vector <IdField* > Fields;
00086     typedef Fields::iterator  FieldIt;
00087    
00088     Fields *m_fields;
00089   };
00090 
00091 }
00092 #endif
00093 

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