Return Type | Function name | Arguments |
---|---|---|
bool | FormCheckDate | (hzXDate&,const char*,const char*,) |
Declared in file: hzTextproc.h
Defined in file : hzRegex.cpp
Function Logic:
Function body:
bool FormCheckDate (hzXDate& xdate, const char* cpTest, const char* cpCtrl) { _hzfunc(__func__) ; _psudoDate pd ; const char* ctrl ; const char* test ; uint32_t val ; xdate.Clear() ; if (!cpCtrl || !cpCtrl[0]) return true ; if (!cpTest || !cpTest[0]) return false ; test = cpTest ; ctrl = cpCtrl ; for (; *test && *ctrl ;) { if (*ctrl == ''*'') { for (; *ctrl == ''*'';ctrl++) ; for (; *test ; test++) { if (FormCheckDate(xdate, test, ctrl)) return true ; } return false ; } if (*ctrl == ''?'') { test++ ; ctrl++ ; continue ; } if (*ctrl == ''{'') { if (!_set_psudo_date(pd, &test, &ctrl)) return false ; continue ; } if (*ctrl == CHAR_BKSLASH) { if (ctrl[1]== CHAR_BKSLASH) if (*test == CHAR_BKSLASH) { test++ ; ctrl += 2; continue ; } if (ctrl[1]== ''n'') if (*test == CHAR_NL) { test++ ; ctrl += 2; continue ; } if (ctrl[1]== ''s'') if (*test == CHAR_CTRLL || *test == CHAR_NL || *test == CHAR_CR || *test == CHAR_TAB || *test == CHAR_CTRLK) { test++ ; ctrl += 2; continue ; } if (ctrl[1]== ''S'') if (*test > CHAR_SPACE) { test++ ; ctrl += 2; continue ; } if (ctrl[1]== ''c'') { if (ctrl[2]>&eq; ''a''&&ctrl[2]<&eq; ''z'') if (*test == (ctrl[2]-''a'')) { test++ ; ctrl += 3; continue ; } if (ctrl[2]>&eq; ''A''&&ctrl[2]<&eq; ''Z'') if (*test == (ctrl[2]-''A'')) { test++ ; ctrl += 3; continue ; } if (*test == ''c'') { test++ ; ctrl += 2; continue ; } } if (ctrl[1]== ''x'') if (IsHexnum(val, ctrl+1)) if (*test == (uchar) (val & 0xff)) { test++ ; ctrl += 4; continue ; } if (ctrl[1]== ''t'') if (*test == CHAR_TAB) { test++ ; ctrl += 2; continue ; } if (ctrl[1]== ''v'') if (*test == CHAR_CTRLI) { test++ ; ctrl += 2; continue ; } if (*test == ctrl[1]) { test++ ; ctrl += 2; continue ; } } if (*test == *ctrl) { test++ ; ctrl++ ; continue ; } return false ; } if (pd.Y || pd.M || pd.D) { if ( pd.Y && pd.M && pd.D) xdate.SetDate(pd.Y, pd.M, pd.D) ; else if ( pd.Y && pd.M && !pd.D) xdate.SetDate(pd.Y, pd.M, 1); else if ( pd.Y && !pd.M && pd.D) xdate.Clear() ; else if ( pd.Y && !pd.M && !pd.D) xdate.Clear() ; else if (!pd.Y && pd.M && pd.D) { if (xdate.IsSet()) pd.Y = xdate.Year() ; else { xdate.SysDateTime() ; pd.Y = xdate.Year() ; } xdate.SetDate(pd.Y, pd.M, pd.D) ; } else if (!pd.Y && pd.M && !pd.D) xdate.Clear() ; else if (!pd.Y && !pd.M && pd.D) xdate.Clear() ; else if (!pd.Y && !pd.M && !pd.D) xdate.Clear() ; if (!xdate.IsSet()) return false ; } return true ; }