Re_node parse_cset(char **s) { Ch_Set cs_ptr, curr_ptr, prev_ptr; char ch; Ch_Range range; if (Unexpected(s, ']')) return NULL; curr_ptr = (Ch_Set) new_node(curr_ptr); cs_ptr = curr_ptr; while (!Unexpected(s, ']')) { range = (Ch_Range)new_node(range); curr_ptr->elt = range; ch = NextChar(s); if (ch == '-') return NULL; /* invalid range */ range->low_bd = ch; if (**s == NUL) return NULL; else if (**s == '-') { /* character range */ (*s)++; if (Invalid_range(**s, ch)) return NULL; else range->hi_bd = NextChar(s); } else range->hi_bd = ch; prev_ptr = curr_ptr; curr_ptr = (Ch_Set) new_node(curr_ptr); prev_ptr->rest = curr_ptr; }; if (**s == ']') { prev_ptr->rest = NULL; return mk_leaf(LITERAL, C_SET, NUL, cs_ptr); } else return NULL; } /* parse_cset */
void AuthSessionData::constructFromSerialized(const QByteArray &serialized) { if (serialized.isEmpty()) { return; } auto readonly = serialized; QBuffer buffer(&readonly); if (!buffer.open(QIODevice::ReadOnly)) { Unexpected("Can't open data for DcOptions::constructFromSerialized()"); } QDataStream stream(&buffer); stream.setVersion(QDataStream::Qt_5_1); qint32 emojiPanTab = static_cast<qint32>(EmojiPanelTab::Emoji); qint32 lastSeenWarningSeen = 0; stream >> emojiPanTab; stream >> lastSeenWarningSeen; if (stream.status() != QDataStream::Ok) { LOG(("App Error: Bad data for AuthSessionData::constructFromSerialized()")); return; } auto uncheckedTab = static_cast<EmojiPanelTab>(emojiPanTab); switch (uncheckedTab) { case EmojiPanelTab::Emoji: case EmojiPanelTab::Stickers: case EmojiPanelTab::Gifs: _variables.emojiPanelTab = uncheckedTab; break; } _variables.lastSeenWarningSeen = (lastSeenWarningSeen == 1); }
void Groups::refreshMessage(not_null<HistoryItem*> item) { if (!isGrouped(item)) { unregisterMessage(item); return; } if (!IsServerMsgId(item->id)) { return; } const auto groupId = item->groupId(); const auto i = _groups.find(groupId); if (i == end(_groups)) { registerMessage(item); return; } auto &items = i->second.items; const auto position = findPositionForItem(items, item); auto current = ranges::find(items, item); if (current == end(items)) { items.insert(position, item); } else if (position == current + 1) { return; } else if (position > current + 1) { for (++current; current != position; ++current) { std::swap(*(current - 1), *current); } } else if (position < current) { for (; current != position; --current) { std::swap(*(current - 1), *current); } } else { Unexpected("Position of item in Groups::refreshMessage()."); } refreshViews(items); }
std::unique_ptr<ContentMemento> Memento::DefaultContent( PeerId peerId, Section section) { Expects(peerId != 0); auto peer = Auth().data().peer(peerId); if (auto to = peer->migrateTo()) { peer = to; } auto migrated = peer->migrateFrom(); peerId = peer->id; auto migratedPeerId = migrated ? migrated->id : PeerId(0); switch (section.type()) { case Section::Type::Profile: return std::make_unique<Profile::Memento>( peerId, migratedPeerId); case Section::Type::Media: return std::make_unique<Media::Memento>( peerId, migratedPeerId, section.mediaType()); case Section::Type::CommonGroups: Assert(peerIsUser(peerId)); return std::make_unique<CommonGroups::Memento>( peerToUser(peerId)); case Section::Type::Members: return std::make_unique<Members::Memento>( peerId, migratedPeerId); } Unexpected("Wrong section type in Info::Memento::DefaultContent()"); }
HistoryMessage::HistoryMessage( not_null<History*> history, const MTPDmessageService &data) : HistoryItem( history, data.vid.v, mtpCastFlags(data.vflags.v), data.vdate.v, data.has_from_id() ? data.vfrom_id.v : UserId(0)) { CreateConfig config; if (data.has_reply_to_msg_id()) config.replyTo = data.vreply_to_msg_id.v; createComponents(config); switch (data.vaction.type()) { case mtpc_messageActionPhoneCall: { _media = std::make_unique<Data::MediaCall>( this, data.vaction.c_messageActionPhoneCall()); } break; default: Unexpected("Service message action type in HistoryMessage."); } setText(TextWithEntities {}); }
not_null<Entry*> Key::entry() const { if (const auto p = base::get_if<not_null<History*>>(&_value)) { return *p; } else if (const auto p = base::get_if<not_null<Folder*>>(&_value)) { return *p; } Unexpected("Empty Dialogs::Key in Key::entry()."); }
//------------------------------------------------------------ static void create_node_dict( hashTable<CC_String,BTCollectable> &dict, BookCaseDB& db ) { DBTable *nodeMeta = db.table(BookCaseDB::NodeMeta, DB::READ); DBCursor cursor(*nodeMeta); const char *bookLocator; const char *nodeLocator; const char *filename; int line_num; const char *title; const char *stitle; const char *style; int throw_exception = 0; while(cursor.next(STRING_CODE, &bookLocator, STRING_CODE, &nodeLocator, STRING_CODE, &filename, INTEGER_CODE, &line_num, SKIP_CODE, /* TOC num */ STRING_CODE, &title, STRING_CODE, &stitle, STRING_CODE, &style, NULL)){ CC_String *key = new CC_String ( nodeLocator ); BTCollectable *value = new BTCollectable ( filename,line_num,bookLocator ); BTCollectable *val = (BTCollectable *)dict.findValue( key ); if ( !val ) { dict.insertKeyAndValue( key, value ); } else { delete key; delete value; throw_exception = 1; cerr << "(ERROR) Duplicate section ID = " << (const char *)*key << endl << " found in file = " << filename << endl << " at line = " << line_num << endl << " is in conflict with " << endl << " section ID = " << (const char *)*key << endl << " found in file = " << val->filename() << endl << " at line = " << val->linenum() << "\n\n"; } } if ( throw_exception ) { throw(Unexpected("Duplicate section IDs are found")); } }
base::optional<int> SharedMediaWithLastSlice::indexOf(Value value) const { const auto result = indexOfImpl(value); if (result && (*result < 0 || *result >= size())) { // Should not happen. auto info = QStringList(); info.push_back("slice:" + QString::number(_slice.size())); info.push_back(_slice.fullCount() ? QString::number(*_slice.fullCount()) : QString("-")); info.push_back(_slice.skippedBefore() ? QString::number(*_slice.skippedBefore()) : QString("-")); info.push_back(_slice.skippedAfter() ? QString::number(*_slice.skippedAfter()) : QString("-")); info.push_back("ending:" + (_ending ? QString::number(_ending->size()) : QString("-"))); info.push_back((_ending && _ending->fullCount()) ? QString::number(*_ending->fullCount()) : QString("-")); info.push_back((_ending && _ending->skippedBefore()) ? QString::number(*_ending->skippedBefore()) : QString("-")); info.push_back((_ending && _ending->skippedAfter()) ? QString::number(*_ending->skippedAfter()) : QString("-")); if (const auto msgId = base::get_if<FullMsgId>(&value)) { info.push_back("value:" + QString::number(msgId->channel)); info.push_back(QString::number(msgId->msg)); const auto index = _slice.indexOf(*base::get_if<FullMsgId>(&value)); info.push_back("index:" + (index ? QString::number(*index) : QString("-"))); } else if (const auto photo = base::get_if<not_null<PhotoData*>>(&value)) { info.push_back("value:" + QString::number((*photo)->id)); } else { info.push_back("value:bad"); } info.push_back("isolated:" + QString(Logs::b(isolatedInSlice()))); info.push_back("last:" + (_lastPhotoId ? QString::number(*_lastPhotoId) : QString("-"))); info.push_back("isolated_last:" + (_isolatedLastPhoto ? QString(Logs::b(*_isolatedLastPhoto)) : QString("-"))); info.push_back("skip:" + (lastPhotoSkip() ? QString::number(*lastPhotoSkip()) : QString("-"))); CrashReports::SetAnnotation("DebugInfo", info.join(',')); Unexpected("Result in SharedMediaWithLastSlice::indexOf"); } return _reversed ? (result | func::negate | func::add(size() - 1)) : result; }
std::unique_ptr<ContentMemento> Memento::DefaultContent( not_null<Data::Feed*> feed, Section section) { switch (section.type()) { case Section::Type::Profile: return std::make_unique<FeedProfile::Memento>(feed); case Section::Type::Channels: return std::make_unique<Channels::Memento>(feed); } Unexpected("Wrong feed section in Info::Memento::DefaultContent()"); }
//------------------------------------------------------------ static void checkTocLink( const char *toc_file_name, hashTable<CC_String,int> &linkTab, hashTable<CC_String,BTCollectable> &nodeTab ) { int flag = 0; char *ToCFileName = strdup ( toc_file_name ); hashTableIterator<CC_String,BTCollectable> nodeit( nodeTab ); while ( ++nodeit ) { CC_String *key = (CC_String *)nodeit.key(); BTCollectable *value = (BTCollectable *)nodeit.value(); if ( !linkTab.contains( key ) ) { flag = 1; const char *file_name = value->filename(); int line_num = value->linenum(); cerr << "(ERROR) Section ID = " << (const char *)*key << endl << " of file = " << file_name << endl << " at line = " << line_num << endl << " does not have a corresponding link with the value = " << (const char *)*key << endl << " from the ToC file = " << ToCFileName << "\n\n"; } } hashTableIterator<CC_String,int> linkit( linkTab ); while ( ++linkit ) { CC_String *link = linkit.key(); int *line_num = linkit.value(); if ( !nodeTab.contains( link ) ) { flag = 1; cerr << "(ERROR) IDREF = " << (const char *)*link << endl << " of ToC file = " << ToCFileName << endl << " at line = " << *line_num << endl << " is pointing to an unavailable node\n\n"; } } delete ToCFileName; if ( flag ) { throw(Unexpected("TOC validation failed\n")); } }
void TrackingStream::next_line() { if (std::getline(*in, text)) text += '\n'; else text.clear(); // hereafter empty text means error line++; col = 0; if (text.empty() and !eof_message.empty()) throw Unexpected(position(), eof_message); for (unsigned char c : text) if (c < ' ' and c != '\n') { if (c == '\t') throw Unexpected(position(), "tab (try the 'expand' program)"); if (c == '\r') throw Unexpected(position(), "carriage return (try the 'dos2unix' program)"); throw Unexpected(position(), "C0 control character"); } }
static void autonumber(FlexBuffer *buffer, const Token& t) { const AttributeRec *id = t.LookupAttr(SGMLName::intern("ID", 1)); const AttributeRec *type = t.LookupAttr(SGMLName::intern("Type", 1)); const AttributeRec *initial = t.LookupAttr(SGMLName::intern("Initial", 1)); const AttributeRec *delta = t.LookupAttr(SGMLName::intern("Delta", 1)); const AttributeRec *reset = t.LookupAttr(SGMLName::intern("Reset", 1)); const AttributeRec *counter = t.LookupAttr(SGMLName::intern("Counter", 1)); if(!id) throw(Unexpected("Autonumber: missing ID attribute")); if(!type) throw(Unexpected("Autonumber: missing Type attribute")); if(!initial) throw(Unexpected("Autonumber: missing Initial attribute")); if(!delta) throw(Unexpected("Autonumber: missing Delta attribute")); if(!reset) throw(Unexpected("Autonumber: missing Reset attribute")); if(!counter) throw(Unexpected("Autonumber: missing Counter attribute")); buffer->writeStr(id->getAttrValueString()); buffer->writeStr(" = autonumber[\""); buffer->writeStr(type->getAttrValueString()); buffer->writeStr("\", \""); buffer->writeStr(initial->getAttrValueString()); buffer->writeStr("\", \""); buffer->writeStr(delta->getAttrValueString()); buffer->writeStr("\", "); write_array(buffer, counter->getAttrValueString(), 1); buffer->writeStr(", "); write_array(buffer, reset->getAttrValueString(), 1); buffer->writeStr("]\n\n"); }
const char * StyleTask::locator() { const char *ret = 0; if (f_locator){ ret = f_locator->content(); } if (!(ret && *ret)){ throw(Unexpected ("No name given to stylesheet.")); } return ret; }
bool CResParser::ParseValue(CUniString& strValue) { switch (CurrentToken()) { case tokenStringLiteral: case tokenIdentifier: strValue=GetStringLiteral(); NextToken(); break; case tokenDoubleLiteral: strValue=GetTokenText(); NextToken(); break; case tokenInt32Literal: if (GetTypeQualifier()==tqRgb) { strValue=GetTokenText(); NextToken(); } else { int iValue=GetInt32Literal(); NextToken(); while (CurrentToken()==tokenOr) { NextToken(); if (!Check(tokenInt32Literal)) return false; iValue|=GetInt32Literal(); NextToken(); } strValue=Format(L"%i", iValue); } break; case tokenInt64Literal: strValue=Format(L"%I64i", GetInt64Literal()); NextToken(); break; default: Unexpected(L"when parsing value "); return false; } return true; }
QByteArray AuthSessionData::serialize() const { auto size = sizeof(qint32) * 2; auto result = QByteArray(); result.reserve(size); { QBuffer buffer(&result); if (!buffer.open(QIODevice::WriteOnly)) { Unexpected("Can't open data for AuthSessionData::serialize()"); } QDataStream stream(&buffer); stream.setVersion(QDataStream::Qt_5_1); stream << static_cast<qint32>(_variables.emojiPanelTab); stream << qint32(_variables.lastSeenWarningSeen ? 1 : 0); } return result; }
MTPWebDocument Result::adjustAttributes(const MTPWebDocument &document) { switch (document.type()) { case mtpc_webDocument: { const auto &data = document.c_webDocument(); return MTP_webDocument( data.vurl, data.vaccess_hash, data.vsize, data.vmime_type, adjustAttributes(data.vattributes, data.vmime_type)); } break; case mtpc_webDocumentNoProxy: { const auto &data = document.c_webDocumentNoProxy(); return MTP_webDocumentNoProxy( data.vurl, data.vsize, data.vmime_type, adjustAttributes(data.vattributes, data.vmime_type)); } break; } Unexpected("Type in InlineBots::Result::adjustAttributes."); }
|| file.skipReason != SkipReason::None); push(label, [&]() -> QByteArray { const auto pre = name.isEmpty() ? QByteArray() : name + ' '; switch (file.skipReason) { case SkipReason::Unavailable: return pre + "(File unavailable, please try again later)"; case SkipReason::FileSize: return pre + "(File exceeds maximum size. " "Change data exporting settings to download.)"; case SkipReason::FileType: return pre + "(File not included. " "Change data exporting settings to download.)"; case SkipReason::None: return FormatFilePath(file); } Unexpected("Skip reason while writing file path."); }()); }; const auto pushPhoto = [&](const Image &image) { pushPath(image.file, "photo"); if (image.width && image.height) { push("width", image.width); push("height", image.height); } }; message.action.content.match([&](const ActionChatCreate &data) { pushActor(); pushAction("create_group"); push("title", data.title); pushUserNames(data.userIds);
void InnerWidget::peerListAddSelectedRowInBunch(not_null<PeerData*> peer) { Unexpected("Item selection in Info::Profile::Members."); }
//------------------------------------------------------------ static void locator_table( BookCaseDB& db, hashTable<CC_String, BTCollectable> &hd) { DBTable *locTable = db.table(BookCaseDB::Locator, DB::READ); DBCursor cursor(*locTable); const char *locator; const char *nodeloc; const char *reflabel; const char *filename; int line_num; int dup_count = 0; while(cursor.next(STRING_CODE, &locator, STRING_CODE, &nodeloc, STRING_CODE, &reflabel, STRING_CODE, &filename, INTEGER_CODE, &line_num, NULL)){ char *buf = new char[strlen(nodeloc) + strlen(reflabel) + 2]; sprintf(buf, "%s\t%s", nodeloc, reflabel); CC_String *loc_collect = new CC_String( locator ); BTCollectable *node_collect = new BTCollectable( filename, line_num, buf ); delete[] buf; BTCollectable *val = hd.findValue( loc_collect ); if ( !val ) { hd.insertKeyAndValue( loc_collect, node_collect ); } else { delete loc_collect; delete node_collect; dup_count++; cerr << "(ERROR) Duplicate ID = " << locator << endl << " found in file = " << filename << endl << " at line = " << line_num << endl << " is in conflict with " << endl << " ID = " << locator << endl << " found in file = " << val->filename() << endl << " at line = " << val->linenum() << "\n\n"; } } if ( dup_count ) { throw(Unexpected(form("Number of duplicate IDs found = %d\n", dup_count))); } }
SearchResult ParseSearchResult( not_null<PeerData*> peer, Storage::SharedMediaType type, MsgId messageId, SparseIdsLoadDirection direction, const MTPmessages_Messages &data) { auto result = SearchResult(); result.noSkipRange = MsgRange{ messageId, messageId }; auto messages = [&] { switch (data.type()) { case mtpc_messages_messages: { auto &d = data.c_messages_messages(); App::feedUsers(d.vusers); App::feedChats(d.vchats); result.fullCount = d.vmessages.v.size(); return &d.vmessages.v; } break; case mtpc_messages_messagesSlice: { auto &d = data.c_messages_messagesSlice(); App::feedUsers(d.vusers); App::feedChats(d.vchats); result.fullCount = d.vcount.v; return &d.vmessages.v; } break; case mtpc_messages_channelMessages: { auto &d = data.c_messages_channelMessages(); if (auto channel = peer->asChannel()) { channel->ptsReceived(d.vpts.v); } else { LOG(("API Error: received messages.channelMessages when " "no channel was passed! (ParseSearchResult)")); } App::feedUsers(d.vusers); App::feedChats(d.vchats); result.fullCount = d.vcount.v; return &d.vmessages.v; } break; case mtpc_messages_messagesNotModified: { LOG(("API Error: received messages.messagesNotModified! " "(ParseSearchResult)")); return (const QVector<MTPMessage>*)nullptr; } break; } Unexpected("messages.Messages type in ParseSearchResult()"); }(); if (!messages) { return result; } auto addType = NewMessageExisting; result.messageIds.reserve(messages->size()); for (auto &message : *messages) { if (auto item = App::histories().addNewMessage(message, addType)) { auto itemId = item->id; if ((type == Storage::SharedMediaType::kCount) || item->sharedMediaTypes().test(type)) { result.messageIds.push_back(itemId); } accumulate_min(result.noSkipRange.from, itemId); accumulate_max(result.noSkipRange.till, itemId); } } if (messageId && result.messageIds.empty()) { result.noSkipRange = [&]() -> MsgRange { switch (direction) { case SparseIdsLoadDirection::Before: // All old loaded. return { 0, result.noSkipRange.till }; case SparseIdsLoadDirection::Around: // All loaded. return { 0, ServerMaxMsgId }; case SparseIdsLoadDirection::After: // All new loaded. return { result.noSkipRange.from, ServerMaxMsgId }; } Unexpected("Direction in ParseSearchResult"); }(); } return result; }
//------------------------------------------------------------ static void writeCCF(BookCaseDB& db, info_lib *mmdb, const char *bcname ) { DBTable *bookMeta = db.table(BookCaseDB::BookMeta, DB::READ); DBCursor cursor(*bookMeta); DBTable *ccf = db.DB::table(DATABASE_STDIO, DOC_CODE, BT_NUM_DOC_FIELDS, DB::CREATE); const char *bookLocator; const char *stitle; const char *title; int seq_no; int tabQty; const char **tabLines; const char *access; /* * First put the global node table into hash dictionary */ hashTable<CC_String,BTCollectable> global_node_tab(hash_func); create_node_dict( global_node_tab , db); /* throw exception if duplicate node locator is found */ int exception_flag = 0; while(cursor.next(STRING_CODE, &bookLocator, STRING_CODE, &stitle, STRING_CODE, &title, INTEGER_CODE, &seq_no, SHORT_LIST_CODE, &tabQty, STRING_CODE, &tabLines, STRING_CODE, &access, NULL)){ StringList heap; /* convert tab to oids in forst tabQty items in heap */ for(int i = 0; i < tabQty; i++){ char *t = (char *)tabLines[i]; const char *name = strtok( t, "\t" ); const char *loc = strtok( NULL, "\t"); const char *line = strtok( NULL, "\t"); const char *file_name = strtok( NULL, "\t"); int nameLen = strlen( name ); /* * First check if the tab link is resolved */ CC_String key ( loc ); BTCollectable *tab_link = (BTCollectable *)global_node_tab. findValue( &key ); if ( !tab_link ) { cerr << "(ERROR) Tab ID = " << loc << endl << " of book = " << title << endl << " specified in file = " << file_name << endl << " at line = " << line << endl << " is not pointing to any section ID found in the book\n\n"; exception_flag = 1; } else { /* * see if it is a node locator within the same book */ if ( strcmp( tab_link->get_value(), bookLocator )) { cerr << "(ERROR) Tab ID = " << loc << endl << " of book = " << title << endl << " specified in file = " << file_name << endl << " at line = " << line << endl << " is not pointing to any section ID found in the book\n\n"; exception_flag = 1; } } // if exception_flag is set, calling to_oid will throw exception // It will just loop through all the tabs, and report all the bad ones if ( !exception_flag ) { const char *tabOID = to_oid(mmdb, bcname, loc); char *result = new char[nameLen + 1 + strlen(tabOID) + 1]; sprintf(result, "%s\t%s", name, tabOID ); heap.add(result); } } if ( !exception_flag ) { const char *bookOID = heap.append(to_oid(mmdb, bcname, bookLocator)); #ifdef FISH_DEBUG DBUG_PRINT("CCF", ("Load Book: O:%s `%s'\n", bookOID, title)); #endif ccf->insert(OID_CODE, bookOID, STRING_CODE, stitle, STRING_CODE, title, INTEGER_CODE, seq_no, SHORT_LIST_CODE, tabQty, STRING_CODE, heap.array(), STRING_CODE, access, NULL); } } if ( exception_flag ) { throw(Unexpected("Tab validation failed")); } delete ccf; global_node_tab.clearAndDestroy(); }
void StyleTask::markup( const Token &t ) { ComplexTask::markup(t); if (t.type() == START) { /* * Process Stylesheet start tags... */ switch(t.olaf()){ case OLAF::Stylesheet: if (f_base >= 0) { throw (Unexpected ("illegal nested STYLESHEET architectural form")); } f_base = t.level(); #ifdef FISH_DEBUG DBUG_PRINT("Style", ("Style level=`%d'\n", f_base)); #endif break; case OLAF::Path: if ( f_pathbuf != NULL ) { delete f_pathbuf; } f_pathbuf = new FlexBuffer(); f_buffer = f_pathbuf; f_dataMode = inPath; break; case OLAF::Select: f_buffer->writeStr( "[" ); f_select = t.level(); break; case OLAF::Online: f_buffer = onlineSS; // feature_depth->clear(); if ( f_pathbuf == NULL ) { throw(Unexpected("no path available for online feature.")); } report_position(f_buffer, t.file(), t.line()); f_buffer->writeStr( f_pathbuf->GetBuffer() ); f_buffer->writeStr( "\n" ); write_tabs( f_buffer, feature_depth, '\t'); f_buffer->writeStr( "{\n" ); feature_depth->push(t.level()); break; case OLAF::Print: f_buffer = printSS; // feature_depth->clear(); if ( f_pathbuf == NULL ) { throw(Unexpected("no path available for print feature.")); } report_position(f_buffer, t.file(), t.line()); f_buffer->writeStr( f_pathbuf->GetBuffer() ); f_buffer->writeStr( "\n" ); write_tabs( f_buffer, feature_depth, '\t'); f_buffer->writeStr( "{\n" ); feature_depth->push( t.level() ); break; case OLAF::AutoNumber: report_position(onlineSS, t.file(), t.line()); autonumber(onlineSS, t); report_position(printSS, t.file(), t.line()); autonumber(printSS, t); break; case OLAF::FeatureText: report_position(f_buffer, t.file(), t.line()); write_tabs( f_buffer, feature_depth, '\t'); f_buffer->writeStr( t.giName() ); f_buffer->writeStr( ": " ); f_dataMode = startContent; break; case OLAF::AutoRef: { const AttributeRec *arec; int id = SGMLName::intern("ID"); if((arec = t.LookupAttr(id))){ if(f_dataMode == inContent){ f_buffer->writeStr(" + "); } f_buffer->writeStr(arec->getAttrValueString()); f_dataMode = inContent; } /* else document is not conforming... sgmls will report error */ } break; case OLAF::Feature: report_position(f_buffer, t.file(), t.line()); write_tabs( f_buffer, feature_depth, '\t'); f_buffer->writeStr( t.giName() ); f_buffer->writeStr( ": " ); const AttributeRec *arec; /* * Is it an enumeration feature? */ if((arec = t.LookupAttr(OLAF::OL_Choice))){ /* OL_Choice can only be applied to NAME attributes, hence we don't neet to worryabout "'s in the attribute value. */ /* except TRUE and FALSE....*/ const char *val = arec->getAttrValueString(); int quotes = !isdigit(val[0]) && strcmp(val, "TRUE") != 0 && strcmp(val, "FALSE") != 0 && val[0] != '@'; if (quotes) f_buffer->writeStr("\""); f_buffer->writeStr(val); if (quotes) f_buffer->writeStr("\" "); }else{ f_buffer->writeStr( " {\n" ); for (arec = t.GetFirstAttr(); arec != NULL; arec = t.GetNextAttr( arec )) { if (( arec->getAttrValueString() != NULL ) && ( arec->getAttrName() != OLAF::OLIAS )) { write_tabs( f_buffer, feature_depth, '\t'); f_buffer->put('\t'); write_attr(f_buffer, arec); f_buffer->writeStr( ",\n" ); } } feature_depth->push(t.level()); } break; } /* * first time we see OL-ID="...", spawn an OL_Data to collect the id */ if ((f_base >= 0) && (f_locator == NULL) && (t.LookupAttr(OLAF::OL_id))) { #ifdef FISH_DEBUG DBUG_PRINT("Style", ("spawning locator collection subtask\n")); #endif f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES); addSubTask( f_locator ); } } else if (t.type() == END) { if (f_base > 0) { int topelement; if ( !feature_depth->empty() ) { if ( (topelement = feature_depth->top()) ) { if ( topelement == t.level() ) { topelement = feature_depth->pop(); write_tabs( f_buffer, feature_depth, '\t'); if(feature_depth->empty()){ f_buffer->writeStr("}\n"); } else { f_buffer->writeStr("},\n"); } }else if ( topelement + 1 == t.level() ) { /* need a new-line at end of FeatureText data */ f_buffer->writeStr(",\n"); } } } if (t.level() == f_base) { /* found end of stylesheet... write out StyleSheet data */ #ifdef FISH_DEBUG DBUG_PRINT("Style", ("found end of stylesheet write out StyleSheet data\n")); #endif write_record(); } else if(t.level() == f_select){ f_buffer->writeStr( "]" ); f_select = -1; } } } }
TextState HistoryMedia::getStateGrouped( const QRect &geometry, QPoint point, StateRequest request) const { Unexpected("Grouping method call."); }
bool CResParser::Parse(CResNode* pRootNode, const wchar_t* pszContent, const wchar_t* pszFileName) { // Initialize tokenizer CCppTokenizer::ParseString(pszContent, pszFileName); // Parse it CVector<CResNode*> ScopeStack; ScopeStack.Push(pRootNode); while (CurrentToken()!=tokenEOF) { // Ending a Node if (CurrentToken()==tokenCloseBrace) { // Skip it NextToken(); if (CurrentToken()==tokenSemiColon) { NextToken(); } // Pop scope stack... ScopeStack.Pop(); // Check have something to pop! if (ScopeStack.IsEmpty()) { Unexpected(); return false; } continue; } // Generate definition? if (CurrentToken()==tokenGen) { while (true) { // Yes, find the end of the generator block (or, a new target definition) const wchar_t* pszEndScan[]= {L"#endgen", L"#target"}; if (!ScanForward(pszEndScan, _countof(pszEndScan))) return false; NextToken(); if (CurrentToken()!=tokenTarget) break; } Skip(tokenEndGen); continue; } // Get name of element - expect string literal or identifier... CUniString strName=GetStringLiteral(); if (CurrentToken()!=tokenStringLiteral && CurrentToken()!=tokenIdentifier) { Unexpected(L"when parsing Node or value name "); return false; } NextToken(); if (CurrentToken()==tokenPointer) { // Get the link to name NextToken(); CUniString strLinkTo=GetStringLiteral(); if (!Skip(tokenStringLiteral)) return false; if (strLinkTo.IsEmpty()) { SetError(L"Missing link reference name"); return false; } // Start a new Node CResNode* pNewSection; pNewSection=ScopeStack.Top()->CreateNewNode(strName); pNewSection->SetLink(strLinkTo); Skip(tokenSemiColon); continue; } // Parse an optional assign before open brace... bool bHaveAssign=CurrentToken()==tokenEquals; if (bHaveAssign) { NextToken(); } // Starting a Node? if (CurrentToken()==tokenOpenBrace) { // Skip it NextToken(); // Start a new Node ScopeStack.Push(ScopeStack.Top()->CreateNewNode(strName)); continue; } // Expect assignment if (!bHaveAssign) { if (!Skip(tokenEquals)) return false; NextToken(); } // Parse value... CUniString strValue; if (!ParseValue(strValue)) return false; // Skip semicolon if (!Skip(tokenSemiColon)) return false; // Store value... ScopeStack.Top()->SetValue(strName, strValue); } // Check nothing left on stack except the root node if (ScopeStack.GetSize()!=1) { SetError(L"Missing closing brace"); return false; } // Done! return true; }
MTPmessages_Search PrepareSearchRequest( not_null<PeerData*> peer, Storage::SharedMediaType type, const QString &query, MsgId messageId, SparseIdsLoadDirection direction) { const auto filter = [&] { using Type = Storage::SharedMediaType; switch (type) { case Type::Photo: return MTP_inputMessagesFilterPhotos(); case Type::Video: return MTP_inputMessagesFilterVideo(); case Type::PhotoVideo: return MTP_inputMessagesFilterPhotoVideo(); case Type::MusicFile: return MTP_inputMessagesFilterMusic(); case Type::File: return MTP_inputMessagesFilterDocument(); case Type::VoiceFile: return MTP_inputMessagesFilterVoice(); case Type::RoundVoiceFile: return MTP_inputMessagesFilterRoundVoice(); case Type::RoundFile: return MTP_inputMessagesFilterRoundVideo(); case Type::GIF: return MTP_inputMessagesFilterGif(); case Type::Link: return MTP_inputMessagesFilterUrl(); case Type::ChatPhoto: return MTP_inputMessagesFilterChatPhotos(); } return MTP_inputMessagesFilterEmpty(); }(); const auto minId = 0; const auto maxId = 0; const auto limit = messageId ? kSharedMediaLimit : 0; const auto offsetId = [&] { switch (direction) { case SparseIdsLoadDirection::Before: case SparseIdsLoadDirection::Around: return messageId; case SparseIdsLoadDirection::After: return messageId + 1; } Unexpected("Direction in PrepareSearchRequest"); }(); const auto addOffset = [&] { switch (direction) { case SparseIdsLoadDirection::Before: return 0; case SparseIdsLoadDirection::Around: return -limit / 2; case SparseIdsLoadDirection::After: return -limit; } Unexpected("Direction in PrepareSearchRequest"); }(); return MTPmessages_Search( MTP_flags(0), peer->input, MTP_string(query), MTP_inputUserEmpty(), filter, MTP_int(0), MTP_int(0), MTP_int(offsetId), MTP_int(addOffset), MTP_int(limit), MTP_int(maxId), MTP_int(minId)); }