libpqxx
7.0.5
|
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type. More...
#include <binarystring.hxx>
Public Types | |
using | char_type = unsigned char |
using | value_type = std::char_traits< char_type >::char_type |
using | size_type = size_t |
using | difference_type = long |
using | const_reference = value_type const & |
using | const_pointer = value_type const * |
using | const_iterator = const_pointer |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Public Member Functions | |
binarystring (binarystring const &)=default | |
binarystring (field const &) | |
Read and unescape bytea field. More... | |
binarystring (std::string_view) | |
Copy binary data from std::string_view. More... | |
binarystring (void const *, size_t) | |
Copy binary data of given length straight out of memory. More... | |
size_type | size () const noexcept |
Size of converted string in bytes. More... | |
size_type | length () const noexcept |
Size of converted string in bytes. More... | |
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. More... | |
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. More... | |
void | swap (binarystring &) |
Swap contents with other binarystring. More... | |
char const * | get () const noexcept |
Raw character buffer (no terminating zero is added). More... | |
std::string_view | view () const noexcept |
Read contents as a std::string_view. More... | |
std::string | str () const |
Read as regular C++ string (may include null characters). More... | |
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type.
This class represents a binary string as stored in a field of type bytea. The raw value returned by a bytea field contains escape sequences for certain characters, which are filtered out by binarystring.
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 unless you've made sure of it yourself.
The binarystring retains its value even if the result it was obtained from is destroyed, but it cannot be copied or assigned.
To convert the other way, i.e. from a raw series of bytes to a string suitable for inclusion as bytea values in your SQL, use the transaction's esc_raw() functions.
using pqxx::binarystring::char_type = unsigned char |
using pqxx::binarystring::const_pointer = value_type const * |
using pqxx::binarystring::const_reference = value_type const & |
using pqxx::binarystring::const_reverse_iterator = std::reverse_iterator<const_iterator> |
using pqxx::binarystring::difference_type = long |
using pqxx::binarystring::size_type = size_t |
using pqxx::binarystring::value_type = std::char_traits<char_type>::char_type |
|
default |
|
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 |
References pqxx::field::c_str().
|
explicit |
Copy binary data from std::string_view.
pqxx::binarystring::binarystring | ( | void const * | binary_data, |
size_t | len | ||
) |
Copy binary data of given length straight out of memory.
pqxx::binarystring::const_reference pqxx::binarystring::at | ( | size_type | n | ) | const |
Index contained string, checking for valid index.
References data(), and pqxx::to_string().
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
const_reverse_iterator pqxx::binarystring::crbegin | ( | ) | const |
const_reverse_iterator pqxx::binarystring::crend | ( | ) | const |
|
noexcept |
Unescaped field contents.
Referenced by at(), operator==(), and pqxx::connection::quote().
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Raw character buffer (no terminating zero is added).
|
noexcept |
Size of converted string in bytes.
|
noexcept |
|
default |
Referenced by operator==().
|
noexcept |
References data(), operator=(), and size().
|
noexcept |
const_reverse_iterator pqxx::binarystring::rbegin | ( | ) | const |
const_reverse_iterator pqxx::binarystring::rend | ( | ) | const |
|
noexcept |
Size of converted string in bytes.
Referenced by operator==(), and pqxx::connection::quote().
std::string pqxx::binarystring::str | ( | ) | const |
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.
void pqxx::binarystring::swap | ( | binarystring & | rhs | ) |
Swap contents with other binarystring.
|
noexcept |
Read contents as a std::string_view.