diff --git a/include/dpp/cluster.h b/include/dpp/cluster.h index 55d8bc6b8f..e59331ad76 100644 --- a/include/dpp/cluster.h +++ b/include/dpp/cluster.h @@ -51,8 +51,6 @@ namespace dpp { -using json = nlohmann::json; - /** * @brief Types of startup for cluster::start() */ diff --git a/include/dpp/discordclient.h b/include/dpp/discordclient.h index 08f6ed0d57..ff2f7736f7 100644 --- a/include/dpp/discordclient.h +++ b/include/dpp/discordclient.h @@ -41,8 +41,6 @@ #define API_PATH "/api/v" DISCORD_API_VERSION namespace dpp { -using json = nlohmann::json; - // Forward declarations class cluster; diff --git a/include/dpp/discordvoiceclient.h b/include/dpp/discordvoiceclient.h index af0e2c5f2f..cc88ec04b8 100644 --- a/include/dpp/discordvoiceclient.h +++ b/include/dpp/discordvoiceclient.h @@ -64,8 +64,6 @@ class audio_mixer; inline constexpr size_t send_audio_raw_max_length = 11520; -using json = nlohmann::json; - /* * @brief For holding a moving average of the number of current voice users, for applying a smooth gain ramp. */ diff --git a/include/dpp/event_router.h b/include/dpp/event_router.h index f6dd3b4664..f759570465 100644 --- a/include/dpp/event_router.h +++ b/include/dpp/event_router.h @@ -36,8 +36,6 @@ #include #include -using json = nlohmann::json; - namespace dpp { #ifdef DPP_CORO diff --git a/include/dpp/json.h b/include/dpp/json.h index fc47bb45f8..bfbf3bebf9 100644 --- a/include/dpp/json.h +++ b/include/dpp/json.h @@ -23,4 +23,8 @@ #include #else #include -#endif \ No newline at end of file +#endif + +namespace dpp { + using json = nlohmann::json; +} diff --git a/include/dpp/json_fwd.h b/include/dpp/json_fwd.h index 75326193ef..e5d8870ea8 100644 --- a/include/dpp/json_fwd.h +++ b/include/dpp/json_fwd.h @@ -23,4 +23,8 @@ #include #else #include -#endif \ No newline at end of file +#endif + +namespace dpp { + using json = nlohmann::json; +} diff --git a/include/dpp/restresults.h b/include/dpp/restresults.h index 0691b41869..5661a596d5 100644 --- a/include/dpp/restresults.h +++ b/include/dpp/restresults.h @@ -44,8 +44,6 @@ #include #include -using json = nlohmann::json; - namespace dpp { #ifdef _WIN32 diff --git a/include/dpp/snowflake.h b/include/dpp/snowflake.h index 727728440f..226a8d88a9 100644 --- a/include/dpp/snowflake.h +++ b/include/dpp/snowflake.h @@ -25,6 +25,7 @@ #include #include #include +#include /** * @brief The main namespace for D++ functions. classes and types @@ -33,17 +34,17 @@ namespace dpp { /** @brief A container for a 64 bit unsigned value representing many things on discord. * This value is known in distributed computing as a snowflake value. - * + * * Snowflakes are: - * + * * - Performant (very fast to generate at source and to compare in code) * - Uncoordinated (allowing high availability across clusters, data centres etc) * - Time ordered (newer snowflakes have higher IDs) * - Directly Sortable (due to time ordering) * - Compact (64 bit numbers, not 128 bit, or string) - * + * * An identical format of snowflake is used by Twitter, Instagram and several other platforms. - * + * * @see https://en.wikipedia.org/wiki/Snowflake_ID * @see https://github.com/twitter-archive/snowflake/tree/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231 */ @@ -81,7 +82,7 @@ class DPP_EXPORT snowflake final { constexpr snowflake(T snowflake_val) noexcept(std::is_unsigned_v) : value(static_cast>(snowflake_val)) { /** * we cast to the unsigned version of the type given - this maintains "possible loss of data" warnings for sizeof(T) > sizeof(value) - * while suppressing them for signed to unsigned conversion + * while suppressing them for signed to unsigned conversion (for example snowflake(42) will call snowflake(int) which is a signed type) */ if constexpr (!std::is_unsigned_v) { /* if the type is signed, at compile-time, add a check at runtime that the value is unsigned */ @@ -204,7 +205,7 @@ class DPP_EXPORT snowflake final { * @brief For building json * @return The snowflake value as a string */ - operator nlohmann::json() const; + operator json() const; /** * @brief Get the creation time of this snowflake according to Discord. diff --git a/src/dpp/snowflake.cpp b/src/dpp/snowflake.cpp index 46df8583b4..5f7ad6e844 100644 --- a/src/dpp/snowflake.cpp +++ b/src/dpp/snowflake.cpp @@ -19,6 +19,7 @@ * ************************************************************************************/ #include +#include #include #include @@ -37,7 +38,7 @@ snowflake& snowflake::operator=(std::string_view string_value) noexcept { return *this; } -snowflake::operator nlohmann::json() const { +snowflake::operator json() const { /* Discord transfers snowflakes as strings for compatibility with javascript */ return std::to_string(value); }