From 8584857578c3a2946a03de98ff3803431143297a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 30 Aug 2018 20:43:23 -0400 Subject: Refactored tweet and user classes The only API-visible change is that these classes are no longer default constructible. Other than that, tweet now uses hatkirby::recptr to wrap its retweeted_status (tweet) and author (user) member objects, removing the need to implement the Rule of Five. --- src/user.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/user.cpp') diff --git a/src/user.cpp b/src/user.cpp index d2fa592..8109123 100644 --- a/src/user.cpp +++ b/src/user.cpp @@ -1,24 +1,25 @@ #include "user.h" #include #include "codes.h" -#include "client.h" namespace twitter { - user::user(std::string data) try - : _valid(true) + user::user(std::string data) { - auto json = nlohmann::json::parse(data); - _id = json["id"].get(); - _screen_name = json["screen_name"].get(); - _name = json["name"].get(); - _protected = json["protected"].get(); - } catch (const std::invalid_argument& error) - { - std::throw_with_nested(malformed_object("user", data)); - } catch (const std::domain_error& error) - { - std::throw_with_nested(malformed_object("user", data)); + try + { + auto json = nlohmann::json::parse(data); + _id = json["id"].get(); + _screen_name = json["screen_name"].get(); + _name = json["name"].get(); + _protected = json["protected"].get(); + } catch (const std::invalid_argument& error) + { + std::throw_with_nested(malformed_object("user", data)); + } catch (const std::domain_error& error) + { + std::throw_with_nested(malformed_object("user", data)); + } } -}; +} -- cgit 1.4.1