Using include files

Configs in the ArmA world are ostensibly written in C++, as you'd expect from the .cpp extension of unbinarized configs. Therefore in ArmA configs it is possible to use header files to keep large files organized by piecing them together out of smaller files with well-defined responsibilities. The files to be included are given the file extension .hpp.

The only place I've seen this used is in the BISampleMap, to include the contents of the Names class into the main config.cpp file. However, this can be useful to keep your islands' configs clean and easy to read by moving very large sections like the Names and clutter classes to separate files.

Creating a header file is simple, just write the code you intend to include in the main file. Since including is done by the preprocessor, this is effectively the same as copying and pasting the contents of the header file to wherever you place the include directive: that is, the code in the included file will be in the same scope as the include directive.

This is the SampleMap.hpp file for BISampleMap:

class SampleMapVeg_1
{
    name="";
    position[]={2713.62,2140.92};
    type="VegetationPalm";
    radiusA=50;
    radiusB=50;
};
class SampleMapVeg_2
{
    name="";
    position[]={2446.09,3038.29};
    type="VegetationPalm";
    radiusA=50;
    radiusB=50;
};
class SampleMapVeg_3
{
    name="";
    position[]={2940.52,2923.19};
    type="VegetationPalm";
    radiusA=50;
    radiusB=50;
};
class Sample_VillageRahmadi
{
    name="Rahmadi";
    position[]={2882.85,2869.11};
    type="NameVillage";
    radiusA=100;
    radiusB=100;
};


The include directive is simple - #include followed by the name of the header file in quotes. This is the include directive in the BISampleMap config that includes the above .hpp file.

#include "SampleMap.hpp"

There are no downsides that I know of to this. Upon binarization included files are merged into the single config.bin file that is included in the final PBO, so there should be no performance impact incurred by using this method.
Comments