From acc9605fb99f3125e15a345a5bacdc4c1ce8439c Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Thu, 2 May 2024 22:28:29 -0700 Subject: [PATCH] cleanup: more old style format deprecation (#4247) Remove some long-ago deprecated printf-like error functions. Mark as deprecated some other ones that we will remove when it gets closer to 3.0 release. I think these are the very last uses internally of the old style that we want to remove. Signed-off-by: Larry Gritz --- src/include/OpenImageIO/imagebuf.h | 18 ------------------ src/include/OpenImageIO/imageio.h | 2 ++ src/libOpenImageIO/imagebuf_test.cpp | 2 +- src/libOpenImageIO/imagebufalgo_xform.cpp | 6 +++--- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/include/OpenImageIO/imagebuf.h b/src/include/OpenImageIO/imagebuf.h index 937361974c..92630e10bf 100644 --- a/src/include/OpenImageIO/imagebuf.h +++ b/src/include/OpenImageIO/imagebuf.h @@ -1056,15 +1056,6 @@ class OIIO_API ImageBuf { error(Strutil::fmt::format(fmt, args...)); } - /// Error reporting for ImageBuf: call this with printf-like arguments - /// to report an error. It is not necessary to have the error message - /// contain a trailing newline. - template - void errorf(const char* fmt, const Args&... args) const - { - error(Strutil::sprintf(fmt, args...)); - } - /// Error reporting for ImageBuf: call this with Strutil::format /// formatting conventions. It is not necessary to have the error /// message contain a trailing newline. Beware, this is in transition, @@ -1076,15 +1067,6 @@ class OIIO_API ImageBuf { error(Strutil::format(fmt, args...)); } - // Error reporting for ImageBuf: call this with Python / {fmt} / - // std::format style formatting specification. - template - OIIO_DEPRECATED("use `errorfmt` instead") - void fmterror(const char* fmt, const Args&... args) const - { - error(Strutil::fmt::format(fmt, args...)); - } - /// Returns `true` if the ImageBuf has had an error and has an error /// message ready to retrieve via `geterror()`. bool has_error(void) const; diff --git a/src/include/OpenImageIO/imageio.h b/src/include/OpenImageIO/imageio.h index 9de735137b..953e115a98 100644 --- a/src/include/OpenImageIO/imageio.h +++ b/src/include/OpenImageIO/imageio.h @@ -1690,6 +1690,7 @@ class OIIO_API ImageInput { /// printf-like arguments. It is not necessary to have the error message /// contain a trailing newline. template + OIIO_FORMAT_DEPRECATED void errorf(const char* fmt, const Args&... args) const { append_error(Strutil::sprintf (fmt, args...)); } @@ -2485,6 +2486,7 @@ class OIIO_API ImageOutput { /// printf-like arguments. It is not necessary to have the error message /// contain a trailing newline. template + OIIO_FORMAT_DEPRECATED void errorf(const char* fmt, const Args&... args) const { append_error(Strutil::sprintf (fmt, args...)); } diff --git a/src/libOpenImageIO/imagebuf_test.cpp b/src/libOpenImageIO/imagebuf_test.cpp index a4222bbad8..8ff5188059 100644 --- a/src/libOpenImageIO/imagebuf_test.cpp +++ b/src/libOpenImageIO/imagebuf_test.cpp @@ -506,7 +506,7 @@ static void test_uncaught_error() { ImageBuf buf; - buf.error("Boo!"); + buf.errorfmt("Boo!"); // buf exists scope and is destroyed without anybody retrieving the error. } diff --git a/src/libOpenImageIO/imagebufalgo_xform.cpp b/src/libOpenImageIO/imagebufalgo_xform.cpp index 43e422f89c..639021ff70 100644 --- a/src/libOpenImageIO/imagebufalgo_xform.cpp +++ b/src/libOpenImageIO/imagebufalgo_xform.cpp @@ -1591,7 +1591,7 @@ check_st_warp_args(ImageBuf& dst, const ImageBuf& src, const ImageBuf& stbuf, { // Validate ST buffer if (!stbuf.initialized()) { - dst.error("ImageBufAlgo::st_warp : Uninitialized ST buffer"); + dst.errorfmt("ImageBufAlgo::st_warp : Uninitialized ST buffer"); return false; } @@ -1690,7 +1690,7 @@ ImageBufAlgo::st_warp(const ImageBuf& src, const ImageBuf& stbuf, bool ok = st_warp(result, src, stbuf, filter, chan_s, chan_t, flip_s, flip_t, roi, nthreads); if (!ok && !result.has_error()) { - result.error("ImageBufAlgo::st_warp : Unknown error"); + result.errorfmt("ImageBufAlgo::st_warp : Unknown error"); } return result; } @@ -1707,7 +1707,7 @@ ImageBufAlgo::st_warp(const ImageBuf& src, const ImageBuf& stbuf, bool ok = st_warp(result, src, stbuf, filtername, filterwidth, chan_s, chan_t, flip_s, flip_t, roi, nthreads); if (!ok && !result.has_error()) { - result.error("ImageBufAlgo::st_warp : Unknown error"); + result.errorfmt("ImageBufAlgo::st_warp : Unknown error"); } return result; }