|
Net-Marks Softwareformerly Pyrealware
|
xml2cpp
Download/Install
xml2cpp
- »
- Downloads: 110 download (2.62 KB)
Functionality/Use
This is a tool that was originally created for use by Decal Plugin programmers using VC++, but it does have other uses if you're clever.
Essentially I had gotten very tired of doing Decal Plugin XML following the example of the original Decal demo plugin. My problems were: I'm not too keen on having to release the XML file with plugins, making sure it lives in the right place, it allows the XML to be easily modified which could break a Decal Plugin, etc.
However, I also did not want to loose the XML debugging capabilities of Internet Explorer - which would happen if I hard coded my XML directly into my Decal Plugin.
So I wrote this little program which takes an XML file and converts it into a _bstr_t and stores it in a cpp file named after the XML file. You can then include the XML file in your VC++ project and create a custom build step for it using this tool.
You need to make sure that xml2cpp.exe is in your path as defined in your DevStudio VC++ options. This setting can be found under Projects and Solutions->VC++ Directories or Directories (depending on your version of DevStudio) which can be gotten too using Tools->Options.... Set the Show directories for: to Executable files, then add in the directory where you place xml2cpp.exe at the end of the listing.
Add your XML file to your project under the Source Files folder (or equivalent). And then right-click the XML file and choose Settings... On this page choose the Custom Build tab. Under Commands add the text:
xml2cpp $(InputPath)
and under the Outputs enter in:
$(InputName)_xml.cpp
Now compile and you will notice that, for example, if your XML file was named X.xml, that the file X_xml.cpp will be created. Inside that file the string g_bstrX_xml will be created. Now all you need to do is in the file where you want to use the XML from X.xml add the following line at the top of your file (where you feel it appropriate):
#include "X_xml.cpp"
and then when you create your view (if using Decal) use the following command:
m_pSite->LoadView(g_bstrX_xml, &m_pView);
Doing this you can use a separate file for your XML, but you gain the benefit of not having to release your XML with your plugin. I find this to be extremely useful, but, y'mmv.

