libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::largeobjectaccess Class Reference

Accessor for large object's contents. More...

#include <largeobject.hxx>

Inheritance diagram for pqxx::largeobjectaccess:
Collaboration diagram for pqxx::largeobjectaccess:

Public Types

typedef long off_type
 
typedef PGSTD::ios::openmode openmode
 Open mode: in, out (can be combined with the "or" operator) More...
 
typedef size_type pos_type
 
typedef PGSTD::ios::seekdir seekdir
 Seek direction: beg, cur, end. More...
 
typedef long size_type
 

Public Member Functions

 largeobjectaccess (dbtransaction &T, openmode mode=PGSTD::ios::in|PGSTD::ios::out)
 Create new large object and open it. More...
 
 largeobjectaccess (dbtransaction &T, oid O, openmode mode=PGSTD::ios::in|PGSTD::ios::out)
 Open large object with given oid. More...
 
 largeobjectaccess (dbtransaction &T, largeobject O, openmode mode=PGSTD::ios::in|PGSTD::ios::out)
 Open given large object. More...
 
 largeobjectaccess (dbtransaction &T, const PGSTD::string &File, openmode mode=PGSTD::ios::in|PGSTD::ios::out)
 Import large object from a local file and open it. More...
 
 ~largeobjectaccess () throw ()
 
void to_file (const PGSTD::string &File) const
 Export large object's contents to a local file. More...
 
High-level access to object contents
void write (const char Buf[], size_type Len)
 Write data to large object. More...
 
void write (const PGSTD::string &Buf)
 Write string to large object. More...
 
size_type read (char Buf[], size_type Len)
 Read data from large object. More...
 
size_type seek (size_type dest, seekdir dir)
 Seek in large object's data stream. More...
 
size_type tell () const
 Report current position in large object's data stream. More...
 
Low-level access to object contents

These functions provide a more "C-like" access interface, returning special values instead of throwing exceptions on error.

These functions are generally best avoided in favour of the high-level access functions, which behave more like C++ functions should.

pos_type cseek (off_type dest, seekdir dir) throw ()
 Seek in large object's data stream. More...
 
off_type cwrite (const char Buf[], size_type Len) throw ()
 Write to large object's data stream. More...
 
off_type cread (char Buf[], size_type Len) throw ()
 Read from large object's data stream. More...
 
pos_type ctell () const throw ()
 Report current position in large object's data stream. More...
 
Error/warning output
void process_notice (const PGSTD::string &) throw ()
 Issue message to transaction's notice processor. More...
 

Private Member Functions

 largeobjectaccess ()
 
 largeobjectaccess (const largeobjectaccess &)
 
void close () throw ()
 
oid id () const throw ()
 Object identifier. More...
 
void open (openmode mode)
 
largeobjectaccess operator= (const largeobjectaccess &)
 
internal::pq::PGconnRawConnection () const
 
PGSTD::string PQXX_PRIVATE Reason (int err) const
 
void remove (dbtransaction &T) const
 Delete large object from database. More...
 
void to_file (dbtransaction &T, const PGSTD::string &File) const
 Export large object's contents to a local file. More...
 
Identity comparisons

These operators compare the object identifiers of large objects.

This has nothing to do with the objects' actual contents; use them only for keeping track of containers of references to large objects and such.

bool operator== (const largeobject &other) const
 Compare object identities. More...
 
bool operator!= (const largeobject &other) const
 Compare object identities. More...
 
bool operator<= (const largeobject &other) const
 Compare object identities. More...
 
bool operator>= (const largeobject &other) const
 Compare object identities. More...
 
bool operator< (const largeobject &other) const
 Compare object identities. More...
 
bool operator> (const largeobject &other) const
 Compare object identities. More...
 

Static Private Member Functions

static internal::pq::PGconn
*PQXX_PURE 
RawConnection (const dbtransaction &T)
 

Private Attributes

int m_fd
 
dbtransactionm_Trans
 

Detailed Description

Accessor for large object's contents.

