Commit 5edab4f6 authored by Vinogradov Aleksei's avatar Vinogradov Aleksei Committed by Pavel Vainerman

Исправил ошибку в парсинге строки param

parent eebde190
......@@ -56,10 +56,10 @@ bool SQLiteInterface::connect( const std::string& param )
{
std::string dbfile;
std::string::size_type pos = param.find_first_of(":");
dbfile = param.substr(0, pos);
if( pos != std::string::npos )
{
dbfile = param.substr(0, pos);
std::string create_str = param.substr(pos + 1, std::string::npos);
if( create_str == "true" )
......
......@@ -2,34 +2,34 @@
// ------------------------------------------------------------------------------------------
bool DBNetInterface::connect( const std::string& param )
{
std::string host;
std::string user;
std::string pswd;
std::string dbname;
std::string host = "";
std::string user = "";
std::string pswd = "";
std::string dbname = "";
for(;;)
{
std::string::size_type pos = param.find_first_of("@");
std::string::size_type prev = 0;
user = param.substr(0, pos);
if( pos == std::string::npos )
break;
if( pos != std::string::npos )
user = param.substr(prev, pos);
prev = pos + 1;
std::string::size_type prev = pos + 1;
pos = param.find_first_of(":", prev);
if( pos != std::string::npos )
host = param.substr(prev, pos);
host = param.substr(prev, pos - prev);
if( pos == std::string::npos )
break;
prev = pos + 1;
pos = param.find_first_of(":", prev);
if( pos != std::string::npos )
pswd = param.substr(prev, pos);
pswd = param.substr(prev, pos - prev);
if( pos == std::string::npos )
break;
prev = pos + 1;
pos = param.find_first_of(":", prev);
if( pos != std::string::npos )
dbname = param.substr(prev, pos);
dbname = param.substr(prev, pos - prev);
break;
}
return nconnect( host, user, pswd, dbname );
}
//--------------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment