improve docs, add setFormat and setBufferDefault
This commit is contained in:
parent
af5c571b16
commit
87d61c1c69
5 changed files with 54 additions and 12 deletions
|
@ -36,6 +36,7 @@ RagePhoto::RagePhoto()
|
|||
{
|
||||
p_photoLoaded = false;
|
||||
p_photoData = nullptr;
|
||||
setBufferDefault();
|
||||
}
|
||||
|
||||
RagePhoto::~RagePhoto()
|
||||
|
@ -56,6 +57,7 @@ void RagePhoto::clear()
|
|||
p_titleString.clear();
|
||||
p_error = Error::Uninitialised;
|
||||
p_photoFormat = PhotoFormat::Undefined;
|
||||
setBufferDefault();
|
||||
}
|
||||
|
||||
bool RagePhoto::load(const char *data, size_t length)
|
||||
|
@ -344,6 +346,25 @@ bool RagePhoto::load(const char *data, size_t length)
|
|||
std::cout << "Benchmark: " << benchmark_ns.count() << "ns" << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef RAGEPHOTO_DEBUG
|
||||
std::cout << "header: " << p_photoString << std::endl;
|
||||
std::cout << "headerSum: " << p_headerSum << std::endl;
|
||||
std::cout << "photoBuffer: " << p_photoBuffer << std::endl;
|
||||
std::cout << "descBuffer: " << p_descBuffer << std::endl;
|
||||
std::cout << "descOffset: " << p_descOffset << std::endl;
|
||||
std::cout << "jsonBuffer: " << p_jsonBuffer << std::endl;
|
||||
std::cout << "jsonOffset: " << p_jsonOffset << std::endl;
|
||||
std::cout << "titlBuffer: " << p_titlBuffer << std::endl;
|
||||
std::cout << "titlOffset: " << p_titlOffset << std::endl;
|
||||
std::cout << "eofOffset: " << p_endOfFile << std::endl;
|
||||
std::cout << "moveOffsets()" << std::endl;
|
||||
moveOffsets();
|
||||
std::cout << "descOffset: " << p_descOffset << std::endl;
|
||||
std::cout << "jsonOffset: " << p_jsonOffset << std::endl;
|
||||
std::cout << "titlOffset: " << p_titlOffset << std::endl;
|
||||
std::cout << "eofOffset: " << p_endOfFile << std::endl;
|
||||
#endif
|
||||
|
||||
p_error = Error::NoError; // 255
|
||||
return true;
|
||||
}
|
||||
|
@ -374,7 +395,7 @@ const char* RagePhoto::photoData()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const uint32_t RagePhoto::photoSize()
|
||||
uint32_t RagePhoto::photoSize()
|
||||
{
|
||||
if (p_photoLoaded)
|
||||
return p_photoSize;
|
||||
|
@ -402,6 +423,14 @@ const std::string RagePhoto::title()
|
|||
return p_titleString;
|
||||
}
|
||||
|
||||
void RagePhoto::setBufferDefault()
|
||||
{
|
||||
p_descBuffer = DEFAULT_DESCBUFFER;
|
||||
p_jsonBuffer = DEFAULT_JSONBUFFER;
|
||||
p_titlBuffer = DEFAULT_TITLBUFFER;
|
||||
moveOffsets();
|
||||
}
|
||||
|
||||
void RagePhoto::setDescription(const std::string &description, uint32_t bufferSize)
|
||||
{
|
||||
p_descriptionString = description;
|
||||
|
@ -411,6 +440,11 @@ void RagePhoto::setDescription(const std::string &description, uint32_t bufferSi
|
|||
}
|
||||
}
|
||||
|
||||
void RagePhoto::setFormat(PhotoFormat photoFormat)
|
||||
{
|
||||
p_photoFormat = photoFormat;
|
||||
}
|
||||
|
||||
void RagePhoto::setJson(const std::string &json, uint32_t bufferSize)
|
||||
{
|
||||
p_jsonString = json;
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
#define DEFAULT_GTAV_PHOTOBUFFER 524288UL /**< GTA V default Photo Buffer Size */
|
||||
#define DEFAULT_RDR2_PHOTOBUFFER 1048576UL /**< RDR 2 default Photo Buffer Size */
|
||||
#define DEFAULT_DESCBUFFER 256UL /**< Default Description Buffer Size */
|
||||
#define DEFAULT_JSONBUFFER 3072UL /**< Default JSON Buffer Size */
|
||||
#define DEFAULT_TITLBUFFER 256UL /**< Default Title Buffer Size */
|
||||
|
||||
class LIBRAGEPHOTO_EXPORT RagePhoto
|
||||
{
|
||||
public:
|
||||
|
@ -79,21 +85,25 @@ public:
|
|||
Error error(); /**< Returns the last error occurred. */
|
||||
PhotoFormat format(); /**< Returns the Photo Format (GTA V or RDR 2). */
|
||||
const char *photoData(); /**< Returns the Photo JPEG data. */
|
||||
const uint32_t photoSize(); /**< Returns the Photo JPEG data size. */
|
||||
uint32_t photoSize(); /**< Returns the Photo JPEG data size. */
|
||||
const std::string description(); /**< Returns the Photo description. */
|
||||
const std::string json(); /**< Returns the Photo JSON data. */
|
||||
const std::string header(); /**< Returns the Photo header. */
|
||||
const std::string title(); /**< Returns the Photo title. */
|
||||
void setBufferDefault(); /**< Sets all cross-format Buffer to default size. */
|
||||
void setDescription(const std::string &description, uint32_t bufferSize = 0); /**< Sets the Photo description. */
|
||||
void setFormat(PhotoFormat photoFormat); /**< Sets the Photo Format (GTA V or RDR 2). */
|
||||
void setJson(const std::string &json, uint32_t bufferSize = 0); /**< Sets the Photo JSON data. */
|
||||
void setHeader(const std::string &header, uint32_t headerSum); /**< Sets the Photo header. (expert only) */
|
||||
/** Sets the Photo JPEG data.
|
||||
* @param data JPEG data
|
||||
* @param size JPEG data size
|
||||
* \param data JPEG data
|
||||
* \param size JPEG data size
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setPhotoData(const char *data, uint32_t size, uint32_t bufferSize = 0);
|
||||
/** Sets the Photo JPEG data.
|
||||
* @param data JPEG data
|
||||
* \param data JPEG data
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setPhotoData(const std::string &data, uint32_t bufferSize = 0);
|
||||
void setTitle(const std::string &title, uint32_t bufferSize = 0); /**< Sets the Photo title. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue