本文整理汇总了C++中ptree::find方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::find方法的具体用法?C++ ptree::find怎么用?C++ ptree::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ptree
的用法示例。
在下文中一共展示了ptree::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseJsonAndGetMessage
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: string
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: parseJsonAndGetUpdate
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;
}