Get rid of unnecessary SOCI_ALLOW_DEPRECATED_BEGIN/END macros

They were ugly and not really necessary when we can just avoid marking
the functions as deprecated when compiling SOCI itself to allow using
them from the implementation code.

Also simply remove deprecated attributes from the functions in
blob_backend which is not supposed to be used publicly at all.
This commit is contained in:
Vadim Zeitlin
2025-06-08 02:25:07 +02:00
parent d1fede569a
commit 85b15d24a6
5 changed files with 5 additions and 37 deletions

View File

@@ -45,7 +45,9 @@ public:
std::size_t get_len();
// offset is backend-specific
#ifndef SOCI_SOURCE
[[deprecated("Use read_from_start instead")]]
#endif
std::size_t read(std::size_t offset, void * buf, std::size_t toRead);
// Extracts data from this blob into the given buffer.
@@ -58,7 +60,9 @@ public:
std::size_t offset = 0);
// offset is backend-specific
#ifndef SOCI_SOURCE
[[deprecated("Use write_from_start instead")]]
#endif
std::size_t write(std::size_t offset, const void * buf,
std::size_t toWrite);

View File

@@ -346,11 +346,8 @@ public:
// 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); }
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); }

View File

@@ -90,31 +90,6 @@ namespace std {
#endif
#endif
// Define SOCI_ALLOW_DEPRECATED_BEGIN and SOCI_ALLOW_DEPRECATED_END
// Ref.: https://www.fluentcpp.com/2019/08/30/how-to-disable-a-warning-in-cpp/
#if defined(__GNUC__) || defined(__clang__)
# define SOCI_ALLOW_DEPRECATED_BEGIN \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define SOCI_ALLOW_DEPRECATED_END \
_Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
# define SOCI_ALLOW_DEPRECATED_BEGIN \
__pragma(warning(push)) \
__pragma(warning(disable: 4973 )) \
__pragma(warning(disable: 4974 )) \
__pragma(warning(disable: 4995 )) \
__pragma(warning(disable: 4996 ))
# define SOCI_ALLOW_DEPRECATED_END \
__pragma(warning(pop))
# define SOCI_DONT_WARN(statement) statement
#else
# pragma message("WARNING: SOCI_ALLOW_DEPRECATED_* not available for this compilet")
# define SOCI_ALLOW_DEPRECATED_BEGIN
# define SOCI_ALLOW_DEPRECATED_END
#endif
#define SOCI_NOT_ASSIGNABLE(classname) \
public: \
classname(const classname&) = default; \

View File

@@ -45,9 +45,7 @@ std::size_t blob::get_len()
std::size_t blob::read(std::size_t offset, void *buf, std::size_t toRead)
{
ensure_initialized();
SOCI_ALLOW_DEPRECATED_BEGIN
return backEnd_->read(offset, buf, toRead);
SOCI_ALLOW_DEPRECATED_END
}
std::size_t blob::read_from_start(void * buf, std::size_t toRead,
@@ -61,9 +59,7 @@ std::size_t blob::write(
std::size_t offset, const void * buf, std::size_t toWrite)
{
ensure_initialized();
SOCI_ALLOW_DEPRECATED_BEGIN
return backEnd_->write(offset, buf, toWrite);
SOCI_ALLOW_DEPRECATED_END
}
std::size_t blob::write_from_start(const void * buf, std::size_t toWrite,

View File

@@ -193,9 +193,7 @@ SOCI_DECL int soci_blob_read(blob_handle b, int offset, char *buf, int toRead)
blob_wrapper *blob = static_cast<blob_wrapper *>(b);
try
{
SOCI_ALLOW_DEPRECATED_BEGIN
return static_cast<int>(blob->blob_.read(offset, buf, toRead));
SOCI_ALLOW_DEPRECATED_END
}
catch (std::exception &e)
{
@@ -237,9 +235,7 @@ SOCI_DECL int soci_blob_write(blob_handle b, int offset, char const *buf, int to
blob_wrapper *blob = static_cast<blob_wrapper *>(b);
try
{
SOCI_ALLOW_DEPRECATED_BEGIN
return static_cast<int>(blob->blob_.write(offset, buf, toWrite));
SOCI_ALLOW_DEPRECATED_END
}
catch (std::exception &e)
{