22 #include "pqxx/compiler-public.hxx" 23 #include "pqxx/compiler-internal-pre.hxx" 25 #include "pqxx/strconv" 53 field(
const tuple &T, tuple_size_type C)
throw ();
76 bool operator==(
const field &)
const;
82 {
return !operator==(rhs);}
89 const char *name()
const;
98 tuple_size_type
num()
const {
return col(); }
101 tuple_size_type table_column()
const;
114 const char *c_str()
const;
117 template<
typename T>
bool to(T &Obj)
const 119 const char *
const bytes = c_str();
120 if (!bytes[0] && is_null())
return false;
129 #ifdef PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION 130 template<>
bool to<PGSTD::string>(PGSTD::string &Obj)
const;
137 template<>
bool to<const char *>(
const char *&Obj)
const;
141 template<
typename T>
bool to(T &Obj,
const T &Default)
const 143 const bool NotNull = to(Obj);
144 if (!NotNull) Obj = Default;
152 template<
typename T> T
as(
const T &Default)
const 160 template<
typename T> T
as() const
163 const bool NotNull = to(Obj);
168 bool is_null()
const throw ();
169 size_type size()
const throw ();
175 size_t idx()
const throw () {
return m_row; }
176 tuple_size_type
col()
const throw () {
return m_col; }
188 inline bool field::to<PGSTD::string>(PGSTD::string &Obj)
const 190 const char *
const bytes = c_str();
191 if (!bytes[0] && is_null())
return false;
192 Obj = PGSTD::string(bytes, size());
203 inline bool field::to<const char *>(
const char *&Obj)
const 205 if (is_null())
return false;
211 template<
typename CHAR=
char,
typename TRAITS=PGSTD::
char_traits<CHAR> >
213 #ifdef PQXX_HAVE_STREAMBUF 214 public PGSTD::basic_streambuf<CHAR, TRAITS>
216 public PGSTD::streambuf
223 #ifdef PQXX_HAVE_STREAMBUF 224 typedef typename traits_type::pos_type
pos_type;
225 typedef typename traits_type::off_type
off_type;
239 #ifdef PQXX_HAVE_STREAMBUF 242 virtual int sync() {
return traits_type::eof(); }
245 virtual pos_type
seekoff(off_type, seekdir, openmode)
246 {
return traits_type::eof(); }
247 virtual pos_type
seekpos(pos_type, openmode) {
return traits_type::eof();}
248 virtual int_type
overflow(int_type) {
return traits_type::eof(); }
249 virtual int_type
underflow() {
return traits_type::eof(); }
252 const field &m_Field;
254 int_type initialize()
257 reinterpret_cast<char_type *
>(
const_cast<char *
>(m_Field.
c_str()));
258 this->setg(G, G, G + m_Field.
size());
259 return int_type(m_Field.
size());
273 template<
typename CHAR=
char,
typename TRAITS=PGSTD::
char_traits<CHAR> >
275 #ifdef PQXX_HAVE_STREAMBUF 276 public PGSTD::basic_istream<CHAR, TRAITS>
278 public PGSTD::istream
281 #ifdef PQXX_HAVE_STREAMBUF 282 typedef PGSTD::basic_istream<CHAR, TRAITS> super;
284 typedef PGSTD::istream super;
295 { super::init(&m_Buf); }
306 #include "pqxx/compiler-internal-post.hxx" TRAITS traits_type
Definition: field.hxx:289
Result set containing data returned by a query or command.
Definition: result.hxx:81
Reference to one row in a result.
Definition: tuple.hxx:52
bool operator!=(const field &rhs) const
Byte-by-byte comparison (all nulls are considered equal)
Definition: field.hxx:81
Reference to a field in a result set.
Definition: field.hxx:43
basic_fieldstream(const field &F)
Definition: field.hxx:294
basic_fieldstream< char > fieldstream
Definition: field.hxx:301
virtual pos_type seekoff(off_type, seekdir, openmode)
Definition: field.hxx:245
traits_type::off_type off_type
Definition: field.hxx:292
streampos pos_type
Definition: field.hxx:228
bool operator>>(T &Obj) const
Read value into Obj; or leave Obj untouched and return false if null.
Definition: field.hxx:126
field_streambuf(const field &F)
Definition: field.hxx:233
const result * home() const
Definition: field.hxx:174
std::ios::openmode openmode
Definition: field.hxx:230
bool to(T &Obj) const
Read value into Obj; or leave Obj untouched and return false if null.
Definition: field.hxx:117
std::ios::seekdir seekdir
Definition: field.hxx:231
virtual int sync()
Definition: field.hxx:242
size_t size_type
Definition: field.hxx:46
tuple_size_type col() const
Definition: field.hxx:176
void from_string(const field &F, T &Obj)
Convert a field's string contents to another type.
Definition: result.hxx:462
traits_type::int_type int_type
Definition: field.hxx:222
tuple_size_type m_col
Definition: field.hxx:178
bool to(T &Obj, const T &Default) const
Read value into Obj; or use Default & return false if null.
Definition: field.hxx:141
CHAR char_type
Definition: field.hxx:220
traits_type::pos_type pos_type
Definition: field.hxx:291
virtual int_type underflow()
Definition: field.hxx:249
T as() const
Return value as object of given type, or throw exception if null.
Definition: field.hxx:160
Input stream that gets its data from a result field.
Definition: field.hxx:274
Traits class for use in string conversions.
Definition: strconv.hxx:46
size_t idx() const
Definition: field.hxx:175
size_type size() const
Definition: field.cxx:86
streamoff off_type
Definition: field.hxx:227
virtual int_type overflow(int_type)
Definition: field.hxx:248
unsigned int tuple_size_type
Definition: field.hxx:34
CHAR char_type
Definition: field.hxx:288
T as(const T &Default) const
Return value as object of given type, or Default if null.
Definition: field.hxx:152
const char * c_str() const
Read as plain C string.
Definition: field.cxx:74
traits_type::int_type int_type
Definition: field.hxx:290
The home of all libpqxx classes, functions, templates, etc.
Definition: basic_connection.hxx:35
Definition: field.hxx:212
virtual pos_type seekpos(pos_type, openmode)
Definition: field.hxx:247
signed int tuple_difference_type
Definition: field.hxx:37
TRAITS traits_type
Definition: field.hxx:221
tuple_size_type num() const
Definition: field.hxx:98