1 #ifndef CondCore_Utilities_Payload2XMLModule_h
2 #define CondCore_Utilities_Payload2XMLModule_h
7 #include <pybind11/pybind11.h>
9 namespace py = pybind11;
13 #define XML_CONVERTER_NAME(CLASS_NAME) (std::string(#CLASS_NAME) + "2xml").c_str()
15 #define PAYLOAD_2XML_MODULE(MODULE_NAME) PYBIND11_MODULE(MODULE_NAME, m)
17 #define PAYLOAD_2XML_CLASS(CLASS_NAME) \
18 py::class_<Payload2xml<CLASS_NAME> >(m, XML_CONVERTER_NAME(CLASS_NAME)) \
20 .def("write", &Payload2xml<CLASS_NAME>::write);
24 template <
typename PayloadType>
31 std::unique_ptr<PayloadType>
payload;
32 std::stringbuf sdataBuf;
33 sdataBuf.pubsetbuf(const_cast<char *>(payloadData.c_str()), payloadData.size());
35 std::istream inBuffer(&sdataBuf);
41 std::ostringstream outBuffer;
43 boost::archive::xml_oarchive xmlResult(outBuffer);
44 xmlResult << boost::serialization::make_nvp(
"cmsCondPayload", *
payload);
46 return outBuffer.str();