19 #ifndef PQXX_H_LARGEOBJECT 
   20 #define PQXX_H_LARGEOBJECT 
   22 #include "pqxx/compiler-public.hxx" 
   23 #include "pqxx/compiler-internal-pre.hxx" 
   25 #ifdef PQXX_HAVE_STREAMBUF 
   28 #include <streambuf.h> 
   31 #include "pqxx/dbtransaction" 
   37 class largeobjectaccess;
 
   86   oid 
id() 
const throw () { 
return m_ID; }                              
 
   99           { 
return m_ID == other.m_ID; }
 
  103           { 
return m_ID != other.m_ID; }
 
  107           { 
return m_ID <= other.m_ID; }
 
  111           { 
return m_ID >= other.m_ID; }
 
  115           { 
return m_ID < other.m_ID; }
 
  119           { 
return m_ID > other.m_ID; }
 
  127   void to_file(
dbtransaction &T, 
const PGSTD::string &File) 
const;      
 
  137   static internal::pq::PGconn * PQXX_PURE RawConnection(
const dbtransaction &T);
 
  139   PGSTD::string Reason(
int err) 
const;
 
  201                     openmode mode = PGSTD::ios::in | PGSTD::ios::out);  
 
  210                     const PGSTD::string &File,
 
  212                         PGSTD::ios::in | PGSTD::ios::out);              
 
  226   void to_file(
const PGSTD::string &File) 
const                          
  229 #ifdef PQXX_BROKEN_USING_DECL 
  250   void write(
const char Buf[], size_type Len);                          
 
  256   void write(
const PGSTD::string &Buf)                                  
 
  266   size_type read(
char Buf[], size_type Len);                            
 
  272   size_type seek(size_type dest, seekdir dir);                          
 
  278   size_type tell() 
const;                                               
 
  299   pos_type cseek(off_type dest, seekdir dir) 
throw ();                  
 
  308   off_type cwrite(
const char Buf[], size_type Len) 
throw ();            
 
  317   off_type cread(
char Buf[], size_type Len) 
throw ();                   
 
  324   pos_type ctell() 
const throw ();                                      
 
  332   void process_notice(const PGSTD::
string &) throw ();                  
 
  345   PGSTD::
string PQXX_PRIVATE Reason(
int err) const;
 
  346   internal::pq::PGconn *RawConnection()
 const 
  349   void open(openmode mode);
 
  350   void close() throw ();
 
  352   dbtransaction &m_Trans;
 
  357   largeobjectaccess(const largeobjectaccess &);
 
  358   largeobjectaccess operator=(const largeobjectaccess &);
 
  371 template<typename CHAR=
char, typename TRAITS=PGSTD::char_traits<CHAR> >
 
  373 #ifdef PQXX_HAVE_STREAMBUF 
  374     public PGSTD::basic_streambuf<CHAR, TRAITS>
 
  376     public PGSTD::streambuf
 
  379   typedef long size_type;
 
  384 #ifdef PQXX_HAVE_STREAMBUF 
  385   typedef typename traits_type::pos_type 
pos_type;
 
  386   typedef typename traits_type::off_type 
