Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid MSVC deprecation warnings for oracle_blob_backend functions #1137

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions include/soci/oracle/soci-oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,8 @@ struct oracle_blob_backend : details::blob_backend

std::size_t get_len() override;

[[deprecated("Use read_from_start instead")]]
std::size_t read(std::size_t offset, void *buf, std::size_t toRead) override
{
// Offsets are 1-based in Oracle
return read_from_start(buf, toRead, offset - 1);
}

std::size_t read_from_start(void * buf, std::size_t toRead, std::size_t offset = 0) override;

[[deprecated("Use write_from_start instead")]]
std::size_t write(std::size_t offset, const void *buf, std::size_t toWrite) override
{
// Offsets are 1-based in Oracle
return write_from_start(buf, toWrite, offset - 1);
}

std::size_t write_from_start(const void * buf, std::size_t toWrite, std::size_t offset = 0) override;

std::size_t append(const void *buf, std::size_t toWrite) override;
Expand All @@ -300,6 +286,18 @@ struct oracle_blob_backend : details::blob_backend
void ensure_initialized();

private:
std::size_t do_deprecated_read(std::size_t offset, void *buf, std::size_t toRead) override
{
// Offsets are 1-based in Oracle
return read_from_start(buf, toRead, offset - 1);
}

std::size_t do_deprecated_write(std::size_t offset, const void *buf, std::size_t toWrite) override
{
// Offsets are 1-based in Oracle
return write_from_start(buf, toWrite, offset - 1);
}

oracle_session_backend &session_;

locator_t lobp_;
Expand Down
17 changes: 11 additions & 6 deletions include/soci/soci-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,21 +304,26 @@ class blob_backend

virtual std::size_t get_len() = 0;

[[deprecated("Use read_from_start instead")]]
virtual std::size_t read(std::size_t offset, void* buf, std::size_t toRead) { return read_from_start(buf, toRead, offset); }

virtual std::size_t read_from_start(void* buf, std::size_t toRead, std::size_t offset) = 0;

[[deprecated("Use write_from_start instead")]]
virtual std::size_t write(std::size_t offset, const void* buf, std::size_t toWrite) { return write_from_start(buf, toWrite, offset); }

virtual std::size_t write_from_start(const void* buf, std::size_t toWrite, std::size_t offset) = 0;

virtual std::size_t append(const void* buf, std::size_t toWrite) = 0;

virtual void trim(std::size_t newLen) = 0;

// Deprecated functions with backend-specific semantics preserved only for
// compatibility.
[[deprecated("Use read_from_start instead")]]
std::size_t read(std::size_t offset, void* buf, std::size_t toRead) { return do_deprecated_read(offset, buf, toRead); }

[[deprecated("Use write_from_start instead")]]
virtual std::size_t write(std::size_t offset, const void* buf, std::size_t toWrite) { return do_deprecated_write(offset, buf, toWrite); }

private:
virtual std::size_t do_deprecated_read(std::size_t offset, void* buf, std::size_t toRead) { return read_from_start(buf, toRead, offset); }
virtual std::size_t do_deprecated_write(std::size_t offset, const void* buf, std::size_t toWrite) { return write_from_start(buf, toWrite, offset); }

SOCI_NOT_COPYABLE(blob_backend)
};

Expand Down