I don\'t need to validate that the IP address is reachable or anything like that. I just want to validate that the string is in dotted-quad (xxx.xxx.xxx.xxx) IPv4 format, w
Here's one straightforward method.
bool IsIPAddress(std::string & ipaddr)
{
StringTokenizer quads(ipaddr,".");
if (quads.countTokens() != 4) return false;
for (int i=0; i < 4; i++)
{
std::string quad = quads.nextToken();
for (int j=0; j < quad.length(); j++
if (!isdigit(quad[j])) return false;
int quad = atoi(quads.GetTokenAt(i));
if (quad < 0) || (quad > 255)) return false;
}
return true;
}