16#if !defined(PQXX_HEADER_PRE)
17# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
22#if defined(PQXX_HAVE_PATH)
27#if __has_include(<ranges>)
32#if __has_include(<span>)
36#include "pqxx/dbtransaction.hxx"
86 blob &operator=(
blob const &) =
delete;
96 static constexpr std::size_t chunk_limit = 0x7fffffff;
107 std::size_t read(
bytes &buf, std::size_t size);
109#if defined(PQXX_HAVE_SPAN)
116 template<std::
size_t extent = std::dynamic_extent>
117 std::span<std::byte> read(std::span<std::byte, extent> buf)
119 return buf.subspan(0, raw_read(std::data(buf), std::size(buf)));
123#if defined(PQXX_HAVE_CONCEPTS) && defined(PQXX_HAVE_SPAN)
130 template<binary DATA> std::span<std::byte> read(DATA &buf)
132 return {std::data(buf), raw_read(std::data(buf), std::size(buf))};
150 return {std::data(buf), raw_read(std::data(buf), std::size(buf))};
154#if defined(PQXX_HAVE_CONCEPTS)
174 template<binary DATA>
void write(DATA
const &data)
176 raw_write(std::data(data), std::size(data));
198 template<
typename DATA>
void write(DATA
const &data)
200 raw_write(std::data(data), std::size(data));
211 void resize(std::int64_t size);
214 [[nodiscard]] std::int64_t tell()
const;
218 std::int64_t seek_abs(std::int64_t offset = 0);
224 std::int64_t seek_rel(std::int64_t offset = 0);
230 std::int64_t seek_end(std::int64_t offset = 0);
246#if defined(PQXX_HAVE_PATH) && !defined(_WIN32)
251 [[nodiscard]]
static oid
252 from_file(
dbtransaction &tx, std::filesystem::path
const &path)
254 return from_file(tx, path.c_str());
262 static oid from_file(dbtransaction &,
char const path[],
oid);
264#if defined(PQXX_HAVE_PATH) && !defined(_WIN32)
273 from_file(dbtransaction &tx, std::filesystem::path
const &path,
oid id)
275 return from_file(tx, path.c_str(),
id);
283 static void to_buf(dbtransaction &,
oid,
bytes &, std::size_t max_size);
292 static std::size_t append_to_buf(
293 dbtransaction &tx,
oid id, std::int64_t offset,
bytes &buf,
294 std::size_t append_max);
297 static void to_file(dbtransaction &,
oid,
char const path[]);
299#if defined(PQXX_HAVE_PATH) && !defined(_WIN32)
305 to_file(dbtransaction &tx,
oid id, std::filesystem::path
const &path)
307 to_file(tx,
id, path.c_str());
326 PQXX_PRIVATE blob(connection &conn,
int fd) noexcept :
327 m_conn{&conn}, m_fd{fd}
329 static PQXX_PRIVATE blob open_internal(dbtransaction &,
oid,
int);
330 static PQXX_PRIVATE pqxx::internal::pq::PGconn *
332 static PQXX_PRIVATE pqxx::internal::pq::PGconn *
334 static PQXX_PRIVATE std::string errmsg(connection
const *);
335 static PQXX_PRIVATE std::string errmsg(dbtransaction
const &tx)
337 return errmsg(&tx.conn());
339 PQXX_PRIVATE std::string errmsg()
const {
return errmsg(m_conn); }
340 PQXX_PRIVATE std::int64_t seek(std::int64_t offset,
int whence);
341 std::size_t raw_read(std::byte buf[], std::size_t size);
342 void raw_write(std::byte
const buf[], std::size_t size);
344 connection *m_conn =
nullptr;
void write(DATA const &data)
Write data large object, at the current position.
Definition: blob.hxx:198
blob()=default
You can default-construct a blob, but it won't do anything useful.
bytes_view read(std::vector< std::byte, ALLOC > &buf)
Read up to std::size(buf) bytes from the object.
Definition: blob.hxx:148
Connection to a database.
Definition: connection.hxx:230
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:54
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:27
std::vector< std::string_view > to_buf(char *here, char const *end, TYPE... value)
Convert multiple values to strings inside a single buffer.
Definition: strconv.hxx:492
std::conditional< has_generic_bytes_char_traits, std::basic_string< std::byte >, std::basic_string< std::byte, byte_char_traits > >::type bytes
Type alias for a container containing bytes.
Definition: util.hxx:375
unsigned int oid
PostgreSQL database row identifier.
Definition: libpq-forward.hxx:33
std::conditional< has_generic_bytes_char_traits, std::basic_string_view< std::byte >, std::basic_string_view< std::byte, byte_char_traits > >::type bytes_view
Type alias for a view of bytes.
Definition: util.hxx:385