Skip to content

Commit

Permalink
D++ == CHAD++ // true (#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Aug 9, 2023
2 parents e41f304 + b4a1cc0 commit cdaaded
Show file tree
Hide file tree
Showing 120 changed files with 172 additions and 186 deletions.
4 changes: 2 additions & 2 deletions include/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
/**
* @brief Destroy the slashcommand object
*/
virtual ~slashcommand();
virtual ~slashcommand() = default;

/**
* @brief Add a localisation for this slash command
Expand Down Expand Up @@ -1222,4 +1222,4 @@ typedef std::unordered_map<snowflake, slashcommand> slashcommand_map;
*/
typedef std::unordered_map<snowflake, guild_command_permissions> guild_command_permissions_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ class DPP_EXPORT application : public managed, public json_interface<application
*/
typedef std::unordered_map<snowflake, application> application_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/auditlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ class DPP_EXPORT auditlog : public json_interface<auditlog> {
auditlog& fill_from_json(nlohmann::json* j);
};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/automod.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,4 @@ class DPP_EXPORT automod_rule : public managed, public json_interface<automod_ru
*/
typedef std::unordered_map<snowflake, automod_rule> automod_rule_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/ban.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ class DPP_EXPORT ban : public json_interface<ban> {
*/
typedef std::unordered_map<snowflake, ban> ban_map;

};
} // namespace dpp
6 changes: 3 additions & 3 deletions include/dpp/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ template<class T> class cache {
} else if (object != existing->second) {
/* Flag old pointer for deletion and replace */
std::lock_guard<std::mutex> delete_lock(deletion_mutex);
deletion_queue[existing->second] = time(NULL);
deletion_queue[existing->second] = time(nullptr);
(*cache_map)[object->id] = object;
}
}
Expand All @@ -133,7 +133,7 @@ template<class T> class cache {
auto existing = cache_map->find(object->id);
if (existing != cache_map->end()) {
cache_map->erase(existing);
deletion_queue[object] = time(NULL);
deletion_queue[object] = time(nullptr);
}
}

Expand Down Expand Up @@ -268,5 +268,5 @@ cache_decl(role, find_role, get_role_cache, get_role_count);
cache_decl(channel, find_channel, get_channel_cache, get_channel_count);
cache_decl(emoji, find_emoji, get_emoji_cache, get_emoji_count);

};
} // namespace dpp

6 changes: 3 additions & 3 deletions include/dpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ struct DPP_EXPORT forum_tag : public managed, public json_interface<forum_tag> {
forum_tag(const std::string& name);

/** Destructor */
virtual ~forum_tag();
virtual ~forum_tag() = default;

/**
* @brief Read struct values from a json object
Expand Down Expand Up @@ -803,7 +803,7 @@ class DPP_EXPORT thread : public channel {
/**
* @brief Destroy the thread object
*/
virtual ~thread();
virtual ~thread() = default;

/**
* @brief Build json for this thread object
Expand Down Expand Up @@ -862,5 +862,5 @@ struct active_thread_info {
*/
using active_threads = std::map<snowflake, active_thread_info>;

};
} // namespace dpp

12 changes: 11 additions & 1 deletion include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ class DPP_EXPORT cluster {
*/
cluster(const cluster&&) = delete;

/**
* @brief dpp::cluster is non-copyable
*/
cluster& operator=(const cluster&) = delete;

/**
* @brief dpp::cluster is non-moveable
*/
cluster& operator=(const cluster&&) = delete;

/**
* @brief Destroy the cluster object
*/
Expand Down Expand Up @@ -3523,4 +3533,4 @@ class DPP_EXPORT cluster {

};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,4 @@ class scheduled_event_collector : public scheduled_event_collector_t {
virtual ~scheduled_event_collector() = default;
};

};
} // namespace dpp
4 changes: 2 additions & 2 deletions include/dpp/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,10 @@ namespace dpp {
snow = 0xFFFAFA,
milk_white = 0xFEFCFF,
half_white = 0xFFFEFA;
};
} // namespace colors

/**
* @brief predefined color constants, same as colors
*/
namespace colours = colors;
};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/commandhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,4 @@ class DPP_EXPORT commandhandler {

};

};
} // namespace dpp
6 changes: 3 additions & 3 deletions include/dpp/coro.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace dpp {
*/
template <typename ReturnType>
using task_handle = detail::std_coroutine::coroutine_handle<detail::task_promise<ReturnType>>;
}
} // namespace detail

/**
* @brief A coroutine task. It can be co_awaited to make nested coroutines.
Expand Down Expand Up @@ -404,7 +404,7 @@ namespace dpp {
if (parent)
parent.resume();
}
}
} // namespace detail

template <typename ReturnType>
#ifndef _DOXYGEN_
Expand Down Expand Up @@ -695,7 +695,7 @@ namespace dpp {
return std::move(*api_callback.get_result());
}
};
};
} // namespace dpp

/**
* @brief Specialization of std::coroutine_traits, helps the standard library figure out a promise type from a coroutine function.
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/discordclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,4 @@ class DPP_EXPORT discord_client : public websocket_client
voiceconn* get_voice(snowflake guild_id);
};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/discordevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ std::string DPP_EXPORT base64_encode(unsigned char const* buf, unsigned int buff
*/
std::string DPP_EXPORT ts_to_string(time_t ts);

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/discordvoiceclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,5 +910,5 @@ class DPP_EXPORT discord_voice_client : public websocket_client
std::string discover_ip();
};

};
} // namespace dpp

4 changes: 2 additions & 2 deletions include/dpp/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace utility {
* @return A lambda for attaching to an API callback
*/
std::function<void(const dpp::confirmation_callback_t& detail)> DPP_EXPORT log_error();
};
} // namespace utility

/** @brief Add user to scheduled event */
struct DPP_EXPORT guild_scheduled_event_user_add_t : public event_dispatch_t {
Expand Down Expand Up @@ -1905,5 +1905,5 @@ struct DPP_EXPORT voice_client_disconnect_t : public event_dispatch_t {
snowflake user_id;
};

};
} // namespace dpp

2 changes: 1 addition & 1 deletion include/dpp/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ namespace dpp {
* @throw dpp::connection_exception On failure to resolve hostname
*/
const dns_cache_entry* resolve_hostname(const std::string& hostname, const std::string& port);
};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/dtemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ class DPP_EXPORT dtemplate : public json_interface<dtemplate> {
typedef std::unordered_map<snowflake, dtemplate> dtemplate_map;


};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/emoji.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ class DPP_EXPORT emoji : public managed, public json_interface<emoji> {
*/
typedef std::unordered_map<snowflake, emoji> emoji_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/etf.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,4 @@ class DPP_EXPORT etf_parser {
std::string build(const nlohmann::json& j);
};

};
} // namespace dpp
3 changes: 2 additions & 1 deletion include/dpp/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,5 @@ event_decl(automod_rule_execute, AUTO_MODERATION_ACTION_EXECUTION);
/* Audit log */
event_decl(guild_audit_log_entry_create, GUILD_AUDIT_LOG_ENTRY_CREATE);

}};
} // namespace events
} // namespace dpp
14 changes: 7 additions & 7 deletions include/dpp/event_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ template<class T> class event_router_t {
warning(event);
}
std::shared_lock l(lock);
std::for_each(dispatch_container.begin(), dispatch_container.end(), [&](auto &ev) {
for (const auto& [_, listener] : dispatch_container) {
if (!event.is_cancelled()) {
ev.second(event);
listener(event);
}
});
};
#ifdef DPP_CORO
auto coro_exception_handler = [from = event.from](std::exception_ptr ptr) {
try {
Expand All @@ -173,13 +173,13 @@ template<class T> class event_router_t {
from->creator->log(dpp::loglevel::ll_error, std::string{"Uncaught exception in event coroutine: "} + exception.what());
}
};
std::for_each(coroutine_container.begin(), coroutine_container.end(), [&](auto &ev) {
for (const auto& [_, listener] : coroutine_container) {
if (!event.is_cancelled()) {
dpp::task<void> task = ev.second(event);
dpp::task<void> task = listener(event);

task.on_exception(coro_exception_handler);
}
});
};
#endif /* DPP_CORO */
};

