pqxx::largeobjectaccess Class Reference

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

`#include <largeobject.hxx>`

Inheritance diagram for pqxx::largeobjectaccess:
[legend]

## Public Types

using | off_type = long
using | pos_type = size_type
using | openmode = std::ios::openmode
| Open mode: `in`, `out` (can be combined with the "or" operator) More...
using | seekdir = std::ios::seekdir
| Seek direction: `beg`, `cur`, `end`. More...
using | size_type = large_object_size_type

## Public Member Functions

| largeobjectaccess (dbtransaction &T, openmode mode=std::ios::in|std::ios::out)
| Create new large object and open it. More...
| largeobjectaccess (dbtransaction &T, oid O, openmode mode=std::ios::in|std::ios::out)
| Open large object with given oid. More...
| largeobjectaccess (dbtransaction &T, largeobject O, openmode mode=std::ios::in|std::ios::out)
| Open given large object. More...
| largeobjectaccess (dbtransaction &T, const std::string &File, openmode mode=std::ios::in|std::ios::out)
| Import large object from a local file and open it. More...
| ~largeobjectaccess () noexcept
void | to_file (const std::string &File) const
| Export large object's contents to a local file. 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...
High-level access to object contents
void | write (const char Buf[], size_type Len)
| Write data to large object. More...
void | write (const std::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) noexcept
| Seek in large object's data stream. More...
off_type | cwrite (const char Buf[], size_type Len) noexcept
| Write to large object's data stream. More...
off_type | cread (char Buf[], size_type Len) noexcept
| Read from large object's data stream. More...
pos_type | ctell () const noexcept
| Report current position in large object's data stream. More...

## Error/warning output

void | process_notice (const std::string &) noexcept
| Issue message to transaction's notice processor. More...
void | remove (dbtransaction &T) const
| Delete large object from database. 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...
bool | operator>= (const largeobject &other) const
| Compare object identities. More...

## Detailed Description

Accessor for large object's contents.

## Member Typedef Documentation

## off_type

using pqxx::largeobjectaccess::off_type = long

## openmode

using pqxx::largeobjectaccess::openmode = std::ios::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.

## pos_type

using pqxx::largeobjectaccess::pos_type = size_type

## seekdir

using pqxx::largeobjectaccess::seekdir = std::ios::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.

## size_type

using pqxx::largeobject::size_type = large_object_size_type

## Constructor & Destructor Documentation

## largeobjectaccess() [1/4]

pqxx::largeobjectaccess::largeobjectaccess | ( | dbtransaction & | T,
|  | openmode | mode = `std::ios::in|std::ios::out`
| ) |  |

explicit

Create new large object and open it.

Parameters

  T | Backend transaction in which the object is to be created
  mode | Access mode, defaults to ios_base::in | ios_base::out

References largeobjectaccess().

Referenced by largeobjectaccess().

## largeobjectaccess() [2/4]

pqxx::largeobjectaccess::largeobjectaccess | ( | dbtransaction & | T,
|  | oid | O,
|  | openmode | mode = `std::ios::in|std::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

  T | Transaction in which the object is to be accessed
  O | Object identifier for the given object
  mode | Access mode, defaults to ios_base::in | ios_base::out

References largeobjectaccess().

## largeobjectaccess() [3/4]

pqxx::largeobjectaccess::largeobjectaccess | ( | dbtransaction & | T,
|  | largeobject | O,
|  | openmode | mode = `std::ios::in|std::ios::out`
| ) |  |

Open given large object.

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

Parameters

  T | Transaction in which the object is to be accessed
  O | Identity for the large object to be accessed
  mode | Access mode, defaults to ios_base::in | ios_base::out

References largeobjectaccess().

## largeobjectaccess() [4/4]

pqxx::largeobjectaccess::largeobjectaccess | ( | dbtransaction & | T,
|  | const std::string & | File,
|  | openmode | mode = `std::ios::in|std::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

  T | Backend transaction in which the large object is to be created
  File | A filename on the client program's filesystem
  mode | Access mode, defaults to ios_base::in | ios_base::out

References largeobjectaccess().

## ~largeobjectaccess()

pqxx::largeobjectaccess::~largeobjectaccess | ( |  | ) |

noexcept

## Member Function Documentation

## cread()

pqxx::largeobjectaccess::pos_type pqxx::largeobjectaccess::cread | ( | char | Buf[],
|  | size_type | Len
| ) |  |

noexcept

Read from large object's data stream.

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

Parameters

  Buf | Area where incoming bytes should be stored
  Len | Number of bytes to read

Returns
  Number of bytes actually read, or -1 if an error occurred.

## cseek()

pqxx::largeobjectaccess::pos_type pqxx::largeobjectaccess::cseek | ( | off_type | dest,
|  | seekdir | dir
| ) |  |

noexcept

Seek in large object's data stream.

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

Parameters

  dest | Offset to go to
  dir | Origin 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.

## ctell()

pqxx::largeobjectaccess::pos_type pqxx::largeobjectaccess::ctell | ( |  | ) | const

noexcept

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.

## cwrite()

pqxx::largeobjectaccess::pos_type pqxx::largeobjectaccess::cwrite | ( | const char | Buf[],
|  | size_type | Len
| ) |  |

noexcept

Write to large object's data stream.

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

Parameters

  Buf | Data to write
  Len | Number of bytes to write

Returns
  Number of bytes actually written, or -1 if an error occurred.

## id()

oid pqxx::largeobject::id

noexcept

Object identifier.

The number returned by this function uniquely identifies the large object in the context of the database we're connected to.

## operator!=()

bool pqxx::largeobject::operator!=

Compare object identities.

Warning
  Only valid between large objects in the same database.

## operator<()

bool pqxx::largeobject::operator<

Compare object identities.

Warning
  Only valid between large objects in the same database.

## operator<=()

bool pqxx::largeobject::operator<=

Compare object identities.

Warning
  Only valid between large objects in the same database.

## operator==()

bool pqxx::largeobject::operator==

Compare object identities.

Warning
  Only valid between large objects in the same database.

## operator>()

bool pqxx::largeobject::operator>

Compare object identities.

Warning
  Only valid between large objects in the same database.

## operator>=()

bool pqxx::largeobject::operator>=

Compare object identities.

Warning
  Only valid between large objects in the same database.

## process_notice()

void pqxx::largeobjectaccess::process_notice | ( | const std::string & | s | ) |

noexcept

Issue message to transaction's notice processor.

## read()

pqxx::largeobjectaccess::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

  Buf | Location to store the read data in
  Len | Number 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

References pqxx::to_string().

## remove()

void pqxx::largeobject::remove

Delete large object from database.

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

Parameters

  T | Transaction in which the object is to be deleted

## seek()

pqxx::largeobjectaccess::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

## tell()

pqxx::largeobjectaccess::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

## to_file() [1/2]

void pqxx::largeobjectaccess::to_file | ( | 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

  File | A filename on the client's filesystem

References pqxx::largeobject::to_file().

## to_file() [2/2]

void pqxx::largeobject::to_file

Export large object's contents to a local file.

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

Parameters

  T | Transaction in which the object is to be accessed
  File | A filename on the client's filesystem

## write() [1/2]

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

  Buf | Data to write
  Len | Number of bytes from Buf to write

References pqxx::to_string().

## write() [2/2]

void pqxx::largeobjectaccess::write | ( | const std::string & | Buf | ) |

Write string to large object.

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

Parameters

  Buf | Data to write; no terminating zero is written

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

- largeobject.hxx
- largeobject.cxx