On Saturday, 20 January 2018 at 04:54:47 UTC, Adam D. Ruppe wrote:
Same as above. The general pattern is:
C_Type[] name = new C_Type[](requested_size);
// pass as `name.ptr`. This becomes a C_Type*
Thanks, Adam. Perhaps something like this ought to make its way
into the "D for C Programmers"
On Saturday, 20 January 2018 at 04:09:01 UTC, Joe wrote:
extern(C) char * [2] pvs;
foreach (i, val; paramValues)
pvs[i] = cast(char *)toStringz(val);
And then use "cast(const char **)pvs" for the paramValues
argument.
A slight improvement here that removes the need for any casts
On Saturday, 13 January 2018 at 05:28:17 UTC, Joe wrote:
Going beyond the connection, there are various other libpq
functions that use a similar pattern of values passed using
multiple parallel C arrays, e.g.,
PGresult *PQexecParams(PGconn *conn,
const char *command,
On Saturday, 13 January 2018 at 17:58:14 UTC, Joe wrote:
...ddb. The latter perhaps has the distinction that it doesn't
use libpq, but rather implements the Postgres FE/BE protocol.
That's a bit *too* native for my taste. It means the library
maintainer has to keep up with changes to the
On Monday, 15 January 2018 at 02:28:29 UTC, Matthias Klumpp wrote:
In any case, please don't start another Postgres library and
consider contributing to one of the existing ones, so that we
maybe have one really awesome, 100% complete library at some
point.
If, on the other hand, your goal
On Saturday, 13 January 2018 at 17:58:14 UTC, Joe wrote:
On Saturday, 13 January 2018 at 10:10:41 UTC, Jacob Carlborg
wrote:
There's a native D library, ddb [1], for connecting to
Postgres. Then you don't have to worry about null-terminated
strings.
There are several D libraries that I would
On Saturday, 13 January 2018 at 10:10:41 UTC, Jacob Carlborg
wrote:
There's a native D library, ddb [1], for connecting to
Postgres. Then you don't have to worry about null-terminated
strings.
There are several D libraries that I would consider "native":
derelict-pq, dpq, dpq2 and ddb. The
On 2018-01-13 05:17, Joe wrote:
I'm trying to learn how to use D to connect (and send queries) to
Postgres, i.e., libpq in C.
So my question is: is there an easier or better way of passing two
arrays of C null-terminated strings to an extern(C) function?
There's a native D library, ddb [1],
Going beyond the connection, there are various other libpq
functions that use a similar pattern of values passed using
multiple parallel C arrays, e.g.,
PGresult *PQexecParams(PGconn *conn,
const char *command,
int nParams,
On Saturday, 13 January 2018 at 04:26:06 UTC, Adam D. Ruppe wrote:
If and only if the values are known at compile time, you can do:
const char** keywords = ["hostaddr".ptr, "port".ptr,
"dbname".ptr, null].ptr;
or even do it inline:
PQconnectdbParams(["hostaddr".ptr, "port".ptr,
On Saturday, 13 January 2018 at 04:17:02 UTC, Joe wrote:
It only compiled after I removed the second 'const' in the
first and second arguments.
Yeah, D's const applies down the chain automatically, so you
don't write it twice there.
string[] keywords = ["hostaddr", "port", "dbname"];
11 matches
Mail list logo