forked from OpenGamers/abaddon
add Snowflake ctor for Glib::ustring
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
Snowflake::Snowflake()
|
Snowflake::Snowflake()
|
||||||
: m_num(Invalid) {}
|
: m_num(Invalid) {}
|
||||||
|
|
||||||
|
|
||||||
Snowflake::Snowflake(uint64_t n)
|
Snowflake::Snowflake(uint64_t n)
|
||||||
: m_num(n) {}
|
: m_num(n) {}
|
||||||
|
|
||||||
@@ -12,6 +11,12 @@ Snowflake::Snowflake(const std::string &str) {
|
|||||||
m_num = std::stoull(str);
|
m_num = std::stoull(str);
|
||||||
else
|
else
|
||||||
m_num = Invalid;
|
m_num = Invalid;
|
||||||
|
}
|
||||||
|
Snowflake::Snowflake(const Glib::ustring &str) {
|
||||||
|
if (str.size())
|
||||||
|
m_num = std::strtoull(str.c_str(), nullptr, 10);
|
||||||
|
else
|
||||||
|
m_num = Invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Snowflake::IsValid() const {
|
bool Snowflake::IsValid() const {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
struct Snowflake {
|
struct Snowflake {
|
||||||
Snowflake();
|
Snowflake();
|
||||||
Snowflake(uint64_t n);
|
Snowflake(uint64_t n);
|
||||||
Snowflake(const std::string &str);
|
Snowflake(const std::string &str);
|
||||||
|
Snowflake(const Glib::ustring &str);
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user