libragephoto: add ragephoto_getphotosigns function

- rename libragephoto.py to libragephoto_loader.py
- enforce set CXX standard for WASM build
This commit is contained in:
Syping 2024-03-25 13:06:14 +01:00
parent 1b7c95e735
commit dd60f8d0b7
8 changed files with 53 additions and 18 deletions

View file

@ -19,6 +19,7 @@
#include "ragephoto_cxx.hpp"
#ifdef LIBRAGEPHOTO_CXX_C
#include "RagePhoto.h"
#include <cinttypes>
#endif
#include <cstdlib>
@ -27,10 +28,6 @@
#include <iostream>
#include <iterator>
#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L)
#include <filesystem>
#endif
#ifdef RAGEPHOTO_BENCHMARK
#include <chrono>
#endif
@ -607,11 +604,7 @@ bool RagePhoto::load(const std::string &data)
bool RagePhoto::loadFile(const std::string &filename)
{
#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L)
std::ifstream ifs(std::filesystem::u8path(filename), std::ios::in | std::ios::binary);
#else
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
#endif
if (ifs.is_open()) {
std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
ifs.close();
@ -1382,6 +1375,18 @@ uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat)
return ragePhoto->jpegSign(photoFormat);
}
void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
snprintf(data, size, "%" PRIu64, ragePhoto->jpegSign());
}
void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
snprintf(data, size, "%" PRIu64, ragePhoto->jpegSign(photoFormat));
}
uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data)
{
return RagePhoto::jpegSign(rp_data);