00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pqxx/libcompiler.h"
00020
00021 #ifdef PQXX_HAVE_IOS
00022 #include <ios>
00023 #endif
00024
00025 #include <stdexcept>
00026
00027 #include "pqxx/util"
00028
00029
00030
00031
00032
00033
00034 namespace pqxx
00035 {
00037
00055 class PQXX_LIBEXPORT result : private internal::PQAlloc<internal::pq::PGresult>
00056 {
00057 typedef internal::PQAlloc<internal::pq::PGresult> super;
00058 public:
00059 class const_iterator;
00060 class const_fielditerator;
00061 class const_reverse_fielditerator;
00062 class tuple;
00063 class field;
00064 typedef unsigned long size_type;
00065 typedef signed long difference_type;
00066 typedef tuple reference;
00067 typedef const_iterator pointer;
00068
00070
00081 class PQXX_LIBEXPORT tuple
00082 {
00083 public:
00084 typedef unsigned int size_type;
00085 typedef signed int difference_type;
00086 typedef const_fielditerator const_iterator;
00087 typedef field reference;
00088 typedef const_fielditerator pointer;
00089 typedef const_reverse_fielditerator const_reverse_iterator;
00090
00091 tuple(const result *r, result::size_type i) throw () :
00092 m_Home(r), m_Index(i) {}
00093 ~tuple() throw () {}
00094
00099 bool operator==(const tuple &) const throw ();
00100 bool operator!=(const tuple &rhs) const throw ()
00101 { return !operator==(rhs); }
00103
00104 const_iterator begin() const throw ()
00105 { return const_iterator(*this, 0); }
00106 const_iterator end() const throw ()
00107 { return const_iterator(*this, size()); }
00108
00113 reference front() const throw () { return field(*this, 0); }
00114 reference back() const throw () { return field(*this, size()-1); }
00115
00116 const_reverse_fielditerator rbegin() const;
00117 const_reverse_fielditerator rend() const;
00118
00119 reference operator[](size_type i) const throw ()
00120 { return field(*this, i); }
00121 reference operator[](int i) const throw ()
00122 { return operator[](size_type(i)); }
00123 reference operator[](const char[]) const;
00124 reference operator[](const PGSTD::string &s) const
00125 { return operator[](s.c_str()); }
00126 reference at(size_type) const throw (PGSTD::out_of_range);
00127 reference at(int i) const throw (PGSTD::out_of_range)
00128 { return at(size_type(i)); }
00129 reference at(const char[]) const;
00130 reference at(const PGSTD::string &s) const
00131 { return at(s.c_str()); }
00133
00134 size_type size() const throw () { return m_Home->columns(); }
00135
00136 void swap(tuple &) throw ();
00137
00138 result::size_type rownumber() const throw () { return m_Index; }
00139
00144
00145 size_type column_number(const PGSTD::string &ColName) const
00146 { return m_Home->column_number(ColName); }
00147
00149 size_type column_number(const char ColName[]) const
00150 { return m_Home->column_number(ColName); }
00151
00153 oid column_type(size_type ColNum) const
00154 { return m_Home->column_type(ColNum); }
00155
00157 oid column_type(int ColNum) const
00158 { return column_type(size_type(ColNum)); }
00159
00161 oid column_type(const PGSTD::string &ColName) const
00162 { return column_type(column_number(ColName)); }
00163
00165 oid column_type(const char ColName[]) const
00166 { return column_type(column_number(ColName)); }
00167
00169
00176 oid column_table(size_type ColNum) const
00177 { return m_Home->column_table(ColNum); }
00179
00186 oid column_table(int ColNum) const
00187 { return column_table(size_type(ColNum)); }
00189
00196 oid column_table(const PGSTD::string &ColName) const
00197 { return column_table(column_number(ColName)); }
00199
00200 result::size_type num() const { return rownumber(); }
00201
00202
00203 #ifdef PQXX_DEPRECATED_HEADERS
00204
00208
00209 result::size_type Row() const { return rownumber(); }
00210
00212 size_type ColumnNumber(const PGSTD::string &ColName) const
00213 { return column_number(ColName); }
00214
00216 size_type ColumnNumber(const char ColName[]) const
00217 { return column_number(ColName); }
00219 #endif
00220
00221 protected:
00222 friend class field;
00223 const result *m_Home;
00224 result::size_type m_Index;
00225
00226
00227 tuple();
00228 };
00229
00231
00234 class PQXX_LIBEXPORT field
00235 {
00236 public:
00237 typedef size_t size_type;
00238
00240
00244 field(const tuple &T, tuple::size_type C) throw () :
00245 m_tup(T), m_col(C) {}
00246
00251
00252
00268 bool operator==(const field &) const;
00269
00271
00273 bool operator!=(const field &rhs) const {return !operator==(rhs);}
00275
00280
00281 const char *name() const { return home()->column_name(col()); }
00282
00284 oid type() const { return home()->column_type(col()); }
00285
00287
00294 oid table() const { return home()->column_table(col()); }
00295
00296 tuple::size_type num() const { return col(); }
00298
00303
00304
00309 const char *c_str() const { return home()->GetValue(idx(),col()); }
00310
00312 template<typename T> bool to(T &Obj) const
00313 {
00314 if (is_null()) return false;
00315 try
00316 {
00317 from_string(c_str(), Obj);
00318 }
00319 catch (const PGSTD::exception &e)
00320 {
00321 throw PGSTD::domain_error("Error reading field " +
00322 PGSTD::string(name()) + ": " +
00323 e.what());
00324 }
00325 return true;
00326 }
00327
00329 template<typename T> bool operator>>(T &Obj) const
00330 { return to(Obj); }
00331
00332 #ifdef PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
00333
00334 template<> bool to<PGSTD::string>(PGSTD::string &Obj) const;
00335
00337
00340 template<> bool to<const char *>(const char *&Obj) const;
00341 #endif
00342
00344 template<typename T> bool to(T &Obj, const T &Default) const
00345 {
00346 const bool NotNull = to(Obj);
00347 if (!NotNull) Obj = Default;
00348 return NotNull;
00349 }
00350
00352
00355 template<typename T> T as(const T &Default) const
00356 {
00357 T Obj;
00358 to(Obj, Default);
00359 return Obj;
00360 }
00361
00363 template<typename T> T as() const
00364 {
00365 T Obj;
00366 const bool NotNull = to(Obj);
00367 if (!NotNull) throw PGSTD::domain_error("Attempt to read null field");
00368 return Obj;
00369 }
00370
00371 bool is_null() const { return home()->GetIsNull(idx(), col()); }
00372 size_type size() const throw ()
00373 { return home()->GetLength(idx(),col()); }
00375
00376 #ifdef PQXX_DEPRECATED_HEADERS
00377
00378 const char *Name() const {return name();}
00379 #endif
00380
00381 private:
00382 const result *home() const throw () { return m_tup.m_Home; }
00383 result::size_type idx() const throw () { return m_tup.m_Index; }
00384
00385 protected:
00386 const tuple::size_type col() const throw () { return m_col; }
00387 tuple m_tup;
00388 tuple::size_type m_col;
00389 };
00390
00391 typedef PGSTD::iterator<PGSTD::random_access_iterator_tag,
00392 const tuple,
00393 result::difference_type,
00394 const_iterator,
00395 tuple> const_iterator_base;
00396
00398
00402 class PQXX_LIBEXPORT const_iterator :
00403 public const_iterator_base,
00404 public tuple
00405 {
00406 public:
00407 typedef const tuple *pointer;
00408 typedef tuple reference;
00409 typedef result::size_type size_type;
00410 typedef result::difference_type difference_type;
00411
00412 const_iterator() throw () : tuple(0,0) {}
00413 const_iterator(const tuple &t) throw () : tuple(t) {}
00414
00430 pointer operator->() const { return this; }
00431 reference operator*() const { return tuple(*this); }
00433
00438 const_iterator operator++(int);
00439 const_iterator &operator++() { ++m_Index; return *this; }
00440 const_iterator operator--(int);
00441 const_iterator &operator--() { --m_Index; return *this; }
00442
00443 const_iterator &operator+=(difference_type i)
00444 { m_Index+=i; return *this; }
00445 const_iterator &operator-=(difference_type i)
00446 { m_Index-=i; return *this; }
00448
00453 bool operator==(const const_iterator &i) const
00454 {return m_Index==i.m_Index;}
00455 bool operator!=(const const_iterator &i) const
00456 {return m_Index!=i.m_Index;}
00457 bool operator<(const const_iterator &i) const
00458 {return m_Index<i.m_Index;}
00459 bool operator<=(const const_iterator &i) const
00460 {return m_Index<=i.m_Index;}
00461 bool operator>(const const_iterator &i) const
00462 {return m_Index>i.m_Index;}
00463 bool operator>=(const const_iterator &i) const
00464 {return m_Index>=i.m_Index;}
00466
00471 inline const_iterator operator+(difference_type) const;
00472 friend const_iterator
00473 operator+(difference_type, const_iterator);
00474 inline const_iterator operator-(difference_type) const;
00475 inline difference_type operator-(const_iterator) const;
00477
00478 private:
00479 friend class pqxx::result;
00480 const_iterator(const pqxx::result *r, result::size_type i) throw () :
00481 tuple(r, i) {}
00482 };
00483
00484 class PQXX_LIBEXPORT const_reverse_iterator : private const_iterator
00485 {
00486 public:
00487 typedef pqxx::result::const_iterator super;
00488 typedef pqxx::result::const_iterator iterator_type;
00489 using iterator_type::iterator_category;
00490 using iterator_type::difference_type;
00491 using iterator_type::pointer;
00492 #ifndef _MSC_VER
00493 using iterator_type::value_type;
00494 using iterator_type::reference;
00495 #else
00496
00497 typedef const tuple &reference;
00498 typedef tuple value_type;
00499 #endif
00500
00501 const_reverse_iterator(const const_reverse_iterator &rhs) :
00502 const_iterator(rhs) {}
00503 explicit const_reverse_iterator(const const_iterator &rhs) :
00504 const_iterator(rhs) { super::operator--(); }
00505
00506 iterator_type base() const throw ();
00507
00512 using const_iterator::operator->;
00513 using const_iterator::operator*;
00515
00520 const_reverse_iterator &operator=(const const_reverse_iterator &r)
00521 { iterator_type::operator=(r); return *this; }
00522 const_reverse_iterator operator++()
00523 { iterator_type::operator--(); return *this; }
00524 const_reverse_iterator operator++(int);
00525 const_reverse_iterator &operator--()
00526 { iterator_type::operator++(); return *this; }
00527 const_reverse_iterator operator--(int);
00528 const_reverse_iterator &operator+=(difference_type i)
00529 { iterator_type::operator-=(i); return *this; }
00530 const_reverse_iterator &operator-=(difference_type i)
00531 { iterator_type::operator+=(i); return *this; }
00533
00538 const_reverse_iterator operator+(difference_type i) const
00539 { return const_reverse_iterator(base()-i); }
00540 const_reverse_iterator operator-(difference_type i)
00541 { return const_reverse_iterator(base()+i); }
00542 difference_type operator-(const const_reverse_iterator &rhs) const
00543 { return rhs.const_iterator::operator-(*this); }
00545
00550 bool operator==(const const_reverse_iterator &rhs) const throw ()
00551 { return iterator_type::operator==(rhs); }
00552 bool operator!=(const const_reverse_iterator &rhs) const throw ()
00553 { return !operator==(rhs); }
00554
00555 bool operator<(const const_reverse_iterator &rhs) const
00556 { return iterator_type::operator>(rhs); }
00557 bool operator<=(const const_reverse_iterator &rhs) const
00558 { return iterator_type::operator>=(rhs); }
00559 bool operator>(const const_reverse_iterator &rhs) const
00560 { return iterator_type::operator<(rhs); }
00561 bool operator>=(const const_reverse_iterator &rhs) const
00562 { return iterator_type::operator<=(rhs); }
00564 };
00565
00566 class PQXX_LIBEXPORT const_fielditerator :
00567 public PGSTD::iterator<PGSTD::random_access_iterator_tag,
00568 const field,
00569 tuple::size_type>,
00570 public field
00571 {
00572 typedef PGSTD::iterator<PGSTD::random_access_iterator_tag,
00573 const field,
00574 tuple::size_type> it;
00575 public:
00576 using it::pointer;
00577 typedef tuple::size_type size_type;
00578 typedef tuple::difference_type difference_type;
00579 typedef field reference;
00580
00581 const_fielditerator(const tuple &T, tuple::size_type C) throw () :
00582 field(T, C) {}
00583 const_fielditerator(const field &F) throw () : field(F) {}
00584
00589 pointer operator->() const { return this; }
00590 reference operator*() const { return field(*this); }
00592
00597 const_fielditerator operator++(int);
00598 const_fielditerator &operator++() { ++m_col; return *this; }
00599 const_fielditerator operator--(int);
00600 const_fielditerator &operator--() { --m_col; return *this; }
00601
00602 const_fielditerator &operator+=(difference_type i)
00603 { m_col+=i; return *this; }
00604 const_fielditerator &operator-=(difference_type i)
00605 { m_col-=i; return *this; }
00607
00612 bool operator==(const const_fielditerator &i) const
00613 {return col()==i.col();}
00614 bool operator!=(const const_fielditerator &i) const
00615 {return col()!=i.col();}
00616 bool operator<(const const_fielditerator &i) const
00617 {return col()<i.col();}
00618 bool operator<=(const const_fielditerator &i) const
00619 {return col()<=i.col();}
00620 bool operator>(const const_fielditerator &i) const
00621 {return col()>i.col();}
00622 bool operator>=(const const_fielditerator &i) const
00623 {return col()>=i.col();}
00625
00630 inline const_fielditerator operator+(difference_type) const;
00631
00632 friend const_fielditerator operator+(difference_type,
00633 const_fielditerator);
00634
00635 inline const_fielditerator operator-(difference_type) const;
00636 inline difference_type operator-(const_fielditerator) const;
00638 };
00639
00640 class PQXX_LIBEXPORT const_reverse_fielditerator : private const_fielditerator
00641 {
00642 public:
00643 typedef const_fielditerator super;
00644 typedef const_fielditerator iterator_type;
00645 using iterator_type::iterator_category;
00646 using iterator_type::difference_type;
00647 using iterator_type::pointer;
00648 #ifndef _MSC_VER
00649 using iterator_type::value_type;
00650 using iterator_type::reference;
00651 #else
00652
00653 typedef field value_type;
00654 typedef const field &reference;
00655 #endif
00656
00657 const_reverse_fielditerator(const const_reverse_fielditerator &r) :
00658 const_fielditerator(r) {}
00659 explicit
00660 const_reverse_fielditerator(const super &rhs) throw() :
00661 const_fielditerator(rhs) { super::operator--(); }
00662
00663 iterator_type base() const throw ();
00664
00669 using iterator_type::operator->;
00670 using iterator_type::operator*;
00672
00677 const_reverse_fielditerator &
00678 operator=(const const_reverse_fielditerator &r)
00679 { iterator_type::operator=(r); return *this; }
00680 const_reverse_fielditerator operator++()
00681 { iterator_type::operator--(); return *this; }
00682 const_reverse_fielditerator operator++(int);
00683 const_reverse_fielditerator &operator--()
00684 { iterator_type::operator++(); return *this; }
00685 const_reverse_fielditerator operator--(int);
00686 const_reverse_fielditerator &operator+=(difference_type i)
00687 { iterator_type::operator-=(i); return *this; }
00688 const_reverse_fielditerator &operator-=(difference_type i)
00689 { iterator_type::operator+=(i); return *this; }
00691
00696 const_reverse_fielditerator operator+(difference_type i) const
00697 { return const_reverse_fielditerator(base()-i); }
00698 const_reverse_fielditerator operator-(difference_type i)
00699 { return const_reverse_fielditerator(base()+i); }
00700 difference_type
00701 operator-(const const_reverse_fielditerator &rhs) const
00702 { return rhs.const_fielditerator::operator-(*this); }
00704
00709 bool
00710 operator==(const const_reverse_fielditerator &rhs) const throw ()
00711 { return iterator_type::operator==(rhs); }
00712 bool
00713 operator!=(const const_reverse_fielditerator &rhs) const throw ()
00714 { return !operator==(rhs); }
00715
00716 bool operator<(const const_reverse_fielditerator &rhs) const
00717 { return iterator_type::operator>(rhs); }
00718 bool operator<=(const const_reverse_fielditerator &rhs) const
00719 { return iterator_type::operator>=(rhs); }
00720 bool operator>(const const_reverse_fielditerator &rhs) const
00721 { return iterator_type::operator<(rhs); }
00722 bool operator>=(const const_reverse_fielditerator &rhs) const
00723 { return iterator_type::operator<=(rhs); }
00725 };
00726
00727
00728 result() throw () : super() {}
00729 result(const result &rhs) throw () : super(rhs) {}
00730
00731 result &operator=(const result &rhs) throw ()
00732 { super::operator=(rhs); return *this; }
00733
00738 bool operator==(const result &) const throw ();
00739 bool operator!=(const result &rhs) const throw ()
00740 { return !operator==(rhs); }
00742
00743 const_reverse_iterator rbegin() const
00744 { return const_reverse_iterator(end()); }
00745 const_reverse_iterator rend() const
00746 { return const_reverse_iterator(begin()); }
00747
00748 const_iterator begin() const throw ()
00749 { return const_iterator(this, 0); }
00750 inline const_iterator end() const throw ();
00751
00752 reference front() const throw () { return tuple(this,0); }
00753 reference back() const throw () {return tuple(this,size()-1);}
00754
00755 size_type size() const throw ();
00756 bool empty() const throw ();
00757 size_type capacity() const throw () { return size(); }
00758
00759 void swap(result &) throw ();
00760
00761 const tuple operator[](size_type i) const throw ()
00762 { return tuple(this, i); }
00763 const tuple at(size_type) const throw (PGSTD::out_of_range);
00764
00765 using super::clear;
00766
00771
00772 tuple::size_type columns() const throw ();
00773
00775 tuple::size_type column_number(const char ColName[]) const;
00776
00778 tuple::size_type column_number(const PGSTD::string &Name) const
00779 {return column_number(Name.c_str());}
00780
00782 const char *column_name(tuple::size_type Number) const;
00783
00785 oid column_type(tuple::size_type ColNum) const;
00787 oid column_type(int ColNum) const
00788 { return column_type(tuple::size_type(ColNum)); }
00789
00791 oid column_type(const PGSTD::string &ColName) const
00792 { return column_type(column_number(ColName)); }
00793
00795 oid column_type(const char ColName[]) const
00796 { return column_type(column_number(ColName)); }
00797
00799
00806 oid column_table(tuple::size_type ColNum) const;
00807
00809
00816 oid column_table(int ColNum) const
00817 { return column_table(tuple::size_type(ColNum)); }
00818
00820
00827 oid column_table(const PGSTD::string &ColName) const
00828 { return column_table(column_number(ColName)); }
00830
00832
00835 oid inserted_oid() const;
00836
00837
00839
00842 size_type affected_rows() const;
00843
00844
00845 #ifdef PQXX_DEPRECATED_HEADERS
00846
00850
00851 typedef tuple Tuple;
00853 typedef field Field;
00855 oid InsertedOid() const { return inserted_oid(); }
00857 size_type AffectedRows() const { return affected_rows(); }
00859 tuple::size_type Columns() const { return columns(); }
00861 tuple::size_type ColumnNumber(const char Name[]) const
00862 {return column_number(Name);}
00864 tuple::size_type ColumnNumber(const PGSTD::string &Name) const
00865 {return column_number(Name);}
00867 const char *ColumnName(tuple::size_type Number) const
00868 {return column_name(Number);}
00870 #endif
00871
00872
00873 private:
00874 friend class pqxx::result::field;
00875 const char *GetValue(size_type Row, tuple::size_type Col) const;
00876 bool GetIsNull(size_type Row, tuple::size_type Col) const;
00877 field::size_type GetLength(size_type, tuple::size_type) const;
00878
00879 friend class connection_base;
00880 friend class pipeline;
00881 explicit result(internal::pq::PGresult *rhs) throw () : super(rhs) {}
00882 result &operator=(internal::pq::PGresult *rhs) throw ()
00883 { super::operator=(rhs); return *this; }
00884 bool operator!() const throw () { return !c_ptr(); }
00885 operator bool() const throw () { return c_ptr() != 0; }
00886 void PQXX_PRIVATE CheckStatus(const PGSTD::string &Query) const;
00887 void PQXX_PRIVATE CheckStatus(const char Query[]) const;
00888 int PQXX_PRIVATE errorposition() const throw ();
00889 PGSTD::string PQXX_PRIVATE StatusError() const;
00890
00891 friend class Cursor;
00892 friend class cursor_base;
00893 const char *CmdStatus() const throw ();
00894 };
00895
00896
00898
00917 template<typename STREAM>
00918 inline STREAM &operator<<(STREAM &S, const pqxx::result::field &F)
00919 {
00920 S.write(F.c_str(), F.size());
00921 return S;
00922 }
00923
00924
00926 template<typename T>
00927 inline void from_string(const result::field &F, T &Obj)
00928 { from_string(F.c_str(), Obj); }
00929
00931 template<>
00932 inline PGSTD::string to_string(const result::field &Obj)
00933 { return to_string(Obj.c_str()); }
00934
00935
00937 template<>
00938 inline bool result::field::to<PGSTD::string>(PGSTD::string &Obj) const
00939 {
00940 if (is_null()) return false;
00941 Obj = c_str();
00942 return true;
00943 }
00944
00946
00951 template<>
00952 inline bool result::field::to<const char *>(const char *&Obj) const
00953 {
00954 if (is_null()) return false;
00955 Obj = c_str();
00956 return true;
00957 }
00958
00959
00960 inline result::tuple::const_reverse_iterator result::tuple::rbegin() const
00961 { return const_reverse_fielditerator(end()); }
00962 inline result::tuple::const_reverse_iterator result::tuple::rend() const
00963 { return const_reverse_fielditerator(begin()); }
00964
00965 inline result::const_iterator
00966 result::const_iterator::operator+(difference_type o) const
00967 { return const_iterator(m_Home, m_Index + o); }
00968
00969 inline result::const_iterator
00970 operator+(result::const_iterator::difference_type o, result::const_iterator i)
00971 { return i + o; }
00972
00973 inline result::const_iterator
00974 result::const_iterator::operator-(difference_type o) const
00975 { return const_iterator(m_Home, m_Index - o); }
00976
00977 inline result::const_iterator::difference_type
00978 result::const_iterator::operator-(const_iterator i) const
00979 { return num()-i.num(); }
00980
00981 inline result::const_iterator result::end() const throw ()
00982 { return const_iterator(this, size()); }
00983
00984
00985 inline result::const_reverse_iterator
00986 operator+(result::const_reverse_iterator::difference_type n,
00987 const result::const_reverse_iterator &i)
00988 { return result::const_reverse_iterator(i.base() - n); }
00989
00990 inline result::const_fielditerator
00991 result::const_fielditerator::operator+(difference_type o) const
00992 { return const_fielditerator(m_tup, col() + o); }
00993
00994 inline result::const_fielditerator
00995 operator+(result::const_fielditerator::difference_type o,
00996 result::const_fielditerator i)
00997 { return i + o; }
00998
00999 inline result::const_fielditerator
01000 result::const_fielditerator::operator-(difference_type o) const
01001 { return const_fielditerator(m_tup, col() - o); }
01002
01003 inline result::const_fielditerator::difference_type
01004 result::const_fielditerator::operator-(const_fielditerator i) const
01005 { return num()-i.num(); }
01006
01007
01008 template<typename CHAR=char, typename TRAITS=PGSTD::char_traits<CHAR> >
01009 class field_streambuf :
01010 #ifdef PQXX_HAVE_STREAMBUF
01011 public PGSTD::basic_streambuf<CHAR, TRAITS>
01012 #else
01013 public PGSTD::streambuf
01014 #endif
01015 {
01016 public:
01017 typedef CHAR char_type;
01018 typedef TRAITS traits_type;
01019 typedef typename traits_type::int_type int_type;
01020 #ifdef PQXX_HAVE_STREAMBUF
01021 typedef typename traits_type::pos_type pos_type;
01022 typedef typename traits_type::off_type off_type;
01023 #else
01024 typedef streamoff off_type;
01025 typedef streampos pos_type;
01026 #endif
01027 typedef PGSTD::ios::openmode openmode;
01028 typedef PGSTD::ios::seekdir seekdir;
01029
01030 explicit field_streambuf(const result::field &F) :
01031 m_Field(F)
01032 {
01033 initialize();
01034 }
01035
01036 #ifdef PQXX_HAVE_STREAMBUF
01037 protected:
01038 #endif
01039 virtual int sync() { return traits_type::eof(); }
01040
01041 protected:
01042 virtual pos_type seekoff(off_type, seekdir, openmode)
01043 { return traits_type::eof(); }
01044 virtual pos_type seekpos(pos_type, openmode) {return traits_type::eof();}
01045 virtual int_type overflow(int_type) { return traits_type::eof(); }
01046 virtual int_type underflow() { return traits_type::eof(); }
01047
01048 private:
01049 const result::field &m_Field;
01050
01051 int_type initialize()
01052 {
01053 char_type *G =
01054 reinterpret_cast<char_type *>(const_cast<char *>(m_Field.c_str()));
01055 setg(G, G, G + m_Field.size());
01056 return m_Field.size();
01057 }
01058 };
01059
01060
01062
01070 template<typename CHAR=char, typename TRAITS=PGSTD::char_traits<CHAR> >
01071 class basic_fieldstream :
01072 #ifdef PQXX_HAVE_STREAMBUF
01073 public PGSTD::basic_istream<CHAR, TRAITS>
01074 #else
01075 public PGSTD::istream
01076 #endif
01077 {
01078 #ifdef PQXX_HAVE_STREAMBUF
01079 typedef PGSTD::basic_istream<CHAR, TRAITS> super;
01080 #else
01081 typedef PGSTD::istream super;
01082 #endif
01083
01084 public:
01085 typedef CHAR char_type;
01086 typedef TRAITS traits_type;
01087 typedef typename traits_type::int_type int_type;
01088 typedef typename traits_type::pos_type pos_type;
01089 typedef typename traits_type::off_type off_type;
01090
01091 basic_fieldstream(const result::field &F) : super(0), m_Buf(F)
01092 { super::init(&m_Buf); }
01093
01094 private:
01095 field_streambuf<CHAR, TRAITS> m_Buf;
01096 };
01097
01098 typedef basic_fieldstream<char> fieldstream;
01099
01100 }
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117