Manages the compilation of externalized resources from .alibrc files into C++ source code.
This class provides a development-time mechanism to:
.alibrc resource filesThis class operates only when the configuration macro ALIB_CAMP_RESOURCE_COMPILATION is set. Otherwise, the class is an almost empty stub. This approach allows a two-phase workflow:
Development Phase:
.alibrc text filesProduction Phase:
.alibrc files are not needed for distributionThe compiler uses file modification timestamps to determine when re-compilation is needed. If the target C++ file is newer than the .alibrc file (with 10ms tolerance), no action is taken.
Definition at line 201 of file resourcecompiler.hpp.
#include <resourcecompiler.hpp>
Public Method Index: | |
| ~DevtimeResourceCompiler () | |
| Destructor. This is empty if the symbol ALIB_CAMP_RESOURCE_COMPILATION is not set. | |
| bool | Do (const NString &alibrcFileName, const NString &callingFile, Camp &campInstance, const NString &resourceCategory, bool allowReplacements, const NString &cppFileName) |
Protected Field Index: | |
| MonoAllocator * | ma =nullptr |
|
protected |
The allocator to use. Created only in case resources are to be compiled (and a C++ file is to be patched).
Definition at line 206 of file resourcecompiler.hpp.
|
inline |
Destructor. This is empty if the symbol ALIB_CAMP_RESOURCE_COMPILATION is not set.
Definition at line 212 of file resourcecompiler.hpp.
| bool alib::camp::DevtimeResourceCompiler::Do | ( | const NString & | alibrcFileName, |
| const NString & | callingFile, | ||
| Camp & | campInstance, | ||
| const NString & | resourceCategory, | ||
| bool | allowReplacements, | ||
| const NString & | cppFileName ) |
Main entry point for resource compilation.
This method performs the complete resource compilation workflow:
CallingFile's directory).alibrc resource fileFile Path Resolution:
AlibrcFileName and CppFileName may be relative or absolute pathsCallingFile FILE as CallingFile to resolve relative to the calling sourceTimestamp-Based Compilation:
.alibrc and .cpp filesfalse to indicate no compilation occurredTarget File Requirements: The C++ file specified by CppFileName must contain two marker comments:
All lines between these markers are replaced with generated resource loading code. The markers themselves are preserved.
Conditional Compilation: When ALIB_CAMP_RESOURCE_COMPILATION is not set, this method becomes a no-op and always returns false.
Example Usage:
For the corresponding .alibrc file format, see manual section 4.2 The .alibrc File Format..
For the generated output, see the replacement section in App/sample.cpp.
| alibrcFileName | Path to the input .alibrc resource file. |
| callingFile | Reference file for resolving relative paths (typically FILE). |
| campInstance | The ALib Camp instance whose resource pool receives the resources. |
| resourceCategory | The resource category name for registering resources. |
| allowReplacements | Determines whether overriding existing resource-keys should raise an ALib Assertion. |
| cppFileName | Path to the target C++ source file to be patched. If an empty string is given, then the resource file will be loaded in any case and resources will be added. |
true if resources were compiled and the C++ file was updated successfully, false if compilation was skipped (file already up-to-date), an error occurred, or ALIB_CAMP_RESOURCE_COMPILATION is not set.