/**
* 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;
}

'C, C++' 카테고리의 다른 글

xlnt - XLSX 파일 다루기  (0) 2022.12.22
To install the MinGW-w64 toolchain  (0) 2022.10.28
VSCode + vcpkg  (0) 2021.10.19
Get DLL path at run time  (0) 2021.10.05
ticktock  (0) 2021.08.15

+ Recent posts