libpqxx
The C++ client library for PostgreSQL
|
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type. More...
Public Member Functions | |
binarystring (binarystring const &)=default | |
binarystring (field const &) | |
Read and unescape bytea field. | |
binarystring (std::string_view) | |
Copy binary data from std::string_view on binary data. | |
binarystring (void const *, std::size_t) | |
Copy binary data of given length straight out of memory. | |
binarystring (std::shared_ptr< value_type > ptr, size_type size) | |
Efficiently wrap a buffer of binary data in a binarystring . | |
size_type | size () const noexcept |
Size of converted string in bytes. | |
size_type | length () const noexcept |
Size of converted string in bytes. | |
bool | empty () const noexcept |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
const_reference | front () const noexcept |
const_reference | back () const noexcept |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | rend () const |
const_reverse_iterator | crend () const |
value_type const * | data () const noexcept |
Unescaped field contents. | |
const_reference | operator[] (size_type i) const noexcept |
PQXX_PURE bool | operator== (binarystring const &) const noexcept |
bool | operator!= (binarystring const &rhs) const noexcept |
binarystring & | operator= (binarystring const &) |
const_reference | at (size_type) const |
Index contained string, checking for valid index. | |
void | swap (binarystring &) |
Swap contents with other binarystring. | |
char const * | get () const noexcept |
Raw character buffer (no terminating zero is added). | |
std::string_view | view () const noexcept |
Read contents as a std::string_view. | |
std::string | str () const |
Read as regular C++ string (may include null characters). | |
std::byte const * | bytes () const |
Access data as a pointer to std::byte . | |
pqxx::bytes_view | bytes_view () const |
Read data as a bytes_view . |
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type.
bytes
and bytes_view
for binary data. In C++20 or better, any contiguous_range
of std::byte
will do.This class represents a binary string as stored in a field of type bytea
.
Internally a binarystring is zero-terminated, but it may also contain null bytes, they're just like any other byte value. So don't assume that it's safe to treat the contents as a C-style string.
The binarystring retains its value even if the result it was obtained from is destroyed, but it cannot be copied or assigned.
To include a binarystring
value in an SQL query, escape and quote it using the transaction's quote_raw
function.
|
explicit |
Read and unescape bytea field.
The field will be zero-terminated, even if the original bytea field isn't.
F | the field to read; must be a bytea field |
|
explicit |
Copy binary data from std::string_view on binary data.
This is inefficient in that it copies the data to a buffer allocated on the heap.
|
inlinenodiscardnoexcept |
Raw character buffer (no terminating zero is added).
|
nodiscard |
Read as regular C++ string (may include null characters).
This creates and returns a new string object. Don't call this repeatedly; retrieve your string once and keep it in a local variable. Also, do not expect to be able to compare the string's address to that of an earlier invocation.