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 ) ...@@ -56,10 +56,10 @@ bool SQLiteInterface::connect( const std::string& param )
{ {
std::string dbfile; std::string dbfile;
std::string::size_type pos = param.find_first_of(":"); std::string::size_type pos = param.find_first_of(":");
dbfile = param.substr(0, pos);
if( pos != std::string::npos ) if( pos != std::string::npos )
{ {
dbfile = param.substr(0, pos);
std::string create_str = param.substr(pos + 1, std::string::npos); std::string create_str = param.substr(pos + 1, std::string::npos);
if( create_str == "true" ) if( create_str == "true" )
......
...@@ -2,34 +2,34 @@ ...@@ -2,34 +2,34 @@
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool DBNetInterface::connect( const std::string& param ) bool DBNetInterface::connect( const std::string& param )
{ {
std::string host; std::string host = "";
std::string user; std::string user = "";
std::string pswd; std::string pswd = "";
std::string dbname; std::string dbname = "";
std::string::size_type pos = param.find_first_of("@"); for(;;)
std::string::size_type prev = 0; {
std::string::size_type pos = param.find_first_of("@");
user = param.substr(0, pos);
if( pos == std::string::npos )
break;
if( pos != std::string::npos ) std::string::size_type prev = pos + 1;
user = param.substr(prev, pos); pos = param.find_first_of(":", prev);
host = param.substr(prev, pos - prev);
if( pos == std::string::npos )
break;
prev = pos + 1; prev = pos + 1;
pos = param.find_first_of(":", prev); pos = param.find_first_of(":", prev);
pswd = param.substr(prev, pos - prev);
if( pos != std::string::npos ) if( pos == std::string::npos )
host = param.substr(prev, pos); break;
prev = pos + 1;
pos = param.find_first_of(":", prev);
if( pos != std::string::npos )
pswd = param.substr(prev, pos);
prev = pos + 1;
pos = param.find_first_of(":", prev);
if( pos != std::string::npos )
dbname = param.substr(prev, pos);
prev = pos + 1;
pos = param.find_first_of(":", prev);
dbname = param.substr(prev, pos - prev);
break;
}
return nconnect( host, user, pswd, dbname ); 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