|
c2pa-c
C++ API for c2pa-c library
|
Builder class for creating a manifest. More...
#include <c2pa.hpp>
Public Member Functions | |
| Builder (const std::string &manifest_json) | |
| Create a Builder from a manifest JSON string. | |
| ~Builder () | |
| void | set_no_embed () |
| Set the no embed flag. | |
| void | set_remote_url (const string &remote_url) |
| Set the remote URL. | |
| void | set_base_path (const string &base_path) |
| Set the base path for loading resources from files. Loads from memory if this is not set. | |
| void | add_resource (const string &uri, istream &source) |
| Add a resource to the builder. | |
| void | add_resource (const string &uri, const std::filesystem::path &source_path) |
| Add a resource to the builder. | |
| void | add_ingredient (const string &ingredient_json, const string &format, istream &source) |
| Add an ingredient to the builder. | |
| void | add_ingredient (const string &ingredient_json, const std::filesystem::path &source_path) |
| Add an ingredient to the builder. | |
| void | add_action (const string &action_json) |
| Add an action to the manifest the Builder is constructing. | |
| std::vector< unsigned char > | sign (const string &format, istream &source, ostream &dest, Signer &signer) |
| Sign an input stream and write the signed data to an output stream. | |
| std::vector< unsigned char > | sign (const string &format, istream &source, iostream &dest, Signer &signer) |
| Sign an input stream and write the signed data to an output stream. | |
| std::vector< unsigned char > | sign (const path &source_path, const path &dest_path, Signer &signer) |
| Sign a file and write the signed data to an output file. | |
| void | to_archive (ostream &dest) |
| Write the builder to an archive stream. | |
| void | to_archive (const path &dest_path) |
| Write the builder to an archive file. | |
| std::vector< unsigned char > | data_hashed_placeholder (uintptr_t reserved_size, const string &format) |
| Create a hashed placeholder from the builder. | |
| std::vector< unsigned char > | sign_data_hashed_embeddable (Signer &signer, const string &data_hash, const string &format, istream *asset=nullptr) |
| Sign a Builder using the specified signer and data hash. | |
Static Public Member Functions | |
| static Builder | from_archive (istream &archive) |
| Create a Builder from an archive. | |
| static Builder | from_archive (const std::filesystem::path &archive_path) |
| Create a Builder from an archive. | |
| static std::vector< unsigned char > | format_embeddable (const string &format, std::vector< unsigned char > &data) |
| convert an unformatted manifest data to an embeddable format. | |
| static std::vector< std::string > | supported_mime_types () |
| Returns a vector of mime types that the SDK is able to sign. | |
Builder class for creating a manifest.
This class is used to create a manifest from a json string and add resources and ingredients to the manifest.
| c2pa::Builder::Builder | ( | const std::string & | manifest_json | ) |
Create a Builder from a manifest JSON string.
| manifest_json | The manifest JSON string. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| c2pa::Builder::~Builder | ( | ) |
| void c2pa::Builder::add_action | ( | const string & | action_json | ) |
Add an action to the manifest the Builder is constructing.
| action_json | JSON string containing the action data. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| void c2pa::Builder::add_ingredient | ( | const string & | ingredient_json, |
| const std::filesystem::path & | source_path | ||
| ) |
Add an ingredient to the builder.
| ingredient_json | Any fields of the ingredient you want to define. |
| source_path | The path to the ingredient file. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| void c2pa::Builder::add_ingredient | ( | const string & | ingredient_json, |
| const string & | format, | ||
| istream & | source | ||
| ) |
Add an ingredient to the builder.
| ingredient_json | Any fields of the ingredient you want to define. |
| format | The format of the ingredient file. |
| source | The input stream to read the ingredient from. |
| C2pa::C2paException | for errors encountered by the C2pa library. |
| void c2pa::Builder::add_resource | ( | const string & | uri, |
| const std::filesystem::path & | source_path | ||
| ) |
Add a resource to the builder.
| uri | The uri of the resource. |
| source_path | The path to the resource file. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| void c2pa::Builder::add_resource | ( | const string & | uri, |
| istream & | source | ||
| ) |
Add a resource to the builder.
| uri | The uri of the resource. |
| source | The input stream to read the resource from. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| std::vector< unsigned char > c2pa::Builder::data_hashed_placeholder | ( | uintptr_t | reserved_size, |
| const string & | format | ||
| ) |
Create a hashed placeholder from the builder.
| reserved_size | The size required for a signature from the intended signer. |
| format | The format of the mime type or extension of the asset. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
|
static |
convert an unformatted manifest data to an embeddable format.
| format | The format for embedding into. |
| data | An unformatted manifest data block from sign_data_hashed_embeddable using "c2pa" format. |
|
static |
Create a Builder from an archive.
| archive_path | the path to the archive file |
| C2pa::C2paException | for errors encountered by the C2PA library |
|
static |
Create a Builder from an archive.
| archive | The input stream to read the archive from. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| void c2pa::Builder::set_base_path | ( | const string & | base_path | ) |
Set the base path for loading resources from files. Loads from memory if this is not set.
| base_path | The base path to set. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
add_resource instead. | void c2pa::Builder::set_no_embed | ( | ) |
Set the no embed flag.
| void c2pa::Builder::set_remote_url | ( | const string & | remote_url | ) |
Set the remote URL.
| remote_url | The remote URL to set. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| std::vector< unsigned char > c2pa::Builder::sign | ( | const path & | source_path, |
| const path & | dest_path, | ||
| Signer & | signer | ||
| ) |
Sign a file and write the signed data to an output file.
| source_path | The path to the file to sign. |
| dest_path | The path to write the signed file to. |
| signer | A signer object to use when signing. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| std::vector< unsigned char > c2pa::Builder::sign | ( | const string & | format, |
| istream & | source, | ||
| iostream & | dest, | ||
| Signer & | signer | ||
| ) |
Sign an input stream and write the signed data to an output stream.
| format | The format of the output stream. |
| source | The input stream to sign. |
| dest | The in/output stream to write the signed data to. |
| signer |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| std::vector< unsigned char > c2pa::Builder::sign | ( | const string & | format, |
| istream & | source, | ||
| ostream & | dest, | ||
| Signer & | signer | ||
| ) |
Sign an input stream and write the signed data to an output stream.
| format | The format of the output stream. |
| source | The input stream to sign. |
| dest | The output stream to write the signed data to. |
| signer |
| C2pa::C2paException | for errors encountered by the C2PA library |
sign(const string&, istream&, iostream&, Signer&) | std::vector< unsigned char > c2pa::Builder::sign_data_hashed_embeddable | ( | Signer & | signer, |
| const string & | data_hash, | ||
| const string & | format, | ||
| istream * | asset = nullptr |
||
| ) |
Sign a Builder using the specified signer and data hash.
| signer | The signer to use for signing. |
| data_hash | The data hash ranges to sign. This must contain hashes unless and asset is provided. |
| format | The mime format for embedding into. Use "c2pa" for an unformatted result. |
| asset | An optional asset to hash according to the data_hash information. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
|
static |
Returns a vector of mime types that the SDK is able to sign.
| void c2pa::Builder::to_archive | ( | const path & | dest_path | ) |
Write the builder to an archive file.
| dest_path | The path to write the archive file to. |
| C2pa::C2paException | for errors encountered by the C2PA library. |
| void c2pa::Builder::to_archive | ( | ostream & | dest | ) |
Write the builder to an archive stream.
| dest | The output stream to write the archive to. |
| C2pa::C2paException | for errors encountered by the C2PA library. |