CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PayloadToXML.h
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <string>
4 #include <memory>
5 
6 #include <boost/python/class.hpp>
7 #include <boost/python/module.hpp>
8 #include <boost/python/init.hpp>
9 #include <boost/python/def.hpp>
10 #include <iostream>
11 #include <string>
12 #include <sstream>
13 
14 #include "boost/archive/xml_oarchive.hpp"
17 
18 namespace cond {
19 
20  template<typename T>
21  std::string convertToXML( const std::string &payloadData, const std::string &payloadType ) {
22 
23  std::unique_ptr< T > payload;
24  std::stringbuf sdataBuf;
25  sdataBuf.pubsetbuf( const_cast<char *> ( payloadData.c_str() ), payloadData.size() );
26 
27  std::istream inBuffer( &sdataBuf );
28  eos::portable_iarchive ia( inBuffer );
29  payload.reset( new T );
30  ia >> (*payload);
31 
32  // now we have the object in memory, convert it to xml in a string and return it
33 
34  std::ostringstream outBuffer;
35  boost::archive::xml_oarchive xmlResult( outBuffer );
36  xmlResult << boost::serialization::make_nvp( "cmsCondPayload", *payload );
37 
38  return outBuffer.str();
39 
40  }
41 } // end namespace cond
42 
long double T
std::string convertToXML(const std::string &payloadData, const std::string &payloadType)
Definition: PayloadToXML.h:21