16 #if !defined(PQXX_HEADER_PRE) 17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>." 22 #if defined(PQXX_HAVE_PATH) 23 # include <filesystem> 26 #if defined(PQXX_HAVE_RANGES) && __has_include(<ranges>) 30 #if defined(PQXX_HAVE_SPAN) && __has_include(<span>) 34 #include "pqxx/dbtransaction.hxx" 84 blob &operator=(
blob const &) =
delete;
94 static constexpr std::size_t chunk_limit = 0x7fffffff;
105 std::size_t read(std::basic_string<std::byte> &buf, std::size_t size);
107 #if defined(PQXX_HAVE_SPAN) 114 template<std::
size_t extent = std::dynamic_extent>
115 std::span<std::byte> read(std::span<std::byte, extent> buf)
117 return buf.subspan(0, raw_read(std::data(buf), std::size(buf)));
119 #endif // PQXX_HAVE_SPAN 121 #if defined(PQXX_HAVE_CONCEPTS) && defined(PQXX_HAVE_SPAN) 128 template<binary DATA> std::span<std::byte> read(DATA &buf)
130 return {std::data(buf), raw_read(std::data(buf), std::size(buf))};
132 #else // PQXX_HAVE_CONCEPTS && PQXX_HAVE_SPAN 146 template<
typename ALLOC>
147 std::basic_string_view<std::byte>
read(std::vector<std::byte, ALLOC> &buf)
149 return {std::data(buf), raw_read(std::data(buf), std::size(buf))};
151 #endif // PQXX_HAVE_CONCEPTS && PQXX_HAVE_SPAN 153 #if defined(PQXX_HAVE_CONCEPTS) 173 template<binary DATA>
void write(DATA
const &data)
175 raw_write(std::data(data), std::size(data));
197 template<
typename DATA>
void write(DATA
const &data)
199 raw_write(std::data(data), std::size(data));
210 void resize(std::int64_t size);
213 [[nodiscard]] std::int64_t tell()
const;
217 std::int64_t seek_abs(std::int64_t offset = 0);
223 std::int64_t seek_rel(std::int64_t offset = 0);
229 std::int64_t seek_end(std::int64_t offset = 0);
236 dbtransaction &tx, std::basic_string_view<std::byte> data, oid
id = 0);
241 static void append_from_buf(
242 dbtransaction &tx, std::basic_string_view<std::byte> data, oid
id);
245 [[nodiscard]]
static oid from_file(
dbtransaction &,
char const path[]);
247 #if defined(PQXX_HAVE_PATH) && !defined(_WIN32) 252 [[nodiscard]]
static oid
253 from_file(
dbtransaction &tx, std::filesystem::path
const &path)
255 return from_file(tx, path.c_str());
263 static oid from_file(dbtransaction &,
char const path[], oid);
265 #if defined(PQXX_HAVE_PATH) && !defined(_WIN32) 274 from_file(dbtransaction &tx, std::filesystem::path
const &path, oid
id)
276 return from_file(tx, path.c_str(), id);
285 dbtransaction &, oid, std::basic_string<std::byte> &,
286 std::size_t max_size);
295 static std::size_t append_to_buf(
296 dbtransaction &tx, oid
id, std::int64_t offset,
297 std::basic_string<std::byte> &buf, std::size_t append_max);
300 static void to_file(dbtransaction &, oid,
char const path[]);
302 #if defined(PQXX_HAVE_PATH) && !defined(_WIN32) 308 to_file(dbtransaction &tx, oid
id, std::filesystem::path
const &path)
310 to_file(tx,
id, path.c_str());
329 PQXX_PRIVATE blob(connection &conn,
int fd) noexcept :
330 m_conn{&conn}, m_fd{fd}
332 static PQXX_PRIVATE blob open_internal(dbtransaction &, oid,
int);
333 static PQXX_PRIVATE pqxx::internal::pq::PGconn *
335 static PQXX_PRIVATE pqxx::internal::pq::PGconn *
337 static PQXX_PRIVATE std::string errmsg(connection
const *);
338 static PQXX_PRIVATE std::string errmsg(dbtransaction
const &tx)
340 return errmsg(&tx.conn());
342 PQXX_PRIVATE std::string errmsg()
const 344 return errmsg(m_conn);
346 PQXX_PRIVATE std::int64_t seek(std::int64_t offset,
int whence);
347 std::size_t raw_read(std::byte buf[], std::size_t size);
348 void raw_write(std::byte
const buf[], std::size_t size);
350 connection *m_conn =
nullptr;
void write(DATA const &data)
Write data large object, at the current position.
Definition: blob.hxx:197
std::basic_string_view< std::byte > read(std::vector< std::byte, ALLOC > &buf)
Read up to std::size(buf) bytes from the object.
Definition: blob.hxx:147
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:53
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
Connection to a database.
Definition: connection.hxx:184
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:349