Skip to content

Commit

Permalink
docs: documented object array json parse helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Commandserver committed Jul 30, 2023
1 parent f9d4cdb commit 968fdc2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/dpp/discordevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,19 @@ uint64_t DPP_EXPORT snowflake_not_null(const nlohmann::json* j, const char *keyn
*/
void DPP_EXPORT set_snowflake_not_null(const nlohmann::json* j, const char *keyname, uint64_t &v);

/** @brief Sets an array of snowflakes from a json field value, if defined, else does nothing
* @param j nlohmann::json instance to retrieve value from
* @param keyname key name to check for the values
* @param v Value to change
*/
void DPP_EXPORT set_snowflake_array_not_null(const nlohmann::json* j, const char *keyname, std::vector<class snowflake> &v);

/** @brief Sets an array of objects from a json field value, if defined, else does nothing
* @tparam T The class of which the array consists of. Must be derived from dpp::json_interface
* @param j nlohmann::json instance to retrieve value from
* @param keyname key name to check for the values
* @param v Value to change
*/
template<class T> inline void DPP_EXPORT set_object_array_not_null(nlohmann::json* j, const char *keyname, std::vector<T> &v) {
v.clear();
auto k = j->find(keyname);
Expand Down

0 comments on commit 968fdc2

Please sign in to comment.