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

Reader class for reading a manifest. More...

#include <c2pa.hpp>

Public Member Functions

 Reader (const std::string &format, std::istream &stream)
 Create a Reader from a stream.
 
 Reader (const std::filesystem::path &source_path)
 Create a Reader from a file path.
 
 ~Reader ()
 
bool is_embedded () const
 Returns 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.
 
string json ()
 Get the manifest as a json string.
 
int64_t get_resource (const string &uri, const std::filesystem::path &path)
 Get a resource from the reader and write it to a file.
 
int64_t get_resource (const 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 ()
 Returns a vector of mime types that the SDK is able to read manifests from.
 

Detailed Description

Reader class for reading a manifest.

This class is used to read and validate a manifest from a stream or file.

Constructor & Destructor Documentation

◆ Reader() [1/2]

c2pa::Reader::Reader ( const std::string &  format,
std::istream &  stream 
)

Create a Reader from a stream.

The validation_status field in the json contains validation results.

Parameters
formatThe mime format of the stream.
streamThe input stream to read from.
Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.

◆ Reader() [2/2]

c2pa::Reader::Reader ( const std::filesystem::path &  source_path)

Create a Reader from a file path.

Parameters
source_paththe path to the file to read.
Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.

◆ ~Reader()

c2pa::Reader::~Reader ( )

Member Function Documentation

◆ get_api_internal_raw_reader()

C2paReader * c2pa::Reader::get_api_internal_raw_reader ( ) const
inline

Get the raw C2paReader pointer.

Returns
The raw C2paReader pointer.
Note
This is intended for internal API use and compatibility with C APIs.
230{ return c2pa_reader; }

◆ get_resource() [1/2]

int64_t c2pa::Reader::get_resource ( const string &  uri,
const std::filesystem::path &  path 
)

Get a resource from the reader and write it to a file.

Parameters
uriThe uri of the resource.
pathThe path to write the resource to.
Returns
The number of bytes written.
Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.

◆ get_resource() [2/2]

int64_t c2pa::Reader::get_resource ( const string &  uri,
std::ostream &  stream 
)

Get a resource from the reader and write it to an output stream.

Parameters
uriThe uri of the resource.
streamThe output stream to write the resource to.
Returns
The number of bytes written.
Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.

◆ is_embedded()

bool c2pa::Reader::is_embedded ( ) const
inline

Returns if the reader was created from an embedded manifest.

Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.
199 {
200 return c2pa_reader_is_embedded(c2pa_reader);
201 }

◆ json()

string c2pa::Reader::json ( )

Get the manifest as a json string.

Returns
The manifest as a json string.
Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.

◆ remote_url()

std::optional< std::string > c2pa::Reader::remote_url ( ) const

Returns the remote url of the manifest if this Reader obtained the manifest remotely.

Exceptions
C2pa::C2paExceptionfor errors encountered by the C2PA library.

◆ supported_mime_types()

static std::vector< std::string > c2pa::Reader::supported_mime_types ( )
static

Returns a vector of mime types that the SDK is able to read manifests from.


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