off_type;
 
  396                         openmode mode = PGSTD::ios::in | PGSTD::ios::out,
 
  397                         size_type BufSize=512) :                        
 
  402         { initialize(mode); }
 
  406                         openmode mode = PGSTD::ios::in | PGSTD::ios::out,
 
  407                         size_type BufSize=512) :                        
 
  412         { initialize(mode); }
 
  420 #ifdef PQXX_HAVE_STREAMBUF 
  426     this->setg(this->eback(), this->eback(), this->egptr());
 
  427     return overflow(EoF());
 
  431   virtual pos_type seekoff(off_type offset,
 
  438   virtual pos_type seekpos(pos_type pos, openmode)
 
  443     return AdjustEOF(newpos);
 
  446   virtual int_type overflow(int_type ch = EoF())
 
  448     char *
const pp = this->pptr();
 
  449     if (!pp) 
return EoF();
 
  450     char *
const pb = this->pbase();
 
  453     if (pp > pb) res = int_type(AdjustEOF(m_Obj.cwrite(pb, pp-pb)));
 
  454     this->setp(m_P, m_P + m_BufSize);
 
  459       *this->pptr() = char(ch);
 
  465   virtual int_type underflow()
 
  467     if (!this->gptr()) 
return EoF();
 
  468     char *
const eb = this->eback();
 
  469     const int_type res(static_cast<int_type>(
 
  470         AdjustEOF(m_Obj.cread(this->eback(), m_BufSize))));
 
  471     this->setg(eb, eb, eb + ((res==EoF()) ? 0 : res));
 
  472     return (!res || (res == EoF())) ? EoF() : *eb;
 
  477   static int_type EoF() { 
return traits_type::eof(); }
 
  480   template<
typename INTYPE>
 
  481   static PGSTD::streampos AdjustEOF(INTYPE pos)
 
  482         { 
return (pos==-1) ? PGSTD::streampos(EoF()) : PGSTD::streampos(pos); }
 
  484   void initialize(openmode mode)
 
  486     if (mode & PGSTD::ios::in)
 
  488       m_G = 
new char_type[unsigned(m_BufSize)];
 
  489       this->setg(m_G, m_G, m_G);
 
  491     if (mode & PGSTD::ios::out)
 
  493       m_P = 
new char_type[unsigned(m_BufSize)];
 
  494       this->setp(m_P, m_P + m_BufSize);
 
  498   const size_type m_BufSize;
 
  499   largeobjectaccess m_Obj;
 
  502   char_type *m_G, *m_P;
 
  515 template<
typename CHAR=
char, 
typename TRAITS=PGSTD::
char_traits<CHAR> >
 
  517 #ifdef PQXX_HAVE_STREAMBUF 
  518     public PGSTD::basic_istream<CHAR, TRAITS>
 
  520     public PGSTD::istream
 
  523 #ifdef PQXX_HAVE_STREAMBUF 
  524   typedef PGSTD::basic_istream<CHAR, TRAITS> super;
 
  526   typedef PGSTD::istream super;
 
  546     m_Buf(T, O, PGSTD::ios::in, BufSize)
 
  547         { super::init(&m_Buf); }
 
  559     m_Buf(T, O, PGSTD::ios::in, BufSize)
 
  560         { super::init(&m_Buf); }
 
  578 template<
typename CHAR=
char, 
typename TRAITS=PGSTD::
char_traits<CHAR> >
 
  580 #ifdef PQXX_HAVE_STREAMBUF 
  581     public PGSTD::basic_ostream<CHAR, TRAITS>
 
  583     public PGSTD::ostream
 
  586 #ifdef PQXX_HAVE_STREAMBUF 
  587   typedef PGSTD::basic_ostream<CHAR, TRAITS> super;
 
  589   typedef PGSTD::ostream super;
 
  608     m_Buf(T, O, PGSTD::ios::out, BufSize)
 
  609         { super::init(&m_Buf); }
 
  621     m_Buf(T, O, PGSTD::ios::out, BufSize)
 
  622         { super::init(&m_Buf); }
 
  628 #ifdef PQXX_HAVE_STREAMBUF 
  629       m_Buf.pubsync(); m_Buf.pubsync();
 
  631       m_Buf.sync(); m_Buf.sync();
 
  634     catch (
const PGSTD::exception &e)
 
  636       m_Buf.process_notice(e.what());
 
  656 template<
typename CHAR=
char, 
typename TRAITS=PGSTD::
char_traits<CHAR> >
 
  658 #ifdef PQXX_HAVE_STREAMBUF 
  659     public PGSTD::basic_iostream<CHAR, TRAITS>
 
  661     public PGSTD::iostream
 
  664 #ifdef PQXX_HAVE_STREAMBUF 
  665   typedef PGSTD::basic_iostream<CHAR, TRAITS> super;
 
  667   typedef PGSTD::iostream super;
 
  687     m_Buf(T, O, PGSTD::ios::in | PGSTD::ios::out, BufSize)
 
  688         { super::init(&m_Buf); }
 
  700     m_Buf(T, O, PGSTD::ios::in | PGSTD::ios::out, BufSize)
 
  701         { super::init(&m_Buf); }
 
  707 #ifdef PQXX_HAVE_STREAMBUF 
  708       m_Buf.pubsync(); m_Buf.pubsync();
 
  710       m_Buf.sync(); m_Buf.sync();
 
  713     catch (
const PGSTD::exception &e)
 
  715       m_Buf.process_notice(e.what());
 
  727 #include "pqxx/compiler-internal-post.hxx"