On Sat, September 8, 2007 00:09, Shannon Allen wrote:
> Another question on this. I am implementing an API for users where I
> try to hide all of the libpqxx back-end connection work. So they
> essentially either call load(stuff) and get(stuff) when wanting to
> push/get data from the database. For the purposes of setting up a
> lostream, what is the best way to implement this? Should I create an
> ilostream pointer and pass them the pointer? I tried doing this but, it
> seems you can't assign one ilostream object to another (perhaps for
> obvious reasons that are not obvious to me). And maybe I shouldn't even
> try to do this, but I was just trying to make the database interface as
> simple as possible for user applications. Thoughts??
You could allocate the stream on the free store and return an auto_ptr.
Few APIs use it, but returning an auto_ptr effectively says to the caller:
"here, it's on the heap, but you own it now" much like you can do in
garbage-collected languages.
> pqxx::ilostream & DBInterface::getBlobStream(int loId)
> {
> std::string me = "getBlob";
> pqxx::work w(*_conn,me);
> static pqxx::ilostream loStream(w, loId);
> return loStream; //really shouldn't return local var, but just
> testing for now
> }
>
> ....
>
> calling app
> ...
> pqxx::ilostream s = db->getBlob(conn, 137396407)); <== causes
> compiler error
The fact that the function is called getBlobStream(), not getBlob(), can't
be helping. :-)
Jeroen
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general