
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

Hi Olumide, I'm no C++ programmer, but if it's as straightforward as plugging values into boilerplate, this is simply done with XSLT. What's not so simple is to avoid the temptation to do more. Entire domain-specific languages have been implemented with XSLT used as a "compiler". Cheers, Wendell On Mon, Jan 7, 2013 at 2:20 PM, Olumide <videohead@mail.com> wrote:
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
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
-- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^

Thanks Wendell. I am evaluating a utility that's highly recommended for this sort of task. Unfortunately, output of this utility requires a runtime that must be licensed. I suppose this is true of similar products. If this happens to be the case I will have to perform the conversion by myself via XSLT. - Olumide
participants (2)
-
Olumide
-
Wendell Piez