Member Typedef Documentation

typedef PGSTD::ios::openmode pqxx::largeobjectaccess::openmode

Open mode: in, out (can be combined with the "or" operator)

According to the C++ standard, these should be in std::ios_base. We take them from std::ios instead, which should be safe because it inherits the same definition, to accommodate gcc 2.95 & 2.96.

typedef PGSTD::ios::seekdir pqxx::largeobjectaccess::seekdir

Seek direction: beg, cur, end.

According to the C++ standard, these should be in std::ios_base. We take them from std::ios instead, which should be safe because it inherits the same definition, to accommodate gcc 2.95 & 2.96.

Constructor & Destructor Documentation

pqxx::largeobjectaccess::largeobjectaccess ( dbtransaction T,
openmode  mode = PGSTD::ios::in|PGSTD::ios::out 
)
explicit

Create new large object and open it.

Parameters
TBackend transaction in which the object is to be created
modeAccess mode, defaults to ios_base::in | ios_base::out
pqxx::largeobjectaccess::largeobjectaccess ( dbtransaction T,
oid  O,
openmode  mode = PGSTD::ios::in|PGSTD::ios::out 
)

Open large object with given oid.

Convert combination of a transaction and object identifier into a large object identity. Does not affect the database.

Parameters
TTransaction in which the object is to be accessed
OObject identifier for the given object
modeAccess mode, defaults to ios_base::in | ios_base::out
pqxx::largeobjectaccess::largeobjectaccess ( dbtransaction T,
largeobject  O,
openmode  mode = PGSTD::ios::in|PGSTD::ios::out 
)

Open given large object.

Open a large object with the given identity for reading and/or writing

Parameters
TTransaction in which the object is to be accessed
OIdentity for the large object to be accessed
modeAccess mode, defaults to ios_base::in | ios_base::out
pqxx::largeobjectaccess::largeobjectaccess ( dbtransaction T,
const PGSTD::string &  File,
openmode  mode = PGSTD::ios::in|PGSTD::ios::out 
)

Import large object from a local file and open it.

Creates a large object containing the data found in the given file.

Parameters
TBackend transaction in which the large object is to be created
FileA filename on the client program's filesystem
modeAccess mode, defaults to ios_base::in | ios_base::out
pqxx::largeobjectaccess::~largeobjectaccess ( ) throw ()
inline
pqxx::largeobjectaccess::largeobjectaccess ( )
private
pqxx::largeobjectaccess::largeobjectaccess ( const largeobjectaccess )
private

Member Function Documentation

void pqxx::largeobjectaccess::close ( ) throw ()
private
off_type pqxx::largeobjectaccess::cread ( char  Buf[],
size_type  Len 
) throw ()

Read from large object's data stream.

Does not throw exception in case of error; inspect return value and errno instead.

Parameters
BufArea where incoming bytes should be stored
LenNumber of bytes to read
Returns
Number of bytes actually read, or -1 if an error occurred.
pos_type pqxx::largeobjectaccess::cseek ( off_type  dest,
seekdir  dir 
) throw ()

Seek in large object's data stream.

Does not throw exception in case of error; inspect return value and errno instead.

Parameters
destOffset to go to
dirOrigin to which dest is relative: ios_base::beg (from beginning of the object), ios_base::cur (from current access position), or ios_base;:end (from end of object)
Returns
New position in large object, or -1 if an error occurred.
pos_type pqxx::largeobjectaccess::ctell ( ) const throw ()

Report current position in large object's data stream.

Does not throw exception in case of error; inspect return value and errno instead.

Returns
Current position in large object, of -1 if an error occurred.
off_type pqxx::largeobjectaccess::cwrite ( const char  Buf[],
size_type  Len 
) throw ()

Write to large object's data stream.

Does not throw exception in case of error; inspect return value and errno instead.

Parameters
BufData to write
LenNumber of bytes to write
Returns
Number of bytes actually written, or -1 if an error occurred.
oid pqxx::largeobject::id ( ) const throw ()
inlineinherited

