18 #if defined(PQXX_HAVE_PATH)
19 # include <filesystem>
22 #if defined(PQXX_HAVE_RANGES) && __has_include(<ranges>)
26 #if defined(PQXX_HAVE_SPAN) && __has_include(<span>)
30 #include "pqxx/dbtransaction.hxx"
91 static constexpr std::size_t chunk_limit = 0x7fffffff;
102 std::size_t read(std::basic_string<std::byte> &buf, std::size_t size);
104 #if defined(PQXX_HAVE_SPAN)
111 template<std::
size_t extent = std::dynamic_extent>
112 std::span<std::byte> read(std::span<std::byte, extent> buf)
114 return buf.subspan(0, raw_read(std::data(buf), std::size(buf)));
118 #if defined(PQXX_HAVE_CONCEPTS) && defined(PQXX_HAVE_SPAN)
125 template<binary DATA> std::span<std::byte> read(DATA &buf)
127 return {std::data(buf), raw_read(std::data(buf), std::size(buf))};
143 template<
typename ALLOC>
144 std::basic_string_view<std::byte>
read(std::vector<std::byte, ALLOC> &buf)
146 return {std::data(buf), raw_read(std::data(buf), std::size(buf))};
150 #if defined(PQXX_HAVE_CONCEPTS)
170 template<binary DATA>
void write(DATA
const &data)
172 raw_write(std::data(data), std::size(data));
194 template<
typename DATA>
void write(DATA
const &data)
196 raw_write(std::data(data), std::size(data));
207 void resize(std::int64_t size);
210 [[nodiscard]] std::int64_t tell()
const;
214 std::int64_t seek_abs(std::int64_t offset = 0);
220 std::int64_t seek_rel(std::int64_t offset = 0);
226 std::int64_t seek_end(std::int64_t offset = 0);
233 dbtransaction &tx, std::basic_string_view<std::byte> data, oid
id = 0);
238 static void append_from_buf(
239 dbtransaction &tx, std::basic_string_view<std::byte> data, oid
id);
242 [[nodiscard]]
static oid from_file(
dbtransaction &,
char const path[]);
244 #if defined(PQXX_HAVE_PATH) && !defined(_WIN32)
249 [[nodiscard]]
static oid
252 return from_file(tx, path.c_str());
260 static oid from_file(
dbtransaction &,
char const path[], oid);
262 #if defined(PQXX_HAVE_PATH) && !defined(_WIN32)
273 return from_file(tx, path.c_str(),
id);
283 std::size_t max_size);
292 static std::size_t append_to_buf(
294 std::basic_string<std::byte> &buf, std::size_t append_max);
297 static void to_file(
dbtransaction &, oid,
char const path[]);
299 #if defined(PQXX_HAVE_PATH) && !defined(_WIN32)
307 to_file(tx,
id, path.c_str());
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;
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
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:343
void write(DATA const &data)
Write data large object, at the current position.
Definition: blob.hxx:194
blob(blob const &)=delete
blob()=default
You can default-construct a blob, but it won't do anything useful.
blob & operator=(blob const &)=delete
static oid from_file(dbtransaction &tx, std::filesystem::path const &path)
Read client-side file and store it server-side as a binary large object.
Definition: blob.hxx:250
static void to_file(dbtransaction &tx, oid id, std::filesystem::path const &path)
Write a binary large object's contents to a client-side file.
Definition: blob.hxx:305
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:144
static oid from_file(dbtransaction &tx, std::filesystem::path const &path, oid id)
Read client-side file and store it server-side as a binary large object.
Definition: blob.hxx:271
Connection to a database.
Definition: connection.hxx:181
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:50