diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-11-28 22:48:30 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-11-28 22:48:30 -0500 |
commit | e1703aea3fd597b23bde90e6c505278c517be611 (patch) | |
tree | 37d98fc90c9cd0844388bfb79beda2204f44af92 /discord/snowflake.hpp | |
parent | fd53a76bf6f53a095a639765923a30f2206b2cd6 (diff) | |
parent | e02107feea8214a045e6faa969f00dcbc0d2b072 (diff) | |
download | abaddon-portaudio-e1703aea3fd597b23bde90e6c505278c517be611.tar.gz abaddon-portaudio-e1703aea3fd597b23bde90e6c505278c517be611.zip |
merge master
Diffstat (limited to 'discord/snowflake.hpp')
-rw-r--r-- | discord/snowflake.hpp | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/discord/snowflake.hpp b/discord/snowflake.hpp deleted file mode 100644 index 1cabf3d..0000000 --- a/discord/snowflake.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include <cstdint> -#include <nlohmann/json.hpp> -#include <glibmm/ustring.h> - -struct Snowflake { - Snowflake(); - Snowflake(uint64_t n); - Snowflake(const std::string &str); - Snowflake(const Glib::ustring &str); - - static Snowflake FromNow(); // not thread safe - - bool IsValid() const; - Glib::ustring GetLocalTimestamp() const; - - bool operator==(const Snowflake &s) const noexcept { - return m_num == s.m_num; - } - - bool operator<(const Snowflake &s) const noexcept { - return m_num < s.m_num; - } - - operator uint64_t() const noexcept { - return m_num; - } - - const static Snowflake Invalid; // makes sense to me - const static uint64_t SecondsInterval = 4194304000ULL; // the "difference" between two snowflakes one second apart - - friend void from_json(const nlohmann::json &j, Snowflake &s); - friend void to_json(nlohmann::json &j, const Snowflake &s); - -private: - friend struct std::hash<Snowflake>; - friend struct std::less<Snowflake>; - unsigned long long m_num; -}; - -namespace std { -template<> -struct hash<Snowflake> { - std::size_t operator()(const Snowflake &k) const { - return k.m_num; - } -}; - -template<> -struct less<Snowflake> { - bool operator()(const Snowflake &l, const Snowflake &r) const { - return l.m_num < r.m_num; - } -}; -} // namespace std |