Go to the documentation of this file.00001 #ifndef DD_XMLElement_H
00002 #define DD_XMLElement_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <map>
00015 #include <string>
00016 #include <vector>
00017
00018 #include "DetectorDescription/Core/interface/DDName.h"
00019 #include "DetectorDescription/Core/interface/DDCompactView.h"
00020
00021 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
00022
00023
00024
00025
00026
00028
00055 typedef std::map <std::string, std::string> DDXMLAttribute;
00056 typedef std::map <std::string, std::vector<std::string> > AttrAccumType;
00057
00058 class DDXMLElement
00059 {
00060 friend std::ostream & operator<<(std::ostream & os, const DDXMLElement & element);
00061
00062 public:
00063
00065 DDXMLElement( DDLElementRegistry* myreg );
00066
00068 DDXMLElement( DDLElementRegistry* myreg, const bool& clearme );
00069
00071 virtual ~DDXMLElement( void );
00072
00074
00083 void loadAttributes(const std::string& elemName,
00084 const std::vector<std::string> & names,
00085 const std::vector<std::string> & values,
00086 const std::string& nmspace, DDCompactView& cpv );
00087
00089
00097 void loadText( const std::string& inText );
00098
00100 void appendText( const std::string& inText );
00101
00103 const std::string getText( size_t tindex = 0 ) const;
00104
00106 virtual bool gotText( void ) const;
00107
00109 virtual void clear( void );
00110
00112 virtual const std::string & getAttribute( const std::string& name ) const;
00113
00115 virtual const DDXMLAttribute& getAttributeSet( size_t aIndex = 0 ) const;
00116
00117 const virtual DDName getDDName( const std::string& defaultNS, const std::string& attname = std::string( "name" ), size_t aIndex = 0 );
00118
00119
00120
00121
00122
00123
00124
00126 virtual const std::string & get( const std::string& name, size_t aIndex = 0 ) const;
00127
00129 virtual std::vector<std::string> getVectorAttribute( const std::string& name );
00130
00132 virtual size_t size( void ) const;
00133
00134 virtual std::vector<DDXMLAttribute>::const_iterator begin( void );
00135
00136 virtual std::vector<DDXMLAttribute>::const_iterator end( void );
00137
00139 void setParent( const std::string& pename );
00140
00142 void setSelf( const std::string& sename );
00143
00145 const std::string& parent( void ) const;
00146
00148
00156 virtual void processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv );
00157
00159
00167 virtual void preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv );
00168
00170 virtual void stream( std::ostream & os ) const;
00171
00173 std::vector<DDXMLAttribute>::const_iterator& operator++( int inc );
00174
00176 virtual bool isEmpty( void ) const;
00177
00179 void throwError( const std::string& keyMessage ) const;
00180
00181
00183 static std::string itostr( int i );
00184
00185 protected:
00186 DDLElementRegistry* myRegistry_;
00187
00188 private:
00190 void appendAttributes( std::vector<std::string> & tv, const std::string& name );
00191
00192 std::vector<DDXMLAttribute> attributes_;
00193 std::vector<std::string> text_;
00194 AttrAccumType attributeAccumulator_;
00195 bool autoClear_;
00196 std::vector<DDXMLAttribute>::const_iterator myIter_;
00197 std::string myElement_;
00198 std::string parentElement_;
00199 };
00200
00201 #endif