c2pa-cpp v0.27.0
C++ API for the C2PA SDK
Loading...
Searching...
No Matches
c2pa Namespace Reference

Namespaces

namespace  detail

Classes

class  C2paException
 Exception class for C2pa errors. This class is used to throw exceptions for errors encountered by the C2pa library via c2pa_error(). More...
class  IContextProvider
 Interface for types that can provide C2PA context functionality. More...
class  Settings
 (C2PA SDK) Settings configuration object for creating contexts. More...
class  Context
 C2PA context implementing IContextProvider. More...
class  C2paStream
 Common owning base for C++ wrappers of opaque C2paStream handles. More...
class  CppIStream
 Input stream IStream wrapper for C2paStream. More...
class  CppOStream
 Output stream OStream wrapper for C2paStream. More...
class  CppIOStream
 IOStream Class wrapper for C2paStream. More...
class  Reader
 Reader class for reading a manifest. More...
class  Signer
 Signer class for creating a Signer. More...
class  Builder
 Builder class for creating a manifest. More...

Typedefs

typedef C2paSignerInfo SignerInfo
 Type alias for C2paSignerInfo from the C API.
using ProgressCallbackFunc = std::function<bool(ProgressPhase phase, uint32_t step, uint32_t total)>
 Type alias for the progress callback passed to ContextBuilder::with_progress_callback().
using SignerFunc = std::vector<unsigned char>(const std::vector<unsigned char> &)
 Signer callback function type.

Enumerations

enum class  OperationResult : int { Success = 0 , Error = -1 }
 Result codes for C API operations (matches C API return convention). More...
enum class  StreamError : int { InvalidArgument = EINVAL , IoError = EIO , NoBufferSpace = ENOBUFS }
 Stream/FFI error codes (maps to errno values used by the C layer). More...
enum class  ProgressPhase : uint8_t {
  Reading = 0 , VerifyingManifest = 1 , VerifyingSignature = 2 , VerifyingIngredient = 3 ,
  VerifyingAssetHash = 4 , AddingIngredient = 5 , Thumbnail = 6 , Hashing = 7 ,
  Signing = 8 , Embedding = 9 , FetchingRemoteManifest = 10 , Writing = 11 ,
  FetchingOCSP = 12 , FetchingTimestamp = 13
}
 Phase values reported to the ProgressCallbackFunc. More...

Functions

int stream_error_return (StreamError e) noexcept
 Set errno from StreamError and return error sentinel.
std::string version ()
 Get the version of the C2PA library.

Typedef Documentation

◆ ProgressCallbackFunc

using c2pa::ProgressCallbackFunc = std::function<bool(ProgressPhase phase, uint32_t step, uint32_t total)>

Type alias for the progress callback passed to ContextBuilder::with_progress_callback().

The callback is invoked at each major phase of signing and reading operations. Returning false from the callback aborts the operation with an OperationCancelled error (equivalent to calling Context::cancel()).

Parameters
phaseCurrent operation phase.
step1-based step index within the phase. 0 = indeterminate (use as liveness signal); resets to 1 at each new phase.
total0 = indeterminate; 1 = single-shot; >1 = determinate (step/total = fraction).
Returns
true to continue the operation, false to request cancellation.
Note
The callback must not throw. If it throws, the implementation catches the exception and reports cancellation to the underlying library (same as returning false); the original exception is not propagated. Prefer returning false or using Context::cancel() instead of throwing.

◆ SignerFunc

using c2pa::SignerFunc = std::vector<unsigned char>(const std::vector<unsigned char> &)

Signer callback function type.

This function type is used to create a callback function for signing. The callback receives data to sign and returns the signature.

Parameters
dataThe data to sign.
Returns
The signature as a vector of bytes.

◆ SignerInfo

typedef C2paSignerInfo c2pa::SignerInfo

Type alias for C2paSignerInfo from the C API.

Enumeration Type Documentation

◆ OperationResult

enum class c2pa::OperationResult : int
strong

Result codes for C API operations (matches C API return convention).

Enumerator
Success 

Operation succeeded.

Error 

Operation failed (check C2paException for details).

64 : int {
65 Success = 0, ///< Operation succeeded
66 Error = -1 ///< Operation failed (check C2paException for details)
67 };
@ Success
Operation succeeded.
Definition c2pa.hpp:65
@ Error
Operation failed (check C2paException for details).
Definition c2pa.hpp:66

◆ ProgressPhase

enum class c2pa::ProgressPhase : uint8_t
strong

Phase values reported to the ProgressCallbackFunc.

A scoped C++ mirror of C2paProgressPhase from c2pa.h. Values are verified at compile time to match the C enum, so any future divergence in c2pa-rs will be caught as a build error.

Phases emitted during a typical sign cycle (in order): AddingIngredient → Thumbnail → Hashing → Signing → Embedding → (if verify_after_sign) VerifyingManifest → VerifyingSignature → VerifyingAssetHash → VerifyingIngredient

Phases emitted during reading: Reading → VerifyingManifest → VerifyingSignature → VerifyingAssetHash → VerifyingIngredient

Enumerator
Reading 
VerifyingManifest 
VerifyingSignature 
VerifyingIngredient 
VerifyingAssetHash 
AddingIngredient 
Thumbnail 
Hashing 
Signing 
Embedding 
FetchingRemoteManifest 
Writing 
FetchingOCSP 
FetchingTimestamp 
265 : uint8_t {
266 Reading = 0,
272 Thumbnail = 6,
273 Hashing = 7,
274 Signing = 8,
275 Embedding = 9,
277 Writing = 11,
278 FetchingOCSP = 12,
280 };
@ VerifyingIngredient
Definition c2pa.hpp:269
@ VerifyingManifest
Definition c2pa.hpp:267
@ AddingIngredient
Definition c2pa.hpp:271
@ Reading
Definition c2pa.hpp:266
@ VerifyingSignature
Definition c2pa.hpp:268
@ VerifyingAssetHash
Definition c2pa.hpp:270
@ Embedding
Definition c2pa.hpp:275
@ Signing
Definition c2pa.hpp:274
@ Writing
Definition c2pa.hpp:277
@ FetchingRemoteManifest
Definition c2pa.hpp:276
@ FetchingOCSP
Definition c2pa.hpp:278
@ Thumbnail
Definition c2pa.hpp:272
@ Hashing
Definition c2pa.hpp:273
@ FetchingTimestamp
Definition c2pa.hpp:279

◆ StreamError

enum class c2pa::StreamError : int
strong

Stream/FFI error codes (maps to errno values used by the C layer).

Enumerator
InvalidArgument 
IoError 
NoBufferSpace 
70 : int {
71 InvalidArgument = EINVAL,
72 IoError = EIO,
73 NoBufferSpace = ENOBUFS
74 };
@ InvalidArgument
Definition c2pa.hpp:71
@ NoBufferSpace
Definition c2pa.hpp:73
@ IoError
Definition c2pa.hpp:72

Function Documentation

◆ stream_error_return()

int c2pa::stream_error_return ( StreamError e)
inlinenoexcept

Set errno from StreamError and return error sentinel.

Parameters
eThe StreamError value to convert to errno.
Returns
OperationResult::Error (-1) for use as C API error return.
79 {
80 errno = static_cast<int>(e);
81 return static_cast<int>(OperationResult::Error);
82 }

◆ version()

std::string c2pa::version ( )

Get the version of the C2PA library.

Returns
Version string.