libpqxx
7.0.1
|
Accessor for large object's contents. More...
#include <largeobject.hxx>
Public Types | |
using | off_type = size_type |
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, std::string_view 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 (std::string_view file) const |
Export large object's contents to a local file. More... | |
largeobjectaccess ()=delete | |
largeobjectaccess (largeobjectaccess const &)=delete | |
largeobjectaccess | operator= (largeobjectaccess const &)=delete |
High-level access to object contents. | |
void | write (char const buf[], size_t len) |
Write data to large object. More... | |
void | write (std::string_view buf) |
Write string to large object. More... | |
size_type | read (char buf[], size_t 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. Due to libpq's underlying API, some operations are limited to "int" sizes, typically 2 GB, even though a large object can grow much larger. | |
pos_type | cseek (off_type dest, seekdir dir) noexcept |
Seek in large object's data stream. More... | |
off_type | cwrite (char const buf[], size_t len) noexcept |
Write to large object's data stream. More... | |
off_type | cread (char buf[], size_t 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 (std::string const &) noexcept |
Issue message to transaction's notice processor. More... | |
Accessor for large object's contents.
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.
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.
|
explicit |
Create new large object and open it.
t | Backend transaction in which the object is to be created |
mode | Access mode, defaults to ios_base::in | ios_base::out |
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.
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 |
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
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 |
pqxx::largeobjectaccess::largeobjectaccess | ( | dbtransaction & | t, |
std::string_view | 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.
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 |
|
noexcept |
References pqxx::largeobject::id().
|
delete |
|
delete |
|
noexcept |
Read from large object's data stream.
Does not throw exception in case of error; inspect return value and errno
instead.
buf | Area where incoming bytes should be stored. |
len | Number of bytes to read. |
Referenced by read().
|
noexcept |
Seek in large object's data stream.
Does not throw exception in case of error; inspect return value and errno
instead.
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). |
Referenced by seek().
|
noexcept |
Report current position in large object's data stream.
Does not throw exception in case of error; inspect return value and errno
instead.
Referenced by tell().
|
noexcept |
Write to large object's data stream.
Does not throw exception in case of error; inspect return value and errno
instead.
buf | Data to write. |
len | Number of bytes to write. |
Referenced by write().
|
delete |
|
noexcept |
Issue message to transaction's notice processor.
References pqxx::transaction_base::process_notice().
pqxx::largeobjectaccess::size_type pqxx::largeobjectaccess::read | ( | char | buf[], |
size_t | len | ||
) |
Read data from large object.
Throws an exception if an error occurs while reading.
buf | Location to store the read data in. |
len | Number of bytes to try and read. |
References cread(), and pqxx::to_string().
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.
References cseek().
pqxx::largeobjectaccess::size_type pqxx::largeobjectaccess::tell | ( | ) | const |
Report current position in large object's data stream.
Throws an exception if an error occurs.
References pqxx::transaction_base::conn(), ctell(), and pqxx::largeobject::reason().
void pqxx::largeobjectaccess::to_file | ( | std::string_view | file | ) | const |
Export large object's contents to a local file.
Writes the data stored in the large object to the given file.
file | A filename on the client's filesystem |
References pqxx::largeobject::to_file().
void pqxx::largeobjectaccess::write | ( | char const | buf[], |
size_t | len | ||
) |
Write data to large object.
buf | Data to write. |
len | Number of bytes from Buf to write. |
References cwrite(), and pqxx::to_string().
void pqxx::largeobjectaccess::write | ( | std::string_view | buf | ) |
Write string to large object.
If not all bytes could be written, an exception is thrown.
buf | Data to write; no terminating zero is written. |
References pqxx::largeobject::raw_connection(), pqxx::largeobject::remove(), and write().
Referenced by write().