Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,14 @@ std::string Utils::stringFromGVariantByteArray(const GVariant *pVariant)
return array.data();
}

// Extracts a VECTOR from an array of bytes ("ay")
std::vector<guint8> Utils::vectorFromGVariantByteArray(const GVariant *pVariant)
{
gsize size;
gconstpointer pPtr = g_variant_get_fixed_array(const_cast<GVariant *>(pVariant), &size, 1);
std::vector<guint8> array(size + 1, 0);
memcpy(array.data(), pPtr, size);
return array;
}

}; // namespace ggk
3 changes: 3 additions & 0 deletions src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ struct Utils
// Extracts a string from an array of bytes ("ay")
static std::string stringFromGVariantByteArray(const GVariant *pVariant);

// Extracts a VECTOR from an array of bytes ("ay")
static std::vector<guint8> vectorFromGVariantByteArray(const GVariant *pVariant);

// -----------------------------------------------------------------------------------------------------------------------------
// Endian conversion
//
Expand Down