[Libpqxx-general] Support char & unsigned char types

Jeroen Vermeulen jtv at xs4all.nl
Thu Oct 22 17:41:16 UTC 2009


Maxime van Noppen wrote:

> I have a CHAR field in my database and it seems that pqxx doesn't
> support retrieving char fields (at least via the .as<char>() function).
> I checked the source and it seems that there are no string_traits for
> those two types. As it is quite straightforward I did the patch and it
> works well for me (see attached file).

The omission is deliberate: it's not clear whether you want a character, 
a very small signed int, or a very small unsigned int.  Convert to a 
less ambiguous type first, such as string or int (depending on what you 
want).


> However, I'm curious about why all this string_traits stuff is needed.
> Aren't C++ stringstreams sufficient for this ?

No.  These are to convert between native types and the string 
presentations of database-side types as used by postgres.


Jeroen


More information about the Libpqxx-general mailing list