QString Entry::debugInfo() const { QString info; info += QLatin1String("### Entry: ###################\n"); if (!title().isEmpty()) info += QLatin1String("title: #") + title() + QLatin1String("#\n"); if (!summary().isEmpty()) info += QLatin1String("summary: #") + summary() + QLatin1String("#\n"); if (!id().isEmpty()) info += QLatin1String("id: #") + id() + QLatin1String("#\n"); if (!content().isNull()) info += content().debugInfo(); if (!rights().isEmpty()) info += QLatin1String("rights: #") + rights() + QLatin1String("#\n"); QString dupdated = dateTimeToString(updated()); if (!dupdated.isNull()) info += QLatin1String("updated: #") + dupdated + QLatin1String("#\n"); QString dpublished = dateTimeToString(published()); if (!dpublished.isNull()) info += QLatin1String("published: #") + dpublished + QLatin1String("#\n"); QList<Link> dlinks = links(); QList<Link>::ConstIterator endlinks = dlinks.constEnd(); for (QList<Link>::ConstIterator it = dlinks.constBegin(); it != endlinks; ++it) info += (*it).debugInfo(); QList<Category> dcats = categories(); QList<Category>::ConstIterator endcats = dcats.constEnd(); for (QList<Category>::ConstIterator it = dcats.constBegin(); it != endcats; ++it) info += (*it).debugInfo(); info += QLatin1String("### Authors: ###################\n"); QList<Person> dauthors = authors(); QList<Person>::ConstIterator endauthors = dauthors.constEnd(); for (QList<Person>::ConstIterator it = dauthors.constBegin(); it != endauthors; ++it) info += (*it).debugInfo(); info += QLatin1String("### Contributors: ###################\n"); QList<Person> dcontri = contributors(); QList<Person>::ConstIterator endcontri = dcontri.constEnd(); for (QList<Person>::ConstIterator it = dcontri.constBegin(); it != endcontri; ++it) info += (*it).debugInfo(); if (!source().isNull()) info += source().debugInfo(); info += QLatin1String("### Entry end ################\n"); return info; }
QString Source::debugInfo() const { QString info; info += QLatin1String("### Source: ###################\n"); if (!title().isEmpty()) info += QLatin1String("title: #") + title() + QLatin1String("#\n"); if (!subtitle().isEmpty()) info += QLatin1String("subtitle: #") + subtitle() + QLatin1String("#\n"); if (!id().isEmpty()) info += QLatin1String("id: #") + id() + QLatin1String("#\n"); if (!rights().isEmpty()) info += QLatin1String("rights: #") + rights() + QLatin1String("#\n"); if (!icon().isEmpty()) info += QLatin1String("icon: #") + icon() + QLatin1String("#\n"); if (!logo().isEmpty()) info += QLatin1String("logo: #") + logo() + QLatin1String("#\n"); if (!generator().isNull()) info += generator().debugInfo(); QString dupdated = dateTimeToString(updated()); if (!dupdated.isNull()) info += QLatin1String("updated: #") + dupdated + QLatin1String("#\n"); QList<Link> dlinks = links(); QList<Link>::ConstIterator endlinks = dlinks.constEnd(); for (QList<Link>::ConstIterator it = dlinks.constBegin(); it != endlinks; ++it) info += (*it).debugInfo(); QList<Category> dcats = categories(); QList<Category>::ConstIterator endcats = dcats.constEnd(); for (QList<Category>::ConstIterator it = dcats.constBegin(); it != endcats; ++it) info += (*it).debugInfo(); info += QLatin1String("### Authors: ###################\n"); QList<Person> dauthors = authors(); QList<Person>::ConstIterator endauthors = dauthors.constEnd(); for (QList<Person>::ConstIterator it = dauthors.constBegin(); it != endauthors; ++it) info += (*it).debugInfo(); info += QLatin1String("### Contributors: ###################\n"); QList<Person> dcontri = contributors(); QList<Person>::ConstIterator endcontri = dcontri.constEnd(); for (QList<Person>::ConstIterator it = dcontri.constBegin(); it != endcontri; ++it) info += (*it).debugInfo(); info += QLatin1String("### Source end ################\n"); return info; }
std::pair<float, float> ScoreSet::calculateLRAccuracies(std::map<int, Score>::const_iterator divider) const { std::pair<float, float> ret; std::pair<int, int> rights(0, 0); std::pair<int, int> wrongs(0, 0); std::map<int, Score>::const_iterator it = scores.begin(); for (; it != divider; ++it) { rights.first += it->second.right; wrongs.first += it->second.wrong; } for (; it != scores.end(); ++it) { rights.second += it->second.right; wrongs.second += it->second.wrong; } if (rights.first + wrongs.first == 0) ret.first = 1.00; else ret.first = static_cast<float>(rights.first) / (rights.first + wrongs.first); if (rights.second + wrongs.second == 0) ret.second = 0.25; else ret.second = static_cast<float>(rights.second) / (rights.second + wrongs.second); return ret; }
ExpandRequestPacket::ExpandRequestPacket( const ExpandRequestData& data, const UserUser* user ) : RequestPacket( REQUEST_HEADER_SIZE + calcPacketSize( data, user ), DEFAULT_PACKET_PRIO, Packet::PACKETTYPE_EXPAND_REQUEST, Packet::NO_PACKET_ID, // Packet ID Packet::MAX_REQUEST_ID, Packet::MAX_MAP_ID ) { int pos = REQUEST_HEADER_SIZE; UserRightsMapInfo rights( data.getIDPair().first, user ); SaveLengthHelper slh ( this, pos ); slh.writeDummyLength( pos ); rights.save( this, pos ); slh.updateLengthUsingEndPos( pos ); data.save( this, pos ); setLength( pos ); if( data.getIDPair().first == MAX_UINT32 ) { setMapID( rights.getFirstAllowedMapID() ); } else { setMapID( data.getIDPair().first ); } }
static int snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) { if (snac->subtype == 0x0003) return rights(od, conn, mod, frame, snac, bs); return 0; }
static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) { if (snac->subtype == 0x0003) return rights(sess, mod, rx, snac, bs); return 0; }
int ExpandRequestPacket::calcPacketSize( const ExpandRequestData& data, const UserUser* user ) { int size = data.getSizeInPacket(); UserRightsMapInfo rights( data.getIDPair().first, user ); size += rights.getSizeInPacket() + 4; return size; }
void User::set_permission(Rights perm, bool can) { Rights r = rights(); if (can) { r = Rights(r | perm); } else { r = Rights(r & (~perm)); } set_rights(r); }
static int snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) { if (snac->subtype == SNAC_SUBTYPE_BUDDY_RIGHTSINFO) return rights(od, conn, mod, frame, snac, bs); else if ((snac->subtype == SNAC_SUBTYPE_BUDDY_ONCOMING) || (snac->subtype == SNAC_SUBTYPE_BUDDY_OFFGOING)) return buddychange(od, conn, mod, frame, snac, bs); return 0; }
gboolean parse_value (PREFS *images, char *key, char *prefsline, char *entry_place) { /* Parse the given line. Check against keys, */ /* if it matches then copy value to the preferences object. */ char current_key[KEY_WORDS_MAX_SIZE]; /* Left hand holder */ char current_var[MAX_LINE_CHARACTERS]; /* Right hand holder */ int key_length; /* Length of current key */ GtkWidget *entry_field; /* Entry field to fill */ /* Check to see if the keys match */ key_length = strlen (key); /* Get length of key */ lefts (current_key, prefsline, key_length); if (strcmp (key, current_key)) /* Do they match? */ return FALSE; /* Keys don't match */ /* The keys match, get the value of the key */ rights (current_var, prefsline, strlen (prefsline) - key_length); lefts (current_var, current_var, strlen (current_var) - 1); /* Check to see if the value is NULL */ if (!strcmp ("", current_var)) return TRUE; /* The value was NULL */ /* We have the value, put it in it's place */ if (strcmp (KEY_DISPLAY_COMMAND, current_key)) { /* This is for everything but the "Display Command" checkbox */ entry_field = glade_xml_get_widget (images->xml, entry_place); gtk_entry_set_text (GTK_ENTRY (entry_field), current_var); } else { /* This is only for the "Display Command" checkbox */ entry_field = glade_xml_get_widget (images->xml, entry_place); if (!strcmp (current_var, "TRUE")) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_field), TRUE); else gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_field), FALSE); } return TRUE; }
ExternalItemInfoRequestPacket:: ExternalItemInfoRequestPacket( const SearchMatch& match, const LangType& langType, const UserUser* user ) : RequestPacket( 65536, DEFAULT_PACKET_PRIO, Packet::PACKETTYPE_EXTERNALITEMINFO_REQUEST, Packet::NO_PACKET_ID, // Packet ID Packet::MAX_REQUEST_ID, Packet::MAX_MAP_ID ) { setResourceID( match.getExtSource() ); int pos = REQUEST_HEADER_SIZE; UserRightsMapInfo rights( MAX_UINT32, user ); rights.save( this, pos ); incWriteString( pos, match.getExtID() ); incWriteLong ( pos, langType ); incWriteLong( pos, match.getCoords().lat ); incWriteLong( pos, match.getCoords().lon ); incWriteString( pos, match.getName() ); setLength( pos ); }
bool User::has_permission(Rights perm) const { return has_permission(perm, rights()); }
GfxFeatureMapRequestPacket::GfxFeatureMapRequestPacket( uint32 mapID, const UserUser* user, uint16 reqID, uint16 packetID, int32 upperLeftLat, int32 upperLeftLon, int32 lowerRightLat, int32 lowerRightLon, uint16 screenSizeX, uint16 screenSizeY, uint32 maxScaleLevel, uint32 minScaleLevel, uint32 filtScaleLevel, LangTypes::language_t language, const MapSettings* mapSettings, bool ignoreStartOffset, bool ignoreEndOffset, uint16 startOffset, uint16 endOffset, bool drawOverviewContents, bool extractForTileMaps ) : RequestPacket( MAX_PACKET_SIZE, GFXFEATUREMAP_REQUEST_PRIO, PACKETTYPE_GFXFEATUREMAPREQUEST, packetID, reqID, MAX_UINT32 ) { setMapID( mapID ); MC2_ASSERT(mapSettings != NULL); writeLong( upperLeftLat_POS, upperLeftLat ); writeLong( upperLeftLon_POS, upperLeftLon ); writeLong( lowerRightLat_POS, lowerRightLat ); writeLong( lowerRightLon_POS, lowerRightLon ); writeShort( screenSizeX_POS, screenSizeX ); writeShort( screenSizeY_POS, screenSizeY ); writeLong( maxScaleLevel_POS, maxScaleLevel ); writeLong( minScaleLevel_POS, minScaleLevel ); writeLong( filtScaleLevel_POS, filtScaleLevel ); writeLong( language_POS, language ); writeShort( startOffset_POS, startOffset ); writeShort( endOffset_POS, endOffset ); // Write some bits. setIgnoreStartOffset(ignoreStartOffset); setIgnoreEndOffset(ignoreEndOffset); setDrawOverviewContents(drawOverviewContents); writeBit(isStartAndEnd_POS, EXTRACT_FOR_TILEMAPS_BIT_POS, extractForTileMaps); writeByte( nbrReqPackets_POS, 0); // Nbr req packets writeShort( nbrNodeIDs_POS, 0 ); // Nbr node ids. int pos = endStatic_POS; mapSettings->saveToPacket( this, pos ); setLength( pos ); UserRightsMapInfo rights( mapID, user, ~MapRights() ); rights.save( this, pos ); // Save the real length of the mapSettings + userRights writeLong( mapSettingsLen_POS, pos - endStatic_POS ); setLength( pos ); }
void operator()(const Scores& scores, Dependency& dependency) { const size_t sentence_size = dependency.size(); const int last_max = sentence_size + 1; actives.clear(); actives.resize(sentence_size + 2, hypothesis_set_type(sentence_size + 2, sentence_size + 2, sentence_size + 2, hypothesis_type())); // initialize by axioms... for (int pos = 0; pos != last_max; ++ pos) { // we need to shift + 1 for correct indexing... // [h3, j, h3 j, j + 1] where j == pos + 1 and h3 should starts from -1 for (int h3 = -1; h3 != pos; ++ h3) actives(pos, pos + 1)(h3 + 1, h3 + 1, pos + 1).score = 0.0; } for (int last = 2; last <= last_max; ++ last) for (int length = 2; last - length >= 0; ++ length) { const int first = last - length; // // is it correct??? // [h1, first, h2 h3, middle] [h3, middle, h4 h5, last] // // first <= h3 < middle // middle <= h5 < last // h3 <= h4 < h5 // -1 <= h1 < h3 (or first??? given h3 < middle...?) // h1 <= h2 < h3 hypothesis_set_type& cells = actives(first, last); for (int middle = first + 1; middle < last; ++ middle) { const hypothesis_set_type& lefts = actives(first, middle); const hypothesis_set_type& rights = actives(middle, last); for (int h3 = first; h3 < middle; ++ h3) for (int h5 = middle; h5 < last; ++ h5) for (int h4 = h3; h4 < h5; ++ h4) for (int h1 = -1; h1 < first; ++ h1) for (int h2 = h1; h2 < h3; ++ h2) { const hypothesis_type& left = lefts(h1 + 1, h2 + 1, h3 + 1); const hypothesis_type& right = rights(h3 + 1, h4 + 1, h5 + 1); // [h1, i, h2 h5, j] (la1; h5 -> h4) // left attachment if (h4 > 0) enumerate(cells(h1 + 1, h2 + 1, h5 + 1), left, right, h5, h4, scores(h5, h4)); // [h1, i, h2 h4, j] (ra1; h4 -> h5) // right attachment if (h4 >= 0) enumerate(cells(h1 + 1, h2 + 1, h4 + 1), left, right, h4, h5, scores(h4, h5)); // [h1, i, h4 h5, j] (la2; h5 -> h2) // left attachment if (h2 > 0) enumerate(cells(h1 + 1, h4 + 1, h5 + 1), left, right, h5, h2, scores(h5, h2)); // [h1, i, h2 h4, j] (ra2; h2 -> h5) // right attachment if (h2 >= 0) enumerate(cells(h1 + 1, h2 + 1, h4 + 1), left, right, h2, h5, scores(h2, h5)); } } } const dep_set_type& deps = actives(0, last_max)(-1 + 1, -1 + 1, 0 + 1).deps; dep_set_type::const_iterator diter_end = deps.end(); for (dep_set_type::const_iterator diter = deps.begin(); diter != diter_end; ++ diter) dependency[diter->second - 1] = diter->first; }