Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On 16/04/13 19:25, Noel Grandin wrote:
On Tue, Apr 16, 2013 at 6:36 PM, Wols Lists <antlists@youngman.org.uk> wrote:

I need to force some type of type conversion - basically from "const
char *" to "const rtl::OUString&", I presume.

You can either call
   matchIgnoreAsciiCase( OUString ( p ) )
or
   matchIgnoreAsciiCase( p, strlen(p) )

This still refuses to work. I'm guessing the problem lies in my
declaration of the array...

   static const char* keyword_list[] = {
        "password",
        "user",
        "port",
        "dbname",
        "connect_timeout",
        "options",
        "requiressl"
    };

    for( int i = 0; i < args.getLength() ; ++i )
    {
        bool append = false;
//        for( int j = 0; j < (int) ( sizeof( keyword_list ) / sizeof(
char * )); j++)
        for( int j = 0; j < (int) SAL_N_ELEMENTS( keyword_list ); j++)
        {
            if( args[i].Name.matchIgnoreAsciiCase( OUString(
keyword_list[j]), strlen( keyword_list[j] )))
            {

/home/anthony/gitstuff/loffice/connectivity/source/drivers/postgresql/pq_connection.cxx:
In function ‘void pq_sdbc_driver::properties2arrays(const
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&,
const
com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter>&,
rtl_TextEncoding, pq_sdbc_driver::cstr_vector&,
pq_sdbc_driver::cstr_vector&)’:
/home/anthony/gitstuff/loffice/connectivity/source/drivers/postgresql/pq_connection.cxx:502:77:
error: invalid conversion from ‘const char*’ to ‘sal_Unicode {aka short
unsigned int}’ [-fpermissive]
/home/anthony/gitstuff/loffice/instdir/unxlngx6.pro/sdk/include/rtl/ustring.hxx:150:14:
error:   initializing argument 1 of
‘rtl::OUString::OUString(sal_Unicode)’ [-fpermissive]
make[1]: ***
[/home/anthony/gitstuff/loffice/workdir/unxlngx6.pro/CxxObject/connectivity/source/drivers/postgresql/pq_connection.o]
Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [build] Error 2

Bear in mind arrays of strings is funny, I'm guessing the test to make
sure the conversion is allowed is exploding.

If we look at the definition of RTL_CONSTASCII_STRINGPARAM

#define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
    ((sal_Int32)SAL_N_ELEMENTS(constAsciiStr)-1)

it's doing something weird with the first argument as a validity check.
I'm feeding it the second dimension of a string array. I wonder.

Is the following valid syntax, and would it fix the problem?

   static const char* keyword_list[] = {
        &("password"),
        &("user")
    }

Cheers,
Wol

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.