Kaydet (Commit) 8ad743ca authored tarafından Wol's avatar Wol Kaydeden (comit) Lionel Elie Mamane

pgsql-sdbc: conninfo keywords as static table instead of series of "else if"

New keywords can now simply be added to a static array rather than
adding a new "else if" blocks for each keyword.

Change-Id: Ib581b3e834a57e0dfa9d139bcb4ae7a0a52a5472
üst 13a04772
......@@ -482,44 +482,30 @@ static void properties2arrays( const Sequence< PropertyValue > & args,
// I.e. they are prefiltered to have only relevant ones?
// Else, at least support all keywords from
// http://www.postgresql.org/docs/9.0/interactive/libpq-connect.html
static const char* keyword_list[] = {
"password",
"user",
"port",
"dbname",
"connect_timeout",
"options",
"requiressl"
};
for( int i = 0; i < args.getLength() ; ++i )
{
bool append = true;
// TODO: rewrite this as a static table of keywords, and a loop over these keywords.
if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "password" ) ) )
{
keywords.push_back( "password", SAL_NO_ACQUIRE );
}
else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "user" ) ) )
{
keywords.push_back( "user", SAL_NO_ACQUIRE );
}
else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "port" ) ) )
{
keywords.push_back( "port", SAL_NO_ACQUIRE );
}
else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "dbname" ) ) )
{
keywords.push_back( "dbname", SAL_NO_ACQUIRE );
}
else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "connect_timeout" ) ) )
{
keywords.push_back( "connect_timeout", SAL_NO_ACQUIRE );
}
else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "options" ) ) )
{
keywords.push_back( "options", SAL_NO_ACQUIRE );
}
else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "requiressl" ) ) )
bool append = false;
for( size_t j = 0; j < SAL_N_ELEMENTS( keyword_list ); j++)
{
keywords.push_back( "requiressl", SAL_NO_ACQUIRE );
}
else
{
append = false;
// ignore for now
OSL_TRACE("sdbc-postgresql: unknown argument '%s'", OUStringToOString( args[i].Name, RTL_TEXTENCODING_UTF8 ).getStr() );
if( args[i].Name.equalsIgnoreAsciiCaseAscii( keyword_list[j] ))
{
keywords.push_back( keyword_list[j], SAL_NO_ACQUIRE );
append = true;
break;
}
}
if( append )
{
OUString value;
......@@ -527,6 +513,11 @@ static void properties2arrays( const Sequence< PropertyValue > & args,
char *v = strdup(OUStringToOString(value, enc).getStr());
values.push_back ( v );
}
else
{
// ignore for now
OSL_TRACE("sdbc-postgresql: unknown argument '%s'", OUStringToOString( args[i].Name, RTL_TEXTENCODING_UTF8 ).getStr() );
}
}
}
......
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