c2pa-c
C++ API for c2pa-c library
Loading...
Searching...
No Matches
c2pa::Settings Class Reference

(C2PA SDK) Settings configuration object for creating contexts. More...

#include <c2pa.hpp>

Public Member Functions

 Settings ()
 Create default settings.
 
 Settings (const std::string &data, const std::string &format)
 Create settings from a configuration string.
 
 Settings (Settings &&) noexcept
 
Settingsoperator= (Settings &&) noexcept
 
 Settings (const Settings &)=delete
 
Settingsoperator= (const Settings &)=delete
 
 ~Settings () noexcept
 
bool is_valid () const noexcept
 Check if this Settings object is valid (holds a C settings handle).
 
Settingsset (const std::string &path, const std::string &json_value)
 Set a single configuration value by path.
 
Settingsupdate (const std::string &data)
 Merge configuration from a JSON string (latest configuration wins).
 
Settingsupdate (const std::string &data, const std::string &format)
 Merge configuration from a std::string (latest configuration wins).
 
C2paSettings * c_settings () const noexcept
 Get the raw C FFI settings pointer.
 

Detailed Description

(C2PA SDK) Settings configuration object for creating contexts.

Settings can be configured via JSON strings or programmatically via set() and update() methods. Once passed to Context::ContextBuilder, the settings are copied into the context and the Settings object can be reused or discarded.

Validity
Settings uses is_valid() to indicate whether the object holds a valid underlying C settings handle. After move-from, is_valid() is false. set(), update(), and callers passing this object to the C API must ensure is_valid() is true or check before use.

Constructor & Destructor Documentation

◆ Settings() [1/4]

c2pa::Settings::Settings ( )

Create default settings.

◆ Settings() [2/4]

c2pa::Settings::Settings ( const std::string &  data,
const std::string &  format 
)

Create settings from a configuration string.

Parameters
dataConfiguration data in JSON format.
formatFormat of the data ("json").
Exceptions
C2paExceptionif parsing fails.

◆ Settings() [3/4]

c2pa::Settings::Settings ( Settings &&  )
noexcept

◆ Settings() [4/4]

c2pa::Settings::Settings ( const Settings )
delete

◆ ~Settings()

c2pa::Settings::~Settings ( )
noexcept

Member Function Documentation

◆ c_settings()

C2paSettings * c2pa::Settings::c_settings ( ) const
noexcept

Get the raw C FFI settings pointer.

Returns
Pointer to C2paSettings when is_valid() is true; nullptr when invalid.
Note
Callers passing this to the C API should check is_valid() first and treat nullptr as invalid.

◆ is_valid()

bool c2pa::Settings::is_valid ( ) const
noexcept

Check if this Settings object is valid (holds a C settings handle).

Returns
true if the object can be used (set, update, c_settings, or passed to Context/ContextBuilder).
false if moved-from (or otherwise invalid). Callers must check before use.

◆ operator=() [1/2]

Settings & c2pa::Settings::operator= ( const Settings )
delete

◆ operator=() [2/2]

Settings & c2pa::Settings::operator= ( Settings &&  )
noexcept

◆ set()

Settings & c2pa::Settings::set ( const std::string &  path,
const std::string &  json_value 
)

Set a single configuration value by path.

Parameters
pathDot-separated path to the setting (e.g., "verify.verify_after_sign").
json_valueJSON-encoded value to set.
Returns
Reference to this Settings for method chaining.
Exceptions
C2paExceptionif the path or value is invalid.

◆ update() [1/2]

Settings & c2pa::Settings::update ( const std::string &  data)
inline

Merge configuration from a JSON string (latest configuration wins).

Parameters
dataConfiguration data in JSON format.
Returns
Reference to this Settings for method chaining.
Exceptions
C2paExceptionif parsing fails, or if this object is invalid.
Note
This is the recommended overload when configuration is JSON.
222{ return update(data, "json"); }
Settings & update(const std::string &data)
Merge configuration from a JSON string (latest configuration wins).
Definition c2pa.hpp:222

◆ update() [2/2]

Settings & c2pa::Settings::update ( const std::string &  data,
const std::string &  format 
)

Merge configuration from a std::string (latest configuration wins).

Parameters
dataConfiguration data in JSON or TOML format.
formatFormat of the data ("json" or "toml").
Returns
Reference to this Settings for method chaining.
Exceptions
C2paExceptionif parsing fails, or if this object is invalid.

The documentation for this class was generated from the following file: