From: J. T. Vermeulen <jtv@cistron-office.nl>
To: Carlos Moreno <moreno@mochima.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq++ and strings.
Date: Thu, 17 May 2001 14:59:34 +0200
Message-ID: <20010517145934.W14645@cistron.nl> (raw)
In-Reply-To: <3B03239A.E4685125@mochima.com>
References: <20010514151702.F14645@cistron.nl>
<3B03239A.E4685125@mochima.com>
On Wed, 16 May 2001, Carlos Moreno wrote:
> I wonder why all the string parameters and return values
> are expressed in the form of char * or const char * ?
Performance would be one reason, I'd say. const char * is easier to tune, and
of course the underlying library uses const char *'s anyway. Also of course,
a string is easily constructed from a const char * but the other way needs an
explicit method call.
OTOH I do think you have a point w.r.t. the obvious mistakes to make, and the
lack of help from the compiler in spotting them.
> Why not just changing all the parameters and return
> values to `const string &' and/or `string' ?
One possible tradeoff (and one I was leaning towards) is to take string
parameters (so passing const char [] will still work) but return const char *
in case you don't need the extras of a full C++ string. Unfortunately this
doesn't help with the comparison-with-string-constant problem you cite.
I guess this one boils down to how important performance is. One thing I'd
like to do about it in the upcoming version is to provide type-safe access to
the tuples. There'd still be a GetValue() returning const char *, but you
wouldn't need to use it the way you showed in your example, because you'd be
able to read it simply as a native bool.
Jeroen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jtv@cistron-office.nl, moreno@mochima.com
Subject: Re: libpq++ and strings.
In-Reply-To: <20010517145934.W14645@cistron.nl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox