|
c2pa-c
C++ API for c2pa-c library
|
Reader class for reading a manifest. More...
#include <c2pa.hpp>
Public Member Functions | |
| Reader (IContextProvider &context, const std::string &format, std::istream &stream) | |
| Create a Reader from a context and stream. | |
| Reader (IContextProvider &context, const std::filesystem::path &source_path) | |
| Create a Reader from a context and file path. | |
| Reader (const std::string &format, std::istream &stream) | |
| Create a Reader from a stream (will use global settings if any loaded). | |
| Reader (const std::filesystem::path &source_path) | |
| Create a Reader from a file path (will use global settings if any loaded). | |
| Reader (const Reader &)=delete | |
| Reader & | operator= (const Reader &)=delete |
| Reader (Reader &&other) noexcept | |
| Reader & | operator= (Reader &&other) noexcept |
| ~Reader () | |
| bool | is_embedded () const |
| Check if the reader was created from an embedded manifest. | |
| std::optional< std::string > | remote_url () const |
Returns the remote url of the manifest if this Reader obtained the manifest remotely. | |
| std::string | json () const |
| Get the manifest as a JSON string. | |
| int64_t | get_resource (const std::string &uri, const std::filesystem::path &path) |
| Get a resource from the reader and write it to a file. | |
| int64_t | get_resource (const std::string &uri, std::ostream &stream) |
| Get a resource from the reader and write it to an output stream. | |
| C2paReader * | get_api_internal_raw_reader () const |
| Get the raw C2paReader pointer. | |
Static Public Member Functions | |
| static std::vector< std::string > | supported_mime_types () |
| Get a list of mime types that the SDK can read manifests from. | |
Reader class for reading a manifest.
This class is used to read and validate a manifest from a stream or file. Resources are managed using RAII; member order ensures cpp_stream (which holds a C stream pointing at the ifstream) is destroyed before owned_stream.
| c2pa::Reader::Reader | ( | IContextProvider & | context, |
| const std::string & | format, | ||
| std::istream & | stream | ||
| ) |
Create a Reader from a context and stream.
| context | Context provider; used at construction to configure settings. |
| format | The mime format of the stream. |
| stream | The input stream to read from. |
| C2paException | if context.is_valid() returns false, or for other errors encountered by the C2PA library. |
| c2pa::Reader::Reader | ( | IContextProvider & | context, |
| const std::filesystem::path & | source_path | ||
| ) |
Create a Reader from a context and file path.
| context | Context provider; used at construction only to configure settings. |
| source_path | The path to the file to read. |
| C2paException | if context.is_valid() returns false, or for other errors encountered by the C2PA library. |
| c2pa::Reader::Reader | ( | const std::string & | format, |
| std::istream & | stream | ||
| ) |
Create a Reader from a stream (will use global settings if any loaded).
The validation_status field in the JSON contains validation results.
| format | The mime format of the stream. |
| stream | The input stream to read from. |
| C2paException | for errors encountered by the C2PA library. |
| c2pa::Reader::Reader | ( | const std::filesystem::path & | source_path | ) |
Create a Reader from a file path (will use global settings if any loaded).
| source_path | The path to the file to read. |
| C2paException | for errors encountered by the C2PA library. |
|
delete |
|
inlinenoexcept |
| c2pa::Reader::~Reader | ( | ) |
|
inline |
Get the raw C2paReader pointer.
| int64_t c2pa::Reader::get_resource | ( | const std::string & | uri, |
| const std::filesystem::path & | path | ||
| ) |
Get a resource from the reader and write it to a file.
| uri | The URI of the resource. |
| path | The file path to write the resource to. |
| C2paException | for errors encountered by the C2PA library. |
| int64_t c2pa::Reader::get_resource | ( | const std::string & | uri, |
| std::ostream & | stream | ||
| ) |
Get a resource from the reader and write it to an output stream.
| uri | The URI of the resource. |
| stream | The output stream to write the resource to. |
| C2paException | for errors encountered by the C2PA library. |
|
inline |
Check if the reader was created from an embedded manifest.
| C2paException | for errors encountered by the C2PA library. |
| std::string c2pa::Reader::json | ( | ) | const |
Get the manifest as a JSON string.
| C2paException | for errors encountered by the C2PA library. |
| std::optional< std::string > c2pa::Reader::remote_url | ( | ) | const |
Returns the remote url of the manifest if this Reader obtained the manifest remotely.
| C2paException | for errors encountered by the C2PA library. |
|
static |
Get a list of mime types that the SDK can read manifests from.