libragephoto: update C API

RagePhotoA: add new C API functions
RagePhotoC: add ragephotodata_clear(), ragephotodata_load(),
ragephotodata_getsavesize(), ragephotodata_getsavesizef(),
ragephotodata_setbufferdefault(), ragephotodata_setbufferoffsets()
This commit is contained in:
Syping 2023-02-20 14:58:41 +01:00
parent e51d50f77e
commit 9807f0d696
3 changed files with 96 additions and 2 deletions

View file

@ -1171,12 +1171,22 @@ void ragephoto_clear(ragephoto_t instance)
ragePhoto->clear(); ragePhoto->clear();
} }
void ragephotodata_clear(RagePhotoData *rp_data)
{
RagePhoto::clear(rp_data);
}
ragephoto_bool_t ragephoto_load(ragephoto_t instance, const char *data, size_t size) ragephoto_bool_t ragephoto_load(ragephoto_t instance, const char *data, size_t size)
{ {
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance); RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
return ragePhoto->load(data, size); return ragePhoto->load(data, size);
} }
ragephoto_bool_t ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, const char *data, size_t size)
{
return RagePhoto::load(rp_data, rp_parser, data, size);
}
ragephoto_bool_t ragephoto_loadfile(ragephoto_t instance, const char *filename) ragephoto_bool_t ragephoto_loadfile(ragephoto_t instance, const char *filename)
{ {
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance); RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
@ -1263,12 +1273,22 @@ size_t ragephoto_getsavesize(ragephoto_t instance)
return ragePhoto->saveSize(); return ragePhoto->saveSize();
} }
size_t ragephotodata_getsavesize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser)
{
return RagePhoto::saveSize(rp_data, rp_parser);
}
size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat) size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat)
{ {
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance); RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
return ragePhoto->saveSize(photoFormat); return ragePhoto->saveSize(photoFormat);
} }
size_t ragephotodata_getsavesizef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, uint32_t photoFormat)
{
return RagePhoto::saveSize(rp_data, rp_parser, photoFormat);
}
ragephoto_bool_t ragephoto_save(ragephoto_t instance, char *data) ragephoto_bool_t ragephoto_save(ragephoto_t instance, char *data)
{ {
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance); RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
@ -1299,12 +1319,22 @@ void ragephoto_setbufferdefault(ragephoto_t instance)
ragePhoto->setBufferDefault(); ragePhoto->setBufferDefault();
} }
void ragephotodata_setbufferdefault(RagePhotoData *rp_data)
{
RagePhoto::setBufferDefault(rp_data);
}
void ragephoto_setbufferoffsets(ragephoto_t instance) void ragephoto_setbufferoffsets(ragephoto_t instance)
{ {
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance); RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
ragePhoto->setBufferOffsets(); ragePhoto->setBufferOffsets();
} }
void ragephotodata_setbufferoffsets(RagePhotoData *rp_data)
{
RagePhoto::setBufferOffsets(rp_data);
}
ragephoto_bool_t ragephoto_setphotodata(ragephoto_t instance, RagePhotoData *rp_data) ragephoto_bool_t ragephoto_setphotodata(ragephoto_t instance, RagePhotoData *rp_data)
{ {
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance); RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);

View file

@ -98,7 +98,15 @@ public:
~RagePhotoA() { ~RagePhotoA() {
ragephoto_close(instance); ragephoto_close(instance);
} }
/** Resets the RagePhoto instance to default values. */ /** Add a custom defined RagePhotoFormatParser. */
void addParser(RagePhotoFormatParser *rp_parser) {
ragephoto_addparser(instance, rp_parser);
}
/** Resets the RagePhotoData object to default values. */
static void clear(RagePhotoData *rp_data) {
ragephotodata_clear(rp_data);
}
/** Resets the RagePhotoData object to default values. */
void clear() { void clear() {
ragephoto_clear(instance); ragephoto_clear(instance);
} }
@ -106,6 +114,10 @@ public:
RagePhotoData* data() { RagePhotoData* data() {
return ragephoto_getphotodata(instance); return ragephoto_getphotodata(instance);
} }
/** Loads a Photo from a const char*. */
static bool load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, const char *data, size_t size) {
return ragephotodata_load(rp_data, rp_parser, data, size);
}
/** Loads a Photo from a const char*. /** Loads a Photo from a const char*.
* \param data Photo data * \param data Photo data
* \param size Photo data size * \param size Photo data size
@ -211,6 +223,14 @@ public:
return ragephoto_savefile(instance, filename); return ragephoto_savefile(instance, filename);
} }
/** Returns the Photo save file size. */ /** Returns the Photo save file size. */
static size_t saveSize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, uint32_t photoFormat) {
return ragephotodata_getsavesizef(rp_data, rp_parser, photoFormat);
}
/** Returns the Photo save file size. */
static size_t saveSize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser) {
return ragephotodata_getsavesize(rp_data, rp_parser);
}
/** Returns the Photo save file size. */
size_t saveSize(uint32_t photoFormat) { size_t saveSize(uint32_t photoFormat) {
return ragephoto_getsavesizef(instance, photoFormat); return ragephoto_getsavesizef(instance, photoFormat);
} }
@ -219,10 +239,18 @@ public:
return ragephoto_getsavesize(instance); return ragephoto_getsavesize(instance);
} }
/** Sets all cross-format Buffer to default size. */ /** Sets all cross-format Buffer to default size. */
static void setBufferDefault(RagePhotoData *rp_data) {
ragephotodata_setbufferdefault(rp_data);
}
/** Sets all cross-format Buffer to default size. */
void setBufferDefault() { void setBufferDefault() {
ragephoto_setbufferdefault(instance); ragephoto_setbufferdefault(instance);
} }
/** Moves all Buffer offsets to correct position. */ /** Moves all Buffer offsets to correct position. */
static void setBufferOffsets(RagePhotoData *rp_data) {
ragephotodata_setbufferoffsets(rp_data);
}
/** Moves all Buffer offsets to correct position. */
void setBufferOffsets() { void setBufferOffsets() {
ragephoto_setbufferoffsets(instance); ragephoto_setbufferoffsets(instance);
} }

