[oXygen-user] C++ XML Data Binding

Olumide videohead at mail.com
Mon Jan 7 13:20:07 CST 2013


Hello -

Given an XML "config" file

<?xml version="1.0" encoding="UTF-8"?>
<Device manufacturer="ACME" model="Gizmo">
	<Frequencies>3200 6400 12800</Frequencies>
	<ImageSupport value='false'/>
	<Memory size="128"/>
</Device>

defining the attributes of an object, what would be the best way to 
create C++ header and implementation files

/* C++ Header File */
namespace ACME
{
   class Gizmo
   {
   public:
     typedef std::vector<unsigned> Frequency;
     Frequency initializeFrequency();      // ideally, private
     static const Frequency  m_frequency;

     static const bool     m_supportsImages = false;
     static const unsigned   m_deviceMemory = 128;

     static const std::string name();
   };
}


/* C++ implementation file */
namespace ACME
{
   const Gizmo::m_frequency = Gizmo::initializeFrequency();

   Frequency Gizmo::initializeFrequency()
   {
     Frequency freq;

     freq.push_back( 3200 );
     freq.push_back( 6400 );
     freq.push_back( 12800 );

     return freq;
   }

   const std::string Gizmo::name()
   {
     return "ACME::Gizmo";
   }
}

I've googled and found some utilities (mostly) commercial but I'm not 
sure which is the best or if this task can be easily accomplished with XSLT.

Regards,

- Olumide



More information about the oXygen-user mailing list