[xsd-users] Using xsd commercially in-house

Olumide videohead at mail.com
Tue Jan 8 10:30:00 EST 2013


On 08/01/2013 15:37, Boris Kolpackov wrote:
>> Can xsd be used commercially in-house _solely_ to generate C++ files?
>
> Yes, you can use XSD (including generating C++ files and linking to the
> XSD runtime) without having to publish your source code under the GPLv2
> provided you do not distribute your application to any third party (which
> is what I believe you mean by "in-house").
>
>
>> The runtime library will not be linked with our codebase in anyway.
>
> The generated code is quite useless without the runtime. The only use
> case I could think of is using the generated code as some kind of a
> test case for a static analysis tool or some such. But, as I mentioned
> above, you can link to the runtime if you need to.

Here's what we need to do. 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, we would like to output the 
following 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";
   }
}

As you can see the generated code is self contained. And yes the code 
generated will be shipped.

Regards,

- Olumide



More information about the xsd-users mailing list