From 376b88ec09ef8cf71dd823467406c58204485fcc Mon Sep 17 00:00:00 2001 From: Oleg Morozenkov Date: Tue, 11 Aug 2015 22:13:23 +0300 Subject: Fixed compiler's errors in TgTypeParser + fixed indentation + some other fixes --- src/TgTypeParser.cpp | 792 +++++++++++++++++++++++++-------------------------- 1 file changed, 396 insertions(+), 396 deletions(-) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 9a1f93a..81d2119 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -28,463 +28,463 @@ using namespace boost::property_tree; namespace TgBot { TgTypeParser& TgTypeParser::getInstance() { - static TgTypeParser result; - return result; + static TgTypeParser result; + return result; } -User::Ptr TgTypeParser::parseUser(const ptree& data) const { - User::Ptr result(new User); - result->id = data.get("id"); - result->firstName = data.get("first_name"); - result->lastName = data.get("last_name", ""); - result->username = data.get("username", ""); - return result; +User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const { + User::Ptr result(new User); + result->id = data.get("id"); + result->firstName = data.get("first_name"); + result->lastName = data.get("last_name", ""); + result->username = data.get("username", ""); + return result; } string TgTypeParser::parseUser(const User::Ptr& object) const { - if (!object) { - return ""; - } - string result; - result += '{'; - appendToJson(result, "id", object->id); - appendToJson(result, "first_name", object->firstName); - appendToJson(result, "last_name", object->lastName); - appendToJson(result, "username", object->username); - result.erase(result.length() - 1); - result += '}'; - return result; -} - -GroupChat::Ptr TgTypeParser::parseGroupChat(const ptree& data) const { - GroupChat::Ptr result(new GroupChat); - result->id = data.get("id"); - result->title = data.get("title"); - return result; + if (!object) { + return ""; + } + string result; + result += '{'; + appendToJson(result, "id", object->id); + appendToJson(result, "first_name", object->firstName); + appendToJson(result, "last_name", object->lastName); + appendToJson(result, "username", object->username); + result.erase(result.length() - 1); + result += '}'; + return result; +} + +GroupChat::Ptr TgTypeParser::parseJsonAndGetGroupChat(const ptree& data) const { + GroupChat::Ptr result(new GroupChat); + result->id = data.get("id"); + result->title = data.get("title"); + return result; } string TgTypeParser::parseGroupChat(const GroupChat::Ptr& object) const { - if (!object) { - return ""; - } - string result; - result += '{'; - appendToJson(result, "id", object->id); - appendToJson(result, "title", object->title); - result.erase(result.length() - 1); - result += '}'; - return result; -} - -Message::Ptr TgTypeParser::parseMessage(const ptree& data) const { - Message::Ptr result(new Message); - result->messageId = data.get("message_id"); - result->from = parseUser(data.find("from")->second); - result->date = data.get("date"); - result->chat = parseGenericChat(data.find("chat")->second); - result->forwardFrom = tryParse(parseUser, data, "forward_from"); - result->forwardDate = data.get("forward_date", 0); - result->replyToMessage = tryParse(parseMessage, data, "reply_to_message"); - result->text = data.get("text", ""); - result->audio = tryParse