Object identifier.

The number returned by this function identifies the large object in the database we're connected to (or oid_none is returned if we refer to the null object).

void pqxx::largeobjectaccess::open ( openmode  mode)
private
bool pqxx::largeobject::operator!= ( const largeobject other) const
inlineinherited

Compare object identities.

Warning
Only valid between large objects in the same database.
bool pqxx::largeobject::operator< ( const largeobject other) const
inlineinherited

Compare object identities.

Warning
Only valid between large objects in the same database.
bool pqxx::largeobject::operator<= ( const largeobject other) const
inlineinherited

Compare object identities.

Warning
Only valid between large objects in the same database.
largeobjectaccess pqxx::largeobjectaccess::operator= ( const largeobjectaccess )
private
bool pqxx::largeobject::operator== ( const largeobject other) const
inlineinherited

Compare object identities.

Warning
Only valid between large objects in the same database.
bool pqxx::largeobject::operator> ( const largeobject other) const
inlineinherited

Compare object identities.

Warning
Only valid between large objects in the same database.
bool pqxx::largeobject::operator>= ( const largeobject other) const
inlineinherited

Compare object identities.

Warning
Only valid between large objects in the same database.
void pqxx::largeobjectaccess::process_notice ( const PGSTD::string &  ) throw ()

Issue message to transaction's notice processor.

static internal::pq::PGconn* PQXX_PURE pqxx::largeobject::RawConnection ( const dbtransaction T)
staticprotectedinherited

Referenced by RawConnection().

Here is the caller graph for this function:

internal::pq::PGconn* pqxx::largeobjectaccess::RawConnection ( ) const
inlineprivate

References pqxx::largeobject::RawConnection().

Here is the call graph for this function:

size_type pqxx::largeobjectaccess::read ( char  Buf[],
size_type  Len 
)

Read data from large object.

Throws an exception if an error occurs while reading.

Parameters
BufLocation to store the read data in
LenNumber of bytes to try and read
Returns
Number of bytes read, which may be less than the number requested if the end of the large object is reached
PGSTD::string PQXX_PRIVATE pqxx::largeobjectaccess::Reason ( int  err) const
private
void pqxx::largeobject::remove ( dbtransaction T) const
inherited

Delete large object from database.

Unlike its low-level equivalent cunlink, this will throw an exception if deletion fails.

Parameters
TTransaction in which the object is to be deleted
size_type pqxx::largeobjectaccess::seek ( size_type  dest,
seekdir  dir 
)

Seek in large object's data stream.

Throws an exception if an error occurs.

Returns
The new position in the large object
size_type pqxx::largeobjectaccess::tell ( ) const

Report current position in large object's data stream.

Throws an exception if an error occurs.

Returns
The current position in the large object
void pqxx::largeobject::to_file ( dbtransaction T,
const PGSTD::string &  File 
) const
inherited

Export large object's contents to a local file.

Writes the data stored in the large object to the given file.

Parameters
TTransaction in which the object is to be accessed
FileA filename on the client's filesystem

Referenced by to_file().

Here is the caller graph for this function:

void pqxx::largeobjectaccess::to_file ( const PGSTD::string &  File) const
inline

Export large object's contents to a local file.

Writes the data stored in the large object to the given file.

Parameters
FileA filename on the client's filesystem

References pqxx::largeobject::to_file().

Here is the call graph for this function:

void pqxx::largeobjectaccess::write ( const char  Buf[],
size_type  Len 
)

Write data to large object.

If not all bytes could be written, an exception is thrown.

Parameters
BufData to write
LenNumber of bytes from Buf to write
void pqxx::largeobjectaccess::write ( const PGSTD::string &  Buf)
inline

Write string to large object.

If not all bytes could be written, an exception is thrown.

Parameters
BufData to write; no terminating zero is written

References write().

Referenced by write().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

int pqxx::largeobjectaccess::m_fd
private
dbtransaction& pqxx::largeobjectaccess::m_Trans
private

The documentation for this class was generated from the following file: