17 #include <boost/bind.hpp>
39 m_stringValues( rhs.m_stringValues ? new std::vector<std::string>(*(rhs.m_stringValues)) : 0),
40 m_keyValues( rhs.m_keyValues ? new
KeyValues(*(rhs.m_keyValues)) : 0),
41 m_version(rhs.m_version)
68 throw std::runtime_error(
"adding key/value to configuration containing string values");
71 m_keyValues.reset(
new KeyValues(1, std::make_pair(iKey,iConfig) ) );
73 m_keyValues->push_back(std::make_pair(iKey,iConfig));
81 throw std::runtime_error(
"adding key/value to configuration containing string values");
84 throw std::runtime_error(
"adding key/value to configuration containing string values");
88 m_keyValues.reset(
new KeyValues(1, std::make_pair(iKey,iConfig) ) );
91 m_keyValues->back().second.swap(iConfig);
95 m_keyValues->push_back(std::make_pair(iKey,iConfig));
98 m_keyValues->back().second.swap(iConfig);
108 throw std::runtime_error(
"adding string value to configuration containing key/value pairs");
111 m_stringValues.reset(
new std::vector<std::string>(1,iValue) );
113 m_stringValues->push_back(iValue);
133 throw std::runtime_error(
"no string values set");
135 return m_stringValues->at(iIndex);
142 throw std::runtime_error(
"valueFoKey fails because configuration containing string values");
145 throw std::runtime_error(
"valueForKey fails becuase no key/values set");
147 KeyValues::iterator itFind = std::find_if(m_keyValues->begin(),
150 if(itFind == m_keyValues->end()) {
153 return &(itFind->second);
165 while (std::string::npos != (index=value.find(
'&',index))){
166 value.replace(index, 1,
"&", 5);
171 while (std::string::npos != (index=value.find(
'"',index))){
172 value.replace(index, 1,
""", 6);
178 while (std::string::npos != (index=value.find(
'<',index))){
179 value.replace(index, 1,
"<", 4);
185 while (std::string::npos != (index=value.find(
'>',index))){
186 value.replace(index, 1,
">", 4);
217 static int recursionLevel = -1;
219 std::string indentation(recursionLevel,
' ');
220 oTo << indentation <<
"<config name=\"" << name
221 <<
"\" version=\"" << iConfig.
version() <<
"\">\n";
223 for(FWConfiguration::StringValues::const_iterator it = iConfig.
stringValues()->begin();
226 oTo << indentation <<
" <string>" <<
attrEscape(*it) <<
"</string>\n";
230 for(FWConfiguration::KeyValues::const_iterator it = iConfig.
keyValues()->begin();
236 oTo << indentation <<
"</config>" << std::endl;
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
const StringValues * stringValues() const
FWConfiguration(unsigned int iVersion=1)
const KeyValues * keyValues() const
void streamTo(std::ostream &, const FWConfiguration &, const std::string &name)
boost::scoped_ptr< std::vector< std::string > > m_stringValues
unsigned int version() const
FWConfiguration & operator=(const FWConfiguration &)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void swap(FWConfiguration &)
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const std::string & value(unsigned int iIndex=0) const
FWConfiguration & addValue(const std::string &)
std::string attrEscape(std::string value)
virtual ~FWConfiguration()
const FWConfiguration * valueForKey(const std::string &iKey) const
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues