예제 #1
0
Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
	Message::Ptr result(new Message);
	result->messageId = data.get<int32_t>("message_id");
	result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
	result->date = data.get<int32_t>("date");
	result->chat = parseJsonAndGetChat(data.find("chat")->second);
	result->forwardFrom = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "forward_from");
	result->forwardDate = data.get("forward_date", 0);
	result->replyToMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "reply_to_message");
	result->text = data.get("text", "");
	result->audio = tryParseJson<Audio>(&TgTypeParser::parseJsonAndGetAudio, data, "audio");
	result->document = tryParseJson<Document>(&TgTypeParser::parseJsonAndGetDocument, data, "document");
	result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo");
	result->sticker = tryParseJson<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "sticker");
	result->video = tryParseJson<Video>(&TgTypeParser::parseJsonAndGetVideo, data, "video");
	result->contact = tryParseJson<Contact>(&TgTypeParser::parseJsonAndGetContact, data, "contact");
	result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
	result->newChatParticipant = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "new_chat_participant");
	result->leftChatParticipant = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "left_chat_participant");
	result->newChatTitle = data.get("new_chat_title", "");
	result->newChatPhoto = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "new_chat_photo");
	result->deleteChatPhoto = data.get("delete_chat_photo", false);
	result->groupChatCreated = data.get("group_chat_created", false);
	result->caption = data.get("caption", false);
	return result;
}
예제 #2
0
파일: storage.cpp 프로젝트: miraline/myscan
Request::Request(const ptree &pt, const Storage &storage) {
	ptree::const_assoc_iterator it;
	storage.checkReady();

	indexName = pt.get<string>("index", "id");
	tableName = pt.get<string>("from");

	string api = pt.get<string>("api_key");
	APIKey = string(); for (size_t i=0; i<api.size() && APIKey.size()<=32; i++) if (isalnum(api[i])) APIKey += api[i];

	mode = Mode::Default;
	it = pt.find("mode"); if ( it != pt.not_found() ) {
		string modeString = pt.get<string>("mode");
		if (modeString == "count") mode = Mode::Count;
	}

	offset = pt.get<size_t>("offset", 0);
	limit = pt.get<size_t>("limit", 10);
	if (limit > 100) limit = 100;
	const Table &tbl = storage.activeSlotConst().getTableByNameConst(tableName);

	string name;
	name = "where"; it = pt.find(name); if ( it != pt.not_found() ) {BOOST_FOREACH(const ptree::value_type &v, pt.get_child(name)) { filters.push_back( ColumnCondition(v, tbl, ColumnCondition::OperType::Compare) ); } }
예제 #3
0
Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const ptree& data) const {
	Update::Ptr result(new Update);
	result->updateId = data.get<int32_t>("update_id");
	result->message = parseJsonAndGetMessage(data.find("message")->second);
	return result;
}