SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
parsetools Namespace Reference

A namespace for tools for manipulation and validation of user input strings. More...

Functions

std::vector< const std::string > splitString (const std::string &s, char delim)
 Splits a string around the matches of a given delimiter char. More...
 
bool isValidIP (const std::string &ip)
 Checks whether a given string represents a valid IP(v4). More...
 
bool isValidPort (const std::string &port)
 Checks whether a given string represents a valid user port number. More...
 

Detailed Description

A namespace for tools for manipulation and validation of user input strings.

Warning
The functions contained in this namespace are not designed for efficiency. If you intend to use them more frequently than for just a few user inputs, think twice.

Function Documentation

bool parsetools::isValidIP ( const std::string &  ip)

Checks whether a given string represents a valid IP(v4).

(Internally, inet_pton is called and checked for its return code.)

Parameters
ipThe string to be checked.
Returns
true, if the input string represents a valid IPv4 IP.
bool parsetools::isValidPort ( const std::string &  port)

Checks whether a given string represents a valid user port number.

The well-known ports (0-1023) are considered to be invalid, so valid port numbers range from 1024 to 65535.

Parameters
portThe string to be checked.
Returns
true, if the input string represents a number between 1024 and 65535.
std::vector< const std::string > parsetools::splitString ( const std::string &  s,
char  delim 
)

Splits a string around the matches of a given delimiter char.

Parameters
sThe string to be split.
delimThe delimiter used for splitting.
Returns
A vector containing the resulting substrings.