libpqxx
pqxx::largeobject Class Reference

Identity of a large object. More...

#include <largeobject.hxx>

Inheritance diagram for pqxx::largeobject:

Public Types

using size_type = large_object_size_type
 

Public Member Functions

 largeobject () noexcept=default
 Refer to a nonexistent large object (similar to what a null pointer does) More...
 
 largeobject (dbtransaction &T)
 Create new large object. More...
 
 largeobject (oid O) noexcept
 Wrap object with given oid. More...
 
 largeobject (dbtransaction &T, const std::string &File)
 Import large object from a local file. More...
 
 largeobject (const largeobjectaccess &O) noexcept
 Take identity of an opened large object. More...
 
oid id () const noexcept
 Object identifier. More...
 
void to_file (dbtransaction &T, const std::string &File) const
 Export large object's contents to a local file. More...
 
void remove (dbtransaction &T) const
 Delete large object from database. 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...
 

Protected Member Functions

std::string reason (const connection_base &, int err) const
 

Static Protected Member Functions

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

Detailed Description

Identity of a large object.

This class encapsulates the identity of a large object. To access the contents of the object, create a largeobjectaccess, a largeobject_streambuf, or an ilostream, an olostream or a lostream around the largeobject.

A largeobject must be accessed only from within a backend transaction, but the object's identity remains valid as long as the object exists.

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ largeobject() [1/5]

pqxx::largeobject::largeobject ( )
defaultnoexcept

Refer to a nonexistent large object (similar to what a null pointer does)

◆ largeobject() [2/5]

pqxx::largeobject::largeobject ( dbtransaction T)
explicit

Create new large object.

Parameters
TBackend transaction in which the object is to be created

References pqxx::transaction_base::conn(), pqxx::oid_none, raw_connection(), and reason().

◆ largeobject() [3/5]

pqxx::largeobject::largeobject ( oid  O)
explicitnoexcept

Wrap object with given oid.

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

Parameters
OObject identifier for the given object

◆ largeobject() [4/5]

pqxx::largeobject::largeobject ( dbtransaction T,
const std::string &  File 
)

Import large object from a local file.

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

References pqxx::transaction_base::conn(), pqxx::oid_none, raw_connection(), and reason().

◆ largeobject() [5/5]

pqxx::largeobject::largeobject ( const largeobjectaccess O)
noexcept

Take identity of an opened large object.

Copy identity of already opened large object. Note that this may be done as an implicit conversion.

Parameters
OAlready opened large object to copy identity from

Member Function Documentation

◆ id()

oid pqxx::largeobject::id ( ) const
noexcept

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).

Referenced by pqxx::largeobjectaccess::~largeobjectaccess().

◆ operator!=()

bool pqxx::largeobject::operator!= ( const largeobject other) const

Compare object identities.

Warning
Only valid between large objects in the same database.

◆ operator<()

bool pqxx::largeobject::operator< ( const largeobject other) const

Compare object identities.

Warning
Only valid between large objects in the same database.

◆ operator<=()

bool pqxx::largeobject::operator<= ( const largeobject other) const

Compare object identities.

Warning
Only valid between large objects in the same database.

◆ operator==()

bool pqxx::largeobject::operator== ( const largeobject other) const

Compare object identities.

Warning
Only valid between large objects in the same database.

◆ operator>()

bool pqxx::largeobject::operator> ( const largeobject other) const

Compare object identities.

Warning
Only valid between large objects in the same database.

References pqxx::oid_none.

◆ operator>=()

bool pqxx::largeobject::operator>= ( const largeobject other) const

Compare object identities.

Warning
Only valid between large objects in the same database.

◆ raw_connection()

pqxx::internal::pq::PGconn * pqxx::largeobject::raw_connection ( const dbtransaction T)
staticprotected

◆ reason()

std::string pqxx::largeobject::reason ( const connection_base c,
int  err 
) const
protected

◆ remove()

void pqxx::largeobject::remove ( dbtransaction T) const

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

References pqxx::transaction_base::conn(), raw_connection(), reason(), and pqxx::to_string().

Referenced by pqxx::largeobjectaccess::write().

◆ to_file()

void pqxx::largeobject::to_file ( dbtransaction T,
const std::string &  File 
) const

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

References pqxx::transaction_base::conn(), raw_connection(), reason(), and pqxx::to_string().

Referenced by pqxx::largeobjectaccess::to_file().


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