int LineParser::gettoken_enum(int token, const char *strlist) // null seperated list { int x=0; char *tt=gettoken_str(token); if (tt && *tt) while (*strlist) { if (!stricmp(tt,strlist)) return x; strlist+=strlen(strlist)+1; x++; } return -1; }
int LineParser::gettoken_enum(int token, const TCHAR *strlist) // null separated list { int x=0; TCHAR *tt=gettoken_str(token); if (tt && *tt) while (*strlist) { if (!_tcsicmp(tt,strlist)) return x; strlist+=_tcslen(strlist)+1; x++; } return -1; }
double LineParser::gettoken_number(int token, int *success/*=0*/) const { const TCHAR*str=gettoken_str(token); if (_T('-') == *str || _T('+') == *str) ++str; bool forceint = false; if (_T('0') == str[0]) { if (_T('x') == (str[1]|32)) ++forceint; if (_T('n') == (str[1]|32)) ++forceint; if (_T('b') == (str[1]|32) || _T('y') == (str[1]|32)) ++forceint; } return forceint ? gettoken_int(token,success) : gettoken_float(token,success); }
int LineParser::gettoken_binstrdata(int token, char*buffer, int bufcap) const { const TCHAR*p=gettoken_str(token); int a,b,c,d=0; while (*p) { a=*p; if (a >= _T('0') && a <= _T('9')) a-=_T('0'); else if (a >= _T('a') && a <= _T('f')) a-=_T('a')-10; else if (a >= _T('A') && a <= _T('F')) a-=_T('A')-10; else if (a == _T(',')) { ++p; continue; } // Allow comma separator (for Regedit5 .reg format) else break; b=*++p; if (b >= _T('0') && b <= _T('9')) b-=_T('0'); else if (b >= _T('a') && b <= _T('f')) b-=_T('a')-10; else if (b >= _T('A') && b <= _T('F')) b-=_T('A')-10; else break; c=(a<<4)|b, p++; if (d >= bufcap) return -1; // Buffer too small buffer[d++]=c; } if (*p) return -2; // Did not parse the entire buffer return d; }