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 #include "DetectorDescription/Base/interface/DDException.h"
00021
00022 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
00023
00024
00025
00026
00027
00029
00056 typedef std::map <std::string, std::string> DDXMLAttribute;
00057 typedef std::map <std::string, std::vector<std::string> > AttrAccumType;
00058
00059 class DDXMLElement
00060 {
00061 friend std::ostream & operator<<(std::ostream & os, const DDXMLElement & element);
00062
00063 public:
00064
00066 DDXMLElement( DDLElementRegistry* myreg );
00067
00069 DDXMLElement( DDLElementRegistry* myreg, const bool& clearme );
00070
00072 virtual ~DDXMLElement( void );
00073
00075
00084 void loadAttributes( const std::string& elemName,
00085 const std::vector<std::string> & names,
00086 const std::vector<std::string> & values,
00087 const std::string& nmspace, DDCompactView& cpv );
00088
00090
00098 void loadText( const std::string& inText );
00099
00101 void appendText( const std::string& inText );
00102
00104 const std::string getText( size_t tindex = 0 ) const;
00105
00107 virtual bool gotText( void ) const;
00108
00110 virtual void clear( void );
00111
00113 virtual const std::string & getAttribute( const std::string& name ) const;
00114
00116 virtual const DDXMLAttribute& getAttributeSet( size_t aIndex = 0 ) const;
00117
00118 const virtual DDName getDDName( const std::string& defaultNS, const std::string& attname = std::string( "name" ), size_t aIndex = 0 );
00119
00120
00121
00122
00123
00124
00125
00127 virtual const std::string & get( const std::string& name, size_t aIndex = 0 ) const;
00128
00130 virtual std::vector<std::string> getVectorAttribute( const std::string& name );
00131
00133 virtual size_t size( void ) const;
00134
00135 virtual std::vector<DDXMLAttribute>::const_iterator begin( void );
00136
00137 virtual std::vector<DDXMLAttribute>::const_iterator end( void );
00138
00140 void setParent( const std::string& pename );
00141
00143 void setSelf( const std::string& sename );
00144
00146 const std::string& parent( void ) const;
00147
00149
00157 virtual void processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv );
00158
00160
00168 virtual void preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv );
00169
00171 virtual void stream( std::ostream & os ) const;
00172
00174 std::vector<DDXMLAttribute>::const_iterator& operator++( int inc );
00175
00177 virtual bool isEmpty( void ) const;
00178
00180 void throwError( const std::string& keyMessage ) const;
00181
00182
00184 static std::string itostr( int i );
00185
00186 protected:
00187 DDLElementRegistry* myRegistry_;
00188
00189 private:
00191 void appendAttributes( std::vector<std::string> & tv, const std::string& name );
00192
00193 std::vector<DDXMLAttribute> attributes_;
00194 std::vector<std::string> text_;
00195 AttrAccumType attributeAccumulator_;
00196 bool autoClear_;
00197 std::vector<DDXMLAttribute>::const_iterator myIter_;
00198 std::string myElement_;
00199 std::string parentElement_;
00200 };
00201
00202 #endif