sqldata/sqlpgapi.cpp
// Set the connection string in the API object
Set the connection string in the API object
Set the connection string in the API object
void SqlPgApi::SetConnectionString(const char *conn)
{
	if(conn == NULL)
		return;
	std::string db;
	SplitConnectionString(conn, _user, _pwd, db);
	const char *start = db.c_str();
	const char *semi = strchr(start, ':');
	const char *comma = strchr(start, ',');
	const char *end = (semi != NULL) ? semi :comma;
	if(end != NULL)
		_server.assign(start, (size_t)(end - start));
	else
		_server = start;
	if(semi != NULL)
	{
		if(comma != NULL && comma > semi)
			_port.assign(semi + 1, (size_t)(comma - semi - 1));
		else
			_port = semi + 1;
	}
	if(comma != NULL)
		_db = Str::SkipSpaces(comma + 1);
}
void SqlPgApi :: SetConnectionString ( const char * conn ) { if ( conn == NULL ) return ; std :: string db ; SplitConnectionString ( conn , _user , _pwd , db ) ; const char * start = db . c_str ( ) ; const char * semi = strchr ( start , ' ' ) ; const char * comma = strchr ( start , ' ' ) ; const char * end = ( semi != NULL ) ? semi : comma ; if ( end != NULL ) _server . assign ( start , ( size_t ) ( end - start ) ) ; else _server = start ; if ( semi != NULL ) { if ( comma != NULL && comma > semi ) _port . assign ( semi + 1 , ( size_t ) ( comma - semi - 1 ) ) ; else _port = semi + 1 ; } if ( comma != NULL ) _db = Str :: SkipSpaces ( comma + 1 ) ; }
Set the connection string in the API object
Set the connection string in the API object
// Find : and , that denote the server port and the database name // Define server name // Define port