Safestruct acts as a fundamental class for ensuring member safety from errors that occur from incorrect spellings for any intended class.
The concept behind Safestruct is of a "safe structure," similar to how C++ operates. In C++, each member of a class is declared at compile time, and assignments to non-existent members cannot be made at run time. Safestruct operates on this same principle to guard against programming errors arising from mispelled attribute names which can lead to silent runtime errors.
This software offers two classes: TrappingStruct and NontrappingStruct. Both classes present the same interface, but NontrappingStruct does not perform attribute checking. This class is intended to be used once the code is debugged and is faster, offering faster access. Depending on your needs, SetDebug function can be used to set the SafeStruct member equal to TrappingStruct or NontrappingStruct, making it easy to switch from safe access to faster access by changing just one thing in one file.
Overall, Safestruct is a fantastic tool for anyone looking to check their code for misspelled attributes and avoid runtime errors. The test code at the bottom of this review provides an excellent example of its usage in practice.
Version 1.0: N/A