From 747d7fef6c56ebe48ef4d1ebfc8e008ae1eef264 Mon Sep 17 00:00:00 2001 From: ok-nick Date: Fri, 27 Mar 2026 16:38:43 -0400 Subject: [PATCH 1/5] feat: `ContextBuilder::release` to get owned underlying FFI context builder --- include/c2pa.hpp | 6 ++++++ src/c2pa_context.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/include/c2pa.hpp b/include/c2pa.hpp index 777368d..8291836 100644 --- a/include/c2pa.hpp +++ b/include/c2pa.hpp @@ -321,6 +321,12 @@ namespace c2pa /// @return Pointer to the C2paContextBuilder object, or nullptr if moved from. C2paContextBuilder* c2pa_context_builder() const noexcept; + /// @brief Release ownership of the underlying C2paContextBuilder pointer. + /// @return Pointer to the C2paContextBuilder object, or nullptr if moved from. + /// @note After this call, the ContextBuilder no longer owns the pointer and is_valid() returns false. + /// The caller is responsible for managing the lifetime of the returned pointer. + C2paContextBuilder* release() noexcept; + private: C2paContextBuilder* context_builder; }; diff --git a/src/c2pa_context.cpp b/src/c2pa_context.cpp index f60e0c8..07b7015 100644 --- a/src/c2pa_context.cpp +++ b/src/c2pa_context.cpp @@ -158,6 +158,10 @@ namespace c2pa return context_builder; } + C2paContextBuilder* Context::ContextBuilder::release() noexcept { + return std::exchange(context_builder, nullptr); + } + Context Context::ContextBuilder::create_context() { if (!is_valid()) { throw C2paException("ContextBuilder is invalid (moved from)"); From 4db4b447afbeea81b8695db311eb35394ac3ce02 Mon Sep 17 00:00:00 2001 From: ok-nick Date: Fri, 27 Mar 2026 16:39:47 -0400 Subject: [PATCH 2/5] fix: remove `ContextBuilder::c2pa_context_builder` --- include/c2pa.hpp | 3 --- src/c2pa_context.cpp | 4 ---- 2 files changed, 7 deletions(-) diff --git a/include/c2pa.hpp b/include/c2pa.hpp index 8291836..056363f 100644 --- a/include/c2pa.hpp +++ b/include/c2pa.hpp @@ -317,9 +317,6 @@ namespace c2pa /// @note This consumes the builder. After calling this, is_valid() returns false. [[nodiscard]] Context create_context(); - /// @brief Get the underlying C2paContextBuilder pointer. - /// @return Pointer to the C2paContextBuilder object, or nullptr if moved from. - C2paContextBuilder* c2pa_context_builder() const noexcept; /// @brief Release ownership of the underlying C2paContextBuilder pointer. /// @return Pointer to the C2paContextBuilder object, or nullptr if moved from. diff --git a/src/c2pa_context.cpp b/src/c2pa_context.cpp index 07b7015..480d4f3 100644 --- a/src/c2pa_context.cpp +++ b/src/c2pa_context.cpp @@ -154,10 +154,6 @@ namespace c2pa return *this; } - C2paContextBuilder* Context::ContextBuilder::c2pa_context_builder() const noexcept { - return context_builder; - } - C2paContextBuilder* Context::ContextBuilder::release() noexcept { return std::exchange(context_builder, nullptr); } From 1a4b566cec357dc05b767dd406ddeae7855c638a Mon Sep 17 00:00:00 2001 From: ok-nick Date: Fri, 27 Mar 2026 16:40:03 -0400 Subject: [PATCH 3/5] chore: bump version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e9d57a..5148a75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.27) # This is the current version of this C++ project -project(c2pa-c VERSION 0.19.2) +project(c2pa-c VERSION 0.19.3) # Set the version of the c2pa_rs library used set(C2PA_VERSION "0.78.6") From dbab479e370881e95240b7795fc807c1506fed3b Mon Sep 17 00:00:00 2001 From: ok-nick Date: Fri, 27 Mar 2026 16:48:08 -0400 Subject: [PATCH 4/5] chore: bump minor to remove recently introduced APIs --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5148a75..1bc4975 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.27) # This is the current version of this C++ project -project(c2pa-c VERSION 0.19.3) +project(c2pa-c VERSION 0.20.0) # Set the version of the c2pa_rs library used set(C2PA_VERSION "0.78.6") From 572f6be56c774bb8205fe64ee01ea888a080d9e6 Mon Sep 17 00:00:00 2001 From: ok-nick Date: Fri, 27 Mar 2026 17:06:03 -0400 Subject: [PATCH 5/5] docs: move note to brief --- include/c2pa.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/c2pa.hpp b/include/c2pa.hpp index 056363f..0d07354 100644 --- a/include/c2pa.hpp +++ b/include/c2pa.hpp @@ -317,11 +317,11 @@ namespace c2pa /// @note This consumes the builder. After calling this, is_valid() returns false. [[nodiscard]] Context create_context(); - /// @brief Release ownership of the underlying C2paContextBuilder pointer. + /// After this call, the ContextBuilder no longer owns the pointer + /// and is_valid() returns false. The caller is responsible for managing + /// the lifetime of the returned pointer. /// @return Pointer to the C2paContextBuilder object, or nullptr if moved from. - /// @note After this call, the ContextBuilder no longer owns the pointer and is_valid() returns false. - /// The caller is responsible for managing the lifetime of the returned pointer. C2paContextBuilder* release() noexcept; private: