Skip to content

Commit

Permalink
build: fix #926, speedrun to #1000 (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishura4 authored Oct 6, 2023
1 parent f768e93 commit 91906ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/dpp/discordevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <dpp/export.h>
#include <dpp/json_fwd.h>
#include <dpp/json_interface.h>
#include <string_view>
#include <functional>

namespace dpp {

Expand Down Expand Up @@ -53,7 +55,7 @@ void DPP_EXPORT set_snowflake_array_not_null(const nlohmann::json* j, const char
* @param key key name to check for the values
* @param fn function to apply to each element
*/
void DPP_EXPORT for_each_json(nlohmann::json* parent, std::string_view key, std::function<void(const nlohmann::json*)> fn);
void DPP_EXPORT for_each_json(nlohmann::json* parent, std::string_view key, const std::function<void(nlohmann::json*)> &fn);

/** @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
Expand Down
4 changes: 2 additions & 2 deletions src/dpp/discordevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ void set_snowflake_array_not_null(const json* j, const char *keyname, std::vecto
}
}

void for_each_json(const nlohmann::json* parent, const char* key, std::function<void(const nlohmann::json*)> fn) {
void for_each_json(nlohmann::json* parent, std::string_view key, const std::function<void(nlohmann::json*)> &fn) {
auto it = parent->find(key);
if (it == parent->end() || it->is_null()) {
return;
}
for (const nlohmann::json &elem : *parent) {
for (nlohmann::json &elem : *parent) {
fn(&elem);
}
}
Expand Down

0 comments on commit 91906ac

Please sign in to comment.