chore(developer): refactor CompMsg.cpp to use a std::map

This commit is contained in:
Dr Mark C. Sinclair 2024-05-20 11:19:54 +01:00
parent a099c86ad8
commit 5ea3f6ec16

View file

@ -1,11 +1,7 @@
#include <CompMsg.h>
#include <map>
struct CompilerError {
KMX_DWORD ErrorCode;
const KMX_CHAR* Text;
};
const struct CompilerError CompilerErrors[] = {
std::map<KMX_DWORD, const KMX_CHAR*> CompilerErrorMap = {
{ CERR_InvalidLayoutLine , "Invalid 'layout' command"},
{ CERR_NoVersionLine , "No version line found for file"},
{ CERR_InvalidGroupLine , "Invalid 'group' command"},
@ -150,14 +146,8 @@ const struct CompilerError CompilerErrors[] = {
{ CWARN_VirtualKeyInOutput , "Virtual keys are not supported in output"},
{ 0, nullptr }
};
};
KMX_CHAR *GetCompilerErrorString(KMX_DWORD code)
{
for(int i = 0; CompilerErrors[i].ErrorCode; i++) {
if(CompilerErrors[i].ErrorCode == code) {
return ( KMX_CHAR*) CompilerErrors[i].Text;
}
}
return nullptr;
KMX_CHAR *GetCompilerErrorString(KMX_DWORD code) {
return (KMX_CHAR*) CompilerErrorMap[code];
}