Expand Down Expand Up @@ -276,4 +276,4 @@ template<class T> class event_router_t {
}
};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,5 @@ class exception : public std::exception
derived_exception(cache_exception, exception);
#endif

};
} // namespace dpp

2 changes: 1 addition & 1 deletion include/dpp/guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -1371,4 +1371,4 @@ typedef std::unordered_map<snowflake, guild_member> guild_member_map;
*/
guild_member DPP_EXPORT find_guild_member(const snowflake guild_id, const snowflake user_id);

};
} // namespace dpp
4 changes: 2 additions & 2 deletions include/dpp/httpsclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class DPP_EXPORT https_client : public ssl_client
/**
* @brief Destroy the https client object
*/
virtual ~https_client();
virtual ~https_client() = default;

/**
* @brief Build a multipart content from a set of files and some json
Expand Down Expand Up @@ -335,4 +335,4 @@ class DPP_EXPORT https_client : public ssl_client

};

};
} // namespace dpp
4 changes: 2 additions & 2 deletions include/dpp/integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class DPP_EXPORT integration : public managed, public json_interface<integration
integration();

/** Default destructor */
~integration();
~integration() = default;

/** Read class values from json object
* @param j A json object to read from
Expand Down Expand Up @@ -169,5 +169,5 @@ typedef std::unordered_map<snowflake, integration> integration_map;
/** A group of connections */
typedef std::unordered_map<snowflake, connection> connection_map;

};
} // namespace dpp

2 changes: 1 addition & 1 deletion include/dpp/intents.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ enum intents {
i_unverified_default_intents = dpp::i_default_intents | dpp::i_message_content
};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/invite.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ class DPP_EXPORT invite : public json_interface<invite> {
/** A container of invites */
typedef std::unordered_map<std::string, invite> invite_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/isa_detection.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,4 @@ class audio_mixer {

#endif

}
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/json_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ namespace dpp {
throw dpp::logic_exception("JSON interface doesn't implement build_json");
}
};
};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/managed.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ namespace dpp {
bool operator!=(const managed& other) const noexcept;
};

};
} // namespace dpp
4 changes: 2 additions & 2 deletions include/dpp/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ namespace embed_type {
* @brief Auto moderation filter
*/
const std::string emt_automod = "auto_moderation_message";
};
} // namespace embed_type

/**
* @brief Message types for dpp::message::type
Expand Down Expand Up @@ -1558,4 +1558,4 @@ typedef std::unordered_map<snowflake, sticker> sticker_map;
/** A group of sticker packs */
typedef std::unordered_map<snowflake, sticker_pack> sticker_pack_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/misc-enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ namespace dpp {
ll_critical
};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/once.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ namespace dpp {
return !std::exchange(called, true);
};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/permissions.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,4 @@ class DPP_EXPORT permission {
}
};

}
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/presence.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,4 @@ class DPP_EXPORT presence : public json_interface<presence> {
/** A container of presences */
typedef std::unordered_map<snowflake, presence> presence_map;

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/prune.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ struct DPP_EXPORT prune : public json_interface<prune> {

};

};
} // namespace dpp
2 changes: 1 addition & 1 deletion include/dpp/queues.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,4 @@ class DPP_EXPORT request_queue {
bool is_globally_ratelimited() const;
};

};
} // namespace dpp
Loading

0 comments on commit cdaaded

Please sign in to comment.