38 : m_stringValues(rhs.m_stringValues ? new std::
vector<std::
string>(*(rhs.m_stringValues)) : nullptr),
39 m_keyValues(rhs.m_keyValues ? new
KeyValues(*(rhs.m_keyValues)) : nullptr),
40 m_version(rhs.m_version) {}
60 throw std::runtime_error(
"adding key/value to configuration containing string values");
63 m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, iConfig));
65 m_keyValues->push_back(std::make_pair(iKey, iConfig));
71 throw std::runtime_error(
"adding key/value to configuration containing string values");
74 throw std::runtime_error(
"adding key/value to configuration containing string values");
78 m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, iConfig));
80 m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey,
FWConfiguration()));
81 m_keyValues->back().second.swap(iConfig);
85 m_keyValues->push_back(std::make_pair(iKey, iConfig));
88 m_keyValues->back().second.swap(iConfig);
96 throw std::runtime_error(
"adding string value to configuration containing key/value pairs");
99 m_stringValues = std::make_unique<std::vector<std::string>>(1, iValue);
101 m_stringValues->push_back(iValue);
117 throw std::runtime_error(
"no string values set");
119 return m_stringValues->at(iIndex);
124 throw std::runtime_error(
"valueFoKey fails because configuration containing string values");
127 throw std::runtime_error(
"valueForKey fails becuase no key/values set");
129 KeyValues::iterator itFind =
130 std::find_if(m_keyValues->begin(),
132 std::bind(std::equal_to<void>(),
135 if (itFind == m_keyValues->end()) {
138 return &(itFind->second);
147 while (std::string::npos != (index = value.find(
'&', index))) {
148 value.replace(index, 1,
"&", 5);
153 while (std::string::npos != (index = value.find(
'"', index))) {
154 value.replace(index, 1,
""", 6);
160 while (std::string::npos != (index = value.find(
'<', index))) {
161 value.replace(index, 1,
"<", 4);
167 while (std::string::npos != (index = value.find(
'>', index))) {
168 value.replace(index, 1,
">", 4);
197 static int recursionLevel = -1;
200 oTo << indentation <<
"<config name=\"" << name <<
"\" version=\"" << iConfig.
version() <<
"\">\n";
202 for (FWConfiguration::StringValues::const_iterator it = iConfig.
stringValues()->begin();
205 oTo << indentation <<
" <string>" <<
attrEscape(*it) <<
"</string>\n";
209 for (FWConfiguration::KeyValues::const_iterator it = iConfig.
keyValues()->begin(); it != iConfig.
keyValues()->end();
214 oTo << indentation <<
"</config>" << std::endl;
const StringValues * stringValues() const
FWConfiguration(unsigned int iVersion=1)
const KeyValues * keyValues() const
unsigned int version() const
FWConfiguration & operator=(const FWConfiguration &)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void swap(FWConfiguration &)
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
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
std::unique_ptr< std::vector< std::string > > m_stringValues
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)