c2pa-c
C++ API for c2pa-c library
Loading...
Searching...
No Matches
c2pa Namespace Reference

Namespaces

namespace  detail
 

Classes

class  Builder
 Builder class for creating a manifest. More...
 
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  Context
 C2PA context implementing IContextProvider. More...
 
class  CppIOStream
 IOStream Class wrapper for C2paStream. More...
 
class  CppIStream
 Input stream IStream wrapper for C2paStream. More...
 
class  CppOStream
 Output stream OStream wrapper for C2paStream. More...
 
class  IContextProvider
 Interface for types that can provide C2PA context functionality. More...
 
class  Reader
 Reader class for reading a manifest. More...
 
class  Settings
 (C2PA SDK) Settings configuration object for creating contexts. More...
 
class  Signer
 Signer class for creating a Signer. More...
 

Typedefs

typedef C2paSignerInfo SignerInfo
 Type alias for C2paSignerInfo from the C API.
 
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...
 

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.
 
void load_settings (const std::string &data, const std::string &format)
 Load C2PA settings from a string in a given format.
 
std::optional< std::string > read_file (const std::filesystem::path &source_path, const std::optional< std::filesystem::path > data_dir=std::nullopt)
 Read a file and return the manifest JSON.
 
std::string read_ingredient_file (const std::filesystem::path &source_path, const std::filesystem::path &data_dir)
 Read a file and return an ingredient JSON.
 
void sign_file (const std::filesystem::path &source_path, const std::filesystem::path &dest_path, const char *manifest, SignerInfo *signer_info, const std::optional< std::filesystem::path > data_dir=std::nullopt)
 Add a manifest and sign a file.
 

Typedef Documentation

◆ SignerFunc

using c2pa::SignerFunc = typedef 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

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)

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

◆ StreamError

enum class c2pa::StreamError : int
strong

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

Enumerator
InvalidArgument 
IoError 
NoBufferSpace 
69 : int {
70 InvalidArgument = EINVAL,
71 IoError = EIO,
72 NoBufferSpace = ENOBUFS
73 };

Function Documentation

◆ load_settings()

void c2pa::load_settings ( const std::string &  data,
const std::string &  format 
)

Load C2PA settings from a string in a given format.

Parameters
dataThe configuration data to load.
formatThe mimetype of the string.
Exceptions
C2paExceptionfor errors encountered by the C2PA library.
Deprecated:
Use Context constructors or Context::ContextBuilder instead for better thread safety.

◆ read_file()

std::optional< std::string > c2pa::read_file ( const std::filesystem::path &  source_path,
const std::optional< std::filesystem::path >  data_dir = std::nullopt 
)

Read a file and return the manifest JSON.

Parameters
source_pathThe path to the file to read.
data_dirOptional directory to store binary resources.
Returns
Optional string containing the manifest JSON if a manifest was found.
Exceptions
C2paExceptionfor errors encountered by the C2PA library.
Deprecated:
Use Reader object instead.

◆ read_ingredient_file()

std::string c2pa::read_ingredient_file ( const std::filesystem::path &  source_path,
const std::filesystem::path &  data_dir 
)

Read a file and return an ingredient JSON.

Parameters
source_pathThe path to the file to read.
data_dirThe directory to store binary resources.
Returns
String containing the ingredient JSON.
Exceptions
C2paExceptionfor errors encountered by the C2PA library.
Deprecated:
Use Reader and Builder.add_ingredient instead.

◆ sign_file()

void c2pa::sign_file ( const std::filesystem::path &  source_path,
const std::filesystem::path &  dest_path,
const char *  manifest,
SignerInfo signer_info,
const std::optional< std::filesystem::path >  data_dir = std::nullopt 
)

Add a manifest and sign a file.

Parameters
source_pathThe path to the asset to be signed.
dest_pathThe path to write the signed file to.
manifestThe manifest JSON to add to the file.
signer_infoThe signer info to use for signing.
data_dirOptional directory to store binary resources.
Exceptions
C2paExceptionfor errors encountered by the C2PA library.
Deprecated:
Use Builder.sign instead.

◆ 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.
78 {
79 errno = static_cast<int>(e);
80 return static_cast<int>(OperationResult::Error);
81 }

◆ version()

std::string c2pa::version ( )

Get the version of the C2PA library.

Returns
Version string.