[util] Add accessors for binary plist objects

This commit is contained in:
Bill Currie 2020-12-23 14:07:30 +09:00
parent 91c5baa708
commit 5864b553ef
2 changed files with 37 additions and 0 deletions

View file

@ -141,6 +141,23 @@ pltype_t PL_Type (const plitem_t *item) __attribute__((pure));
*/
int PL_Line (const plitem_t *item) __attribute__((pure));
/** Retrieve the data size from a binary object.
\param binary The binary object
\return the size in bytes of the binary object 0 if binary isn't a binary
object.
*/
size_t PL_BinarySize (const plitem_t *item) __attribute__((pure));
/** Retrieve the data from a binary object.
\param binary The binary object
\return pointer to the actual data or NULL if binary isn't a binary object.
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
const void *PL_BinaryData (const plitem_t *binary) __attribute__((pure));
/** Retrieve a string from a string object.
\param string The string object

View file

@ -231,6 +231,26 @@ PL_Free (plitem_t *item)
free (item);
}
VISIBLE size_t
PL_BinarySize (const plitem_t *binary)
{
plbinary_t *bin = (plbinary_t *) binary->data;
if (binary->type != QFBinary)
return 0;
return bin->size;
}
VISIBLE const void *
PL_BinaryData (const plitem_t *binary)
{
plbinary_t *bin = (plbinary_t *) binary->data;
if (binary->type != QFBinary)
return 0;
return bin->data;
}
VISIBLE const char *
PL_String (const plitem_t *string)
{