Factor common code out of the xml_format files.

This commit is contained in:
Joe Thornber
2014-08-06 15:29:02 +01:00
parent d8f678b079
commit 1d38b390b5
5 changed files with 81 additions and 85 deletions

25
base/xml_utils.cc Normal file
View File

@ -0,0 +1,25 @@
#include "xml_utils.h"
//----------------------------------------------------------------
void
xml_utils::build_attributes(attributes &a, char const **attr)
{
while (*attr) {
char const *key = *attr;
attr++;
if (!*attr) {
ostringstream out;
out << "No value given for xml attribute: " << key;
throw runtime_error(out.str());
}
char const *value = *attr;
a.insert(make_pair(string(key), string(value)));
attr++;
}
}
//----------------------------------------------------------------