This topic describes how to create a sample C++ library and configure a .mff file for it so that the library appears in the Libraries window of MapForce.
|1.||Create a header (.h) file for your class library. The following code listing illustrates a sample header file called Greetings.h.|
Notice that the function has been declared as static, and that the namespace altova is imported. Remember to write ALTOVA_DECLSPECIFIER in front of the class name, this ensures that your classes will compile correctly—whether you use dynamic or static linkage in subsequently generated code.
|2.||Create a .cpp file with the same name as the header file. The .cpp file must be in the same directory as the .h file. The following code listing illustrates a sample .cpp file called Greetings.cpp that includes the Greetings.h file created previously:|
Notice the lines that import the StdAfx.h and several Altova libraries. These lines must be left unchanged. The paths to the Altova libraries is correct; in the generated code, these paths will point to the respective files.
In contrast to Java or C#, you do not need to compile your source C++ files. They will be copied to the generated code, and are compiled with the rest of the generated mapping code.
|3.||Using an XML editor, create a new .mff file and validate it against the ..\Program Files\MapForceLibraries\mff.xsd folder. Make sure that the text highlighted below points to the directory of the header and cpp files created previously. Remember that the namespace and function names and data types defined here must correspond to those in the C++ code, as described in Configuring the .mff File. For information about data type support, see Data Type Mapping.|
<?xml version="1.0" encoding="UTF-8"?>
You have now finished creating a custom library and the .mff file which adapts it to MapForce. The custom .mff file can now be used in MapForce (see Importing the .mff File Into MapForce). Remember that, in order to execute mappings that use native C++ libraries, you will need to generate C++ code and run the mapping from your C++ code or application.
Resolving C++ compile errors
If you get a compiler error at the line shown below, modify the project properties to include a reference to the msado15.dll file.
#import "msado15.dll" rename("EOF", "EndOfFile")
In Visual Studio 2008:
|1.||On the Tools menu, click Options.|
|2.||Expand Projects and Solutions > VC++ Directories.|
|3.||Under "Show directories for", select Include files, and add a new entry that points to the directory where msado15.dll file is located (usually, C:\Program Files\Common Files\System\ADO).|
|4.||Build the project.|
© 2019 Altova GmbH