|
c2pa-c
C++ API for c2pa-c library
|
Classes | |
| struct | StreamSeekTraits |
| Traits (templated): how to seek and get position for a given stream type. More... | |
| struct | StreamSeekTraits< std::iostream > |
| struct | StreamSeekTraits< std::istream > |
| struct | StreamSeekTraits< std::ostream > |
Functions | |
| std::vector< std::string > | c_mime_types_to_vector (const char *const *mime_types, uintptr_t count) |
| Converts a C array of C strings to a std::vector of std::string. | |
| constexpr std::ios_base::seekdir | whence_to_seekdir (C2paSeekMode whence) noexcept |
| Maps C2PA seek mode to std::ios seek direction. | |
| template<typename Stream > | |
| bool | is_stream_usable (Stream *s) noexcept |
| Check if stream is in valid state for I/O operations. | |
| template<typename Stream > | |
| intptr_t | stream_seeker (StreamContext *context, intptr_t offset, C2paSeekMode whence) |
| Seeker impl. | |
| template<typename Stream > | |
| intptr_t | stream_reader (StreamContext *context, uint8_t *buffer, intptr_t size) |
| Reader impl. | |
| template<typename Stream , typename Op > | |
| intptr_t | stream_op (StreamContext *context, Op op) |
| Get stream from context, used by writer and flusher. | |
| template<typename Stream > | |
| intptr_t | stream_writer (StreamContext *context, const uint8_t *buffer, intptr_t size) |
| Writer impl. | |
| template<typename Stream > | |
| intptr_t | stream_flusher (StreamContext *context) |
| Flusher impl. | |
| template<typename StreamType > | |
| std::unique_ptr< StreamType > | open_file_binary (const std::filesystem::path &path) |
| Open a binary file stream with error handling. | |
| std::string | extract_file_extension (const std::filesystem::path &path) noexcept |
| Extract file extension without the leading dot. | |
| template<typename T > | |
| std::string | c_string_to_string (T *c_result) |
| Convert C string result to C++ string with cleanup. | |
| std::vector< unsigned char > | to_byte_vector (const unsigned char *data, int64_t size) |
| Convert C byte array result to C++ vector. | |
|
inline |
Converts a C array of C strings to a std::vector of std::string.
| mime_types | Pointer to an array of C strings (const char*). |
| count | Number of elements in the array. |
This function takes ownership of the input array and frees it using c2pa_free_string_array().
Convert C string result to C++ string with cleanup.
| c_result | Raw C string from C API |
|
inlinenoexcept |
Extract file extension without the leading dot.
| path | Filesystem path |
Check if stream is in valid state for I/O operations.
|
inline |
Open a binary file stream with error handling.
| StreamType | std::ifstream or std::ofstream |
| path | Path to the file |
| intptr_t c2pa::detail::stream_flusher | ( | StreamContext * | context | ) |
Flusher impl.
| intptr_t c2pa::detail::stream_op | ( | StreamContext * | context, |
| Op | op | ||
| ) |
Get stream from context, used by writer and flusher.
| intptr_t c2pa::detail::stream_reader | ( | StreamContext * | context, |
| uint8_t * | buffer, | ||
| intptr_t | size | ||
| ) |
Reader impl.
| intptr_t c2pa::detail::stream_seeker | ( | StreamContext * | context, |
| intptr_t | offset, | ||
| C2paSeekMode | whence | ||
| ) |
Seeker impl.
| intptr_t c2pa::detail::stream_writer | ( | StreamContext * | context, |
| const uint8_t * | buffer, | ||
| intptr_t | size | ||
| ) |
Writer impl.
|
inline |
Convert C byte array result to C++ vector.
| data | Raw byte array from C API |
| size | Size of the byte array (result from C API call) |
This helper extracts the pattern of checking C API results, copying to a vector, and freeing the C-allocated memory. The C API contract is: if result < 0 or data == nullptr, the operation failed.
|
constexprnoexcept |
Maps C2PA seek mode to std::ios seek direction.