LMX Example
Version 1.3
Document Revision 1
Copyright © 2007 Codalogic Ltd.

Introduction

This document gives an example of how to use LMX. Although it is brief, it covers many of the concepts, such as marshaling / unmarshaling and how to interface with optional, singular and multiple types. It also shows how to work with complex types.

Example

To follow the example you will need to extract the contents of lmx-example.zip from the examples sub-directory of the LMX installation, or download the ZIP file from
http://www.codalogic.com/lmx/lmx-example.zip. You can also download the LMX install file from http://www.codalogic.com/lmx/download.php to generate the po.h and po.cpp, or you can use the pre-generated files contained in the ZIP file.

Having downloaded the relevant files you should perform the following steps:

  1. Unzip the example file into a fresh directory.

  2. If you wish to generate the po.h and po.cpp files using LMX, double-click on the file po.lmxprj in Explorer. This should bring up WinLMX. Within WinLMX, press the 'Compile...' button at the bottom of the window and the files will be generated. (Press 'Exit' when complete.)

  3. Or, you can copy the pre-generated files located in the Generated sub-directory into your project directory.

  4. Open the poexample project file relevant to your development environment - poexamplevc6.dsw for VC6, poexamplevc7.sln for VS 2003 and poexamplevc8.sln for VS 2005.

  5. The main part of the example is in the handle_po() function in the poexample.cpp file. Scanning the comments should tell you what is happening at each stage.

  6. Compile, build and run.

Conclusion

The example demonstrates how easy it is to use LMX to interface with XML. Although the example is short, it illustrates many of the key points, including how to unmarshal and marshal, as well as read and writing to different types of data.