16 #include <boost/bind.hpp>
38 m_stringValues( rhs.m_stringValues ? new std::vector<std::
string>(*(rhs.m_stringValues)) : 0),
39 m_keyValues( rhs.m_keyValues ? new
KeyValues(*(rhs.m_keyValues)) : 0),
40 m_version(rhs.m_version)
67 throw std::runtime_error(
"adding key/value to configuration containing string values");
70 m_keyValues.reset(
new KeyValues(1, std::make_pair(iKey,iConfig) ) );
72 m_keyValues->push_back(std::make_pair(iKey,iConfig));
80 throw std::runtime_error(
"adding key/value to configuration containing string values");
83 throw std::runtime_error(
"adding key/value to configuration containing string values");
87 m_keyValues.reset(
new KeyValues(1, std::make_pair(iKey,iConfig) ) );
90 m_keyValues->back().second.swap(iConfig);
94 m_keyValues->push_back(std::make_pair(iKey,iConfig));
97 m_keyValues->back().second.swap(iConfig);
107 throw std::runtime_error(
"adding string value to configuration containing key/value pairs");
110 m_stringValues.reset(
new std::vector<std::string>(1,iValue) );
112 m_stringValues->push_back(iValue);
132 throw std::runtime_error(
"no string values set");
134 return m_stringValues->at(iIndex);
141 throw std::runtime_error(
"valueFoKey fails because configuration containing string values");
144 throw std::runtime_error(
"valueForKey fails becuase no key/values set");
146 KeyValues::iterator itFind = std::find_if(m_keyValues->begin(),
149 if(itFind == m_keyValues->end()) {
152 return &(itFind->second);
164 while (std::string::npos != (index=value.find(
'&',index))){
165 value.replace(index, 1,
"&", 5);
170 while (std::string::npos != (index=value.find(
'"',index))){
171 value.replace(index, 1,
""", 6);
177 while (std::string::npos != (index=value.find(
'<',index))){
178 value.replace(index, 1,
"<", 4);
184 while (std::string::npos != (index=value.find(
'>',index))){
185 value.replace(index, 1,
">", 4);
216 static int recursionLevel = -1;
219 oTo << indentation <<
"<config name=\"" << name
220 <<
"\" version=\"" << iConfig.
version() <<
"\">\n";
222 for(FWConfiguration::StringValues::const_iterator it = iConfig.
stringValues()->begin();
225 oTo << indentation <<
" <string>" <<
attrEscape(*it) <<
"</string>\n";
229 for(FWConfiguration::KeyValues::const_iterator it = iConfig.
keyValues()->begin();
235 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
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
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)