ReadStat
ReadStat copied to clipboard
Handler error code type (enum) doesn't match the return type of handlers (int)
Handlers like readstat_set_variable_handler return an integer error code, but the three available error codes are defined as an enum:
enum {
READSTAT_HANDLER_OK,
READSTAT_HANDLER_ABORT,
READSTAT_HANDLER_SKIP_VARIABLE
};
As a result when registering a handler as a lambda function, I need a cast to avoid compilation errors:
readstat_set_variable_handler(parser, [](int, readstat_variable_t*, const char*, void*) {
return static_cast<int>(READSTAT_HANDLER_OK);
});
While it would make sense to be able to write:
readstat_set_variable_handler(parser, [](int, readstat_variable_t*, const char*, void*) {
return READSTAT_HANDLER_OK;
});