/**
* Valid format:
* "hostname;port" or "hostname;port;topic"
*/
bool is_valid_connection_str(
char *connection_str,
std::string& url,
std::string& port)
{
std::string str(connection_str);
size_t n = std::count(str.begin(), str.end(), ';');
if (n < 1 || n > 2)
{
// Connection string format is invalid
return false;
}
std::istringstream iss(connection_str);
std::getline(iss, url, ';');
std::getline(iss, port, ';');
if (url == "" || port == "")
{
// Connection string is invalid.
// hostname or port is empty.
return false;
}
return true;
}