Example: SelValidate that checks the null flags in BoundIOs and uses this
information to set default values for null fields.
class Example
{
public:
int exampleInt;
string exampleStr;
double exampleDouble;
long exampleLong;
TIMESTAMP_STRUCT exampleDate;
};
template<> class dtl::DefaultSelValidate<Example>
{
public:
bool operator()(BoundIOs &boundIOs, Example &rowbuf) {
if (boundIOs["INT_VALUE"].IsNull()) {
rowbuf.exampleInt = 0;
}
if (boundIOs["STRING_VALUE"].IsNull()) {
rowbuf.exampleStr = "";
}
if (boundIOs["DOUBLE_VALUE"].IsNull()) {
rowbuf.exampleDouble = 0;
}
if (boundIOs["EXAMPLE_LONG"].IsNull()) {
rowbuf.exampleLong = 0;
}
if (boundIOs["EXAMPLE_DATE"].IsNull()) {
const TIMESTAMP_STRUCT defaultDate = {2000, 1, 1, 0, 0, 0, 0};
rowbuf.exampleDate = defaultDate;
}
if (rowbuf.exampleDouble > 100)
return false;
return true; // data is OK
}
};