View file

@ -45,11 +45,16 @@ LIBRAGEPHOTO_C_BINDING ragephoto_t ragephoto_open();
*/ */
LIBRAGEPHOTO_C_BINDING void ragephoto_addparser(ragephoto_t instance, RagePhotoFormatParser *rp_parser); LIBRAGEPHOTO_C_BINDING void ragephoto_addparser(ragephoto_t instance, RagePhotoFormatParser *rp_parser);
/** Resets the \p ragephoto_t instance to default values. /** Resets the RagePhotoData object to default values.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_BINDING void ragephoto_clear(ragephoto_t instance); LIBRAGEPHOTO_C_BINDING void ragephoto_clear(ragephoto_t instance);
/** Resets the RagePhotoData object to default values.
* \param rp_data RagePhotoData object
*/
LIBRAGEPHOTO_C_BINDING void ragephotodata_clear(RagePhotoData *rp_data);
/** Loads a Photo from a const char*. /** Loads a Photo from a const char*.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data Photo data * \param data Photo data
@ -57,6 +62,14 @@ LIBRAGEPHOTO_C_BINDING void ragephoto_clear(ragephoto_t instance);
*/ */
LIBRAGEPHOTO_C_BINDING ragephoto_bool_t ragephoto_load(ragephoto_t instance, const char *data, size_t size); LIBRAGEPHOTO_C_BINDING ragephoto_bool_t ragephoto_load(ragephoto_t instance, const char *data, size_t size);
/** Loads a Photo from a const char*.
* \param rp_data RagePhotoData object
* \param rp_parser RagePhotoFormatParser parser array
* \param data Photo data
* \param size Photo data size
*/
LIBRAGEPHOTO_C_BINDING ragephoto_bool_t ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, const char *data, size_t size);
/** Loads a Photo from a file. /** Loads a Photo from a file.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param filename File to load * \param filename File to load
@ -125,12 +138,25 @@ LIBRAGEPHOTO_C_BINDING const char* ragephoto_getphototitle(ragephoto_t instance)
*/ */
LIBRAGEPHOTO_C_BINDING size_t ragephoto_getsavesize(ragephoto_t instance); LIBRAGEPHOTO_C_BINDING size_t ragephoto_getsavesize(ragephoto_t instance);
/** Returns the Photo save file size.
* \param rp_data RagePhotoData object
* \param rp_parser RagePhotoFormatParser parser array
*/
LIBRAGEPHOTO_C_BINDING size_t ragephotodata_getsavesize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser);
/** Returns the Photo save file size. /** Returns the Photo save file size.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_BINDING size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat); LIBRAGEPHOTO_C_BINDING size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat);
/** Returns the Photo save file size.
* \param rp_data RagePhotoData object
* \param rp_parser RagePhotoFormatParser parser array
* \param photoFormat Photo Format (GTA V or RDR 2)
*/
LIBRAGEPHOTO_C_BINDING size_t ragephotodata_getsavesizef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, uint32_t photoFormat);
/** Saves a Photo to a char*. /** Saves a Photo to a char*.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data Photo data * \param data Photo data
@ -162,11 +188,21 @@ LIBRAGEPHOTO_C_BINDING ragephoto_bool_t ragephoto_savefilef(ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_BINDING void ragephoto_setbufferdefault(ragephoto_t instance); LIBRAGEPHOTO_C_BINDING void ragephoto_setbufferdefault(ragephoto_t instance);
/** Sets all cross-format Buffer to default size.
* \param rp_data RagePhotoData object
*/
LIBRAGEPHOTO_C_BINDING void ragephotodata_setbufferdefault(RagePhotoData *rp_data);
/** Moves all Buffer offsets to correct position. /** Moves all Buffer offsets to correct position.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_BINDING void ragephoto_setbufferoffsets(ragephoto_t instance); LIBRAGEPHOTO_C_BINDING void ragephoto_setbufferoffsets(ragephoto_t instance);
/** Moves all Buffer offsets to correct position.
* \param rp_data RagePhotoData object
*/
LIBRAGEPHOTO_C_BINDING void ragephotodata_setbufferoffsets(RagePhotoData *rp_data);
/** Sets the internal RagePhotoData object. /** Sets the internal RagePhotoData object.
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param rp_data RagePhotoData object being set * \param rp_data RagePhotoData object being set