libragephoto: use ternary operator for flags

index.dox: remove unnecessary whitespaces
This commit is contained in:
Syping 2024-04-16 09:30:41 +02:00
parent 2d59f2acf9
commit bb2b98e5d8
3 changed files with 13 additions and 39 deletions

View file

@ -9,7 +9,7 @@
<b>Getting started</b>
\subpage Build "Build libragephoto"
\subpage Usage "Using libragephoto"
\subpage Usage "Using libragephoto"
<b>Reference</b>
\ref RagePhotoInstance "RagePhoto C API"

View file

@ -681,9 +681,7 @@ const char* ragephoto_getphotojpeg(ragephoto_t instance_t)
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
if (instance->data->jpeg)
return instance->data->jpeg;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return NULL;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? NULL : nullchar;
}
uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoFormat)
@ -737,9 +735,7 @@ const char* ragephoto_getphotodesc(ragephoto_t instance_t)
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
if (instance->data->description)
return instance->data->description;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return NULL;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? NULL : nullchar;
}
const char* ragephoto_getphotojson(ragephoto_t instance_t)
@ -747,9 +743,7 @@ const char* ragephoto_getphotojson(ragephoto_t instance_t)
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
if (instance->data->json)
return instance->data->json;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return NULL;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? NULL : nullchar;
}
const char* ragephoto_getphotoheader(ragephoto_t instance_t)
@ -757,9 +751,7 @@ const char* ragephoto_getphotoheader(ragephoto_t instance_t)
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
if (instance->data->header)
return instance->data->header;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return NULL;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? NULL : nullchar;
}
const char* ragephoto_getphototitle(ragephoto_t instance_t)
@ -767,9 +759,7 @@ const char* ragephoto_getphototitle(ragephoto_t instance_t)
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
if (instance->data->title)
return instance->data->title;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return NULL;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? NULL : nullchar;
}
const char* ragephoto_version()
@ -1113,10 +1103,7 @@ void ragephoto_setbufferoffsets(ragephoto_t instance_t)
void ragephoto_setlibraryflag(RagePhotoLibraryFlag flag, bool state)
{
if (state)
libraryflags |= flag;
else
libraryflags &= ~flag;
state ? (libraryflags |= flag) : (libraryflags &= ~flag);
}
bool ragephoto_setphotodata(ragephoto_t instance_t, RagePhotoData *rp_data)

View file

@ -643,9 +643,7 @@ const char* RagePhoto::jpegData() const
{
if (m_data->jpeg)
return m_data->jpeg;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return nullptr;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? nullptr : nullchar;
}
uint64_t RagePhoto::jpegSign(uint32_t photoFormat, RagePhotoData *rp_data)
@ -685,36 +683,28 @@ const char* RagePhoto::description() const
{
if (m_data->description)
return m_data->description;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return nullptr;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? nullptr : nullchar;
}
const char* RagePhoto::header() const
{
if (m_data->header)
return m_data->header;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return nullptr;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? nullptr : nullchar;
}
const char* RagePhoto::json() const
{
if (m_data->json)
return m_data->json;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return nullptr;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? nullptr : nullchar;
}
const char* RagePhoto::title() const
{
if (m_data->title)
return m_data->title;
if (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN)
return nullptr;
return nullchar;
return (libraryflags & RAGEPHOTO_FLAG_LEGACY_NULL_RETURN) ? nullptr : nullchar;
}
const char* RagePhoto::version()
@ -1242,10 +1232,7 @@ void RagePhoto::setJson(const char *json, uint32_t bufferSize)
void RagePhoto::setLibraryFlag(RagePhotoLibraryFlag flag, bool state)
{
if (state)
libraryflags |= flag;
else
libraryflags &= ~flag;
state ? (libraryflags |= flag) : (libraryflags &= ~flag);
}
void RagePhoto::setTitle(const char *title, uint32_t bufferSize)