add version features

This commit is contained in:
Syping 2021-11-03 10:54:35 +01:00
parent 1be4ae5e4a
commit 2fcc5b0ba7
4 changed files with 48 additions and 6 deletions

View file

@ -457,6 +457,11 @@ const std::string& RagePhoto::title() const
return m_data.title;
}
const char* RagePhoto::version()
{
return RAGEPHOTO_VERSION;
}
bool RagePhoto::save(char *data, uint32_t photoFormat)
{
if (photoFormat == PhotoFormat::GTA5 || photoFormat == PhotoFormat::RDR2) {
@ -916,6 +921,12 @@ int ragephoto_load(ragephoto_t instance, const char *data, size_t size)
return ragePhoto->load(data, size);
}
int ragephoto_loadfile(ragephoto_t instance, const char *filename)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
return ragePhoto->loadFile(filename);
}
uint8_t ragephoto_error(ragephoto_t instance)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
@ -996,6 +1007,12 @@ int ragephoto_save(ragephoto_t instance, char *data)
return ragePhoto->save(data);
}
int ragephoto_savefile(ragephoto_t instance, const char *filename)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
return ragePhoto->saveFile(filename);
}
void ragephoto_setbufferdefault(ragephoto_t instance)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
@ -1049,4 +1066,9 @@ void ragephoto_close(ragephoto_t instance)
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
delete ragePhoto;
}
const char* ragephoto_version()
{
return RAGEPHOTO_VERSION;
}
#endif

View file

@ -116,6 +116,7 @@ public:
const std::string& json() const; /**< Returns the Photo JSON data. */
const std::string& header() const; /**< Returns the Photo header. */
const std::string& title() const; /**< Returns the Photo title. */
static const char* version(); /**< Returns the library version. */
/** Saves a Photo to a char*.
* \param data Photo data
* \param photoFormat Photo Format (GTA V or RDR 2)
@ -196,6 +197,12 @@ LIBRAGEPHOTO_EXPORT ragephoto_t ragephoto_open();
*/
LIBRAGEPHOTO_EXPORT int ragephoto_load(ragephoto_t instance, const char *data, size_t size);
/** Loads a Photo from a file.
* \param instance \p ragephoto_t instance
* \param filename File to load
*/
LIBRAGEPHOTO_EXPORT int ragephoto_loadfile(ragephoto_t instance, const char *filename);
/** Returns the last error occurred.
* \param instance \p ragephoto_t instance
*/
@ -259,6 +266,12 @@ LIBRAGEPHOTO_EXPORT size_t ragephoto_getsavesize(ragephoto_t instance);
*/
LIBRAGEPHOTO_EXPORT int ragephoto_save(ragephoto_t instance, char *data);
/** Saves a Photo to a file.
* \param instance \p ragephoto_t instance
* \param filename File to save
*/
LIBRAGEPHOTO_EXPORT int ragephoto_savefile(ragephoto_t instance, const char *filename);
/** Sets all cross-format Buffer to default size.
* \param instance \p ragephoto_t instance
*/
@ -312,6 +325,9 @@ LIBRAGEPHOTO_EXPORT void ragephoto_setphototitle(ragephoto_t instance, const cha
*/
LIBRAGEPHOTO_EXPORT void ragephoto_close(ragephoto_t instance);
/** Returns the library version. */
LIBRAGEPHOTO_EXPORT const char* ragephoto_version();
#ifdef __cplusplus
}
#endif

View file

@ -22,6 +22,10 @@
/* CMAKE CONFIG BEGIN */
#define @LIBRAGEPHOTO_API@
#define @LIBRAGEPHOTO_LIBTYPE@
#define RAGEPHOTO_VERSION "@PROJECT_VERSION@"
#define RAGEPHOTO_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define RAGEPHOTO_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define RAGEPHOTO_VERSION_PATCH @PROJECT_VERSION_PATCH@
/* CMAKE CONFIG END */
/* RAGEPHOTO LIBRARY EXPORT BEGIN */