bugfix: An exception was thrown when converting empty strings to uint64

This commit is contained in:
tastytea 2018-05-11 06:12:09 +02:00
parent 897e36dc44
commit 87a432f326
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
10 changed files with 24 additions and 10 deletions

View File

@ -335,6 +335,8 @@ public:
*/
const std::vector<string> get_vector(const string &key) const;
const std::uint_fast64_t stouint64(const string &str) const;
private:
Json::Value _tree;
bool _valid;

View File

@ -75,7 +75,7 @@ const string Account::header_static() const
const std::uint_fast64_t Account::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const bool Account::locked() const

View File

@ -103,7 +103,7 @@ const uint_fast64_t Attachment::height_small() const
const std::uint_fast64_t Attachment::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const string Attachment::preview_url() const

View File

@ -31,7 +31,7 @@ List::List()
const uint_fast64_t List::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const string List::title() const

View File

@ -34,7 +34,7 @@ const string Mention::acct() const
const uint_fast64_t Mention::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const string Mention::url() const

View File

@ -47,7 +47,7 @@ const system_clock::time_point Notification::created_at() const
const uint_fast64_t Notification::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const Easy::Status Notification::status() const

View File

@ -49,7 +49,7 @@ const bool Relationship::following() const
const uint_fast64_t Relationship::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const bool Relationship::muting() const

View File

@ -34,6 +34,6 @@ const bool Report::action_taken() const
const uint_fast64_t Report::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}

View File

@ -92,17 +92,17 @@ const uint_fast64_t Status::favourites_count() const
const uint_fast64_t Status::id() const
{
return std::stoull(get_string("id"));
return stouint64(get_string("id"));
}
const uint_fast64_t Status::in_reply_to_id() const
{
return std::stoull(get_string("in_reply_to_id"));
return stouint64(get_string("in_reply_to_id"));
}
const uint_fast64_t Status::in_reply_to_account_id() const
{
return std::stoull(get_string("in_reply_to_account_id"));
return stouint64(get_string("in_reply_to_account_id"));
}
const string Status::language() const

View File

@ -221,3 +221,15 @@ const std::vector<string> Easy::Entity::get_vector(const string &key) const
_was_set = false;
return {};
}
const std::uint_fast64_t Easy::Entity::stouint64(const string &str) const
{
if (str == "")
{
return 0;
}
else
{
return stoull(str);
}
}