18 #ifndef PQXX_H_STRINGCONV
19 #define PQXX_H_STRINGCONV
21 #include "pqxx/compiler-public.hxx"
52 const PGSTD::string &type);
55 #define PQXX_DECLARE_STRING_TRAITS_SPECIALIZATION(T) \
56 template<> struct PQXX_LIBEXPORT string_traits<T> \
58 typedef T subject_type; \
59 static const char *name() { return #T; } \
60 static bool has_null() { return false; } \
61 static bool is_null(T) { return false; } \
63 { internal::throw_null_conversion(name()); return subject_type(); } \
64 static void from_string(const char Str[], T &Obj); \
65 static PGSTD::string to_string(T Obj); \
76 #ifdef PQXX_HAVE_LONG_LONG
83 #ifdef PQXX_HAVE_LONG_DOUBLE
87 #undef PQXX_DECLARE_STRING_TRAITS_SPECIALIZATION
92 static const char *
name() {
return "const char *"; }
94 static bool is_null(
const char *t) {
return !t; }
95 static const char *
null() {
return NULL; }
96 static void from_string(
const char Str[],
const char *&Obj) { Obj = Str; }
97 static PGSTD::string
to_string(
const char *Obj) {
return Obj; }
103 static const char *
name() {
return "char *"; }
105 static bool is_null(
const char *t) {
return !t; }
106 static const char *
null() {
return NULL; }
111 static PGSTD::string
to_string(
char *Obj) {
return Obj; }
117 static const char *
name() {
return "char[]"; }
119 static bool is_null(
const char t[]) {
return !t; }
120 static const char *
null() {
return NULL; }
121 static PGSTD::string
to_string(
const char Obj[]) {
return Obj; }
130 static const char *
name() {
return "char[]"; }
132 static bool is_null(
const char t[]) {
return !t; }
133 static const char *
null() {
return NULL; }
134 static PGSTD::string
to_string(
const char Obj[]) {
return Obj; }
140 static const char *
name() {
return "string"; }
142 static bool is_null(
const PGSTD::string &) {
return false; }
143 static PGSTD::string null()
145 static void from_string(
const char Str[], PGSTD::string &Obj) { Obj=Str; }
146 static PGSTD::string
to_string(
const PGSTD::string &Obj) {
return Obj; }
151 static const char *
name() {
return "const string"; }
153 static bool is_null(
const PGSTD::string &) {
return false; }
154 static const PGSTD::string null()
156 static const PGSTD::string
to_string(
const PGSTD::string &Obj) {
return Obj; }
161 static const char *
name() {
return "stringstream"; }
163 static bool is_null(
const PGSTD::stringstream &) {
return false; }
164 static PGSTD::stringstream null()
170 static void from_string(
const char Str[], PGSTD::stringstream &Obj)
171 { Obj.clear(); Obj << Str; }
172 static PGSTD::string
to_string(
const PGSTD::stringstream &Obj)
173 {
return Obj.str(); }
196 throw PGSTD::runtime_error(
"Attempt to read NULL string");
208 template<
typename T>
inline void from_string(
const char Str[], T &Obj,
size_t)
214 inline void from_string<PGSTD::string>(
const char Str[],
219 throw PGSTD::runtime_error(
"Attempt to read NULL string");
220 Obj.assign(Str, len);
231 template<>
inline void
249 template<
typename T>
inline PGSTD::string
to_string(
const T &Obj)