16 #include <boost/bind.hpp> 37 : m_stringValues(rhs.m_stringValues ? new
std::vector<
std::
string>(*(rhs.m_stringValues)) :
nullptr),
39 m_version(rhs.m_version) {}
59 throw std::runtime_error(
"adding key/value to configuration containing string values");
62 m_keyValues.reset(
new KeyValues(1, std::make_pair(iKey, iConfig)));
64 m_keyValues->push_back(std::make_pair(iKey, iConfig));
70 throw std::runtime_error(
"adding key/value to configuration containing string values");
73 throw std::runtime_error(
"adding key/value to configuration containing string values");
77 m_keyValues.reset(
new KeyValues(1, std::make_pair(iKey, iConfig)));
80 m_keyValues->back().second.swap(iConfig);
84 m_keyValues->push_back(std::make_pair(iKey, iConfig));
87 m_keyValues->back().second.swap(iConfig);
95 throw std::runtime_error(
"adding string value to configuration containing key/value pairs");
98 m_stringValues.reset(
new std::vector<std::string>(1, iValue));
100 m_stringValues->push_back(iValue);
116 throw std::runtime_error(
"no string values set");
118 return m_stringValues->at(iIndex);
123 throw std::runtime_error(
"valueFoKey fails because configuration containing string values");
126 throw std::runtime_error(
"valueForKey fails becuase no key/values set");
128 KeyValues::iterator itFind = std::find_if(m_keyValues->begin(),
131 if (itFind == m_keyValues->end()) {
134 return &(itFind->second);
143 while (std::string::npos != (index = value.find(
'&', index))) {
144 value.replace(index, 1,
"&", 5);
149 while (std::string::npos != (index = value.find(
'"', index))) {
150 value.replace(index, 1,
""", 6);
156 while (std::string::npos != (index = value.find(
'<', index))) {
157 value.replace(index, 1,
"<", 4);
163 while (std::string::npos != (index = value.find(
'>', index))) {
164 value.replace(index, 1,
">", 4);
193 static int recursionLevel = -1;
196 oTo << indentation <<
"<config name=\"" << name <<
"\" version=\"" << iConfig.
version() <<
"\">\n";
198 for (FWConfiguration::StringValues::const_iterator it = iConfig.
stringValues()->begin();
201 oTo << indentation <<
" <string>" <<
attrEscape(*it) <<
"</string>\n";
205 for (FWConfiguration::KeyValues::const_iterator it = iConfig.
keyValues()->begin(); it != iConfig.
keyValues()->end();
210 oTo << indentation <<
"</config>" << std::endl;
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 &)
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void swap(FWConfiguration &)
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
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
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)