Example #1
0
void Code::generateCall(SymbolTableEntry* entry, EntryList& eList)
{
  EntryList::iterator it;
  for(it = eList.begin(); it != eList.end(); it++)
    generate(cd_APARAM,NULL,NULL,*it);
  generate(cd_CALL,entry,NULL,NULL);
}
Example #2
0
    void print() {
      std::map<int, double> totals;
      std::cerr << "Timings: " << std::endl;
      // print out all the entries.

      //std::sort(root_entries.begin(), root_entries.end(), cmp());

      printEntries(std::cerr, root_entries, "   ", -1.0);

      for (EntryList::const_iterator it = entries.begin(); it != entries.end(); ++it) {
        totals[(*it).id] += (*it).time;
      }

      std::cerr << std::endl;
      std::cerr << "Totals: " << std::endl;

      std::vector<std::pair<int, double> > sorted_totals;
      sorted_totals.reserve(totals.size());
      for (std::map<int,double>::iterator it = totals.begin(); it != totals.end(); ++it) {
        sorted_totals.push_back(*it);
      }

      std::sort(sorted_totals.begin(), sorted_totals.end(), cmp());

      for (std::vector<std::pair<int,double> >::iterator it = sorted_totals.begin(); it != sorted_totals.end(); ++it) {
        std::cerr << "  ";
        std::string str = names[it->first];
        if (str.empty()) {
          std::cerr << "(" << it->first << ")";
        } else {
          std::cerr << str;
        }
        std::cerr << " - " << it->second << "s " << std::endl;
      }
    }
Example #3
0
	/**
	 * Stats the given file. If <tt>throttleRate</tt> seconds have passed since
	 * the last time stat() was called on this file, then the file will be
	 * re-stat()ted, otherwise the cached stat information will be returned.
	 *
	 * @param filename The file to stat.
	 * @param stat A pointer to a stat struct; the retrieved stat information
	 *             will be stored here.
	 * @param throttleRate Tells this CachedFileStat that the file may only
	 *        be statted at most every <tt>throttleRate</tt> seconds.
	 * @return 0 if the stat() call succeeded or if the cached stat information was used;
	 *         -1 if something went wrong while statting the file. In the latter
	 *         case, <tt>errno</tt> will be populated with an appropriate error code.
	 * @throws SystemException Something went wrong while retrieving the
	 *         system time. stat() errors will <em>not</em> result in
	 *         SystemException being thrown.
	 * @throws boost::thread_interrupted
	 */
	int stat(const string &filename, struct stat *buf, unsigned int throttleRate = 0) {
		boost::unique_lock<boost::mutex> l(lock);
		EntryMap::iterator it(cache.find(filename));
		EntryPtr entry;
		int ret;
		
		if (it == cache.end()) {
			// Filename not in cache.
			// If cache is full, remove the least recently used
			// cache entry.
			if (maxSize != 0 && cache.size() == maxSize) {
				EntryList::iterator listEnd(entries.end());
				listEnd--;
				string filename((*listEnd)->filename);
				entries.pop_back();
				cache.erase(filename);
			}
			
			// Add to cache as most recently used.
			entry = EntryPtr(new Entry(filename));
			entries.push_front(entry);
			cache[filename] = entries.begin();
		} else {
			// Cache hit.
			entry = *it->second;
			
			// Mark this cache item as most recently used.
			entries.erase(it->second);
			entries.push_front(entry);
			cache[filename] = entries.begin();
		}
		ret = entry->refresh(throttleRate);
		*buf = entry->info;
		return ret;
	}
Example #4
0
SnapshotEntrySeqMap BuddyCoreSnapshotI::getFriends(const ::MyUtil::IntSeq& ids,
		const Ice::Current& current) {
	SnapshotEntrySeqMap result;
	ServiceI& service = ServiceI::instance();
	for (IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
		EntryListHolderPtr owner = service.findObject<EntryListHolderPtr>(
				CATEGORY_ENTRY, *it);
		if (!owner) {
			continue;
		}
		EntryList ownerList = owner->getAll();
		SnapshotEntrySeq ownerSnap;
		for (EntryList::iterator ownerIt = ownerList.begin(); ownerIt
				!= ownerList.end(); ++ownerIt) {
			int ownerToId = ownerIt->to;
			uint32_t ownerDesc = ownerIt->desc;
			//MCE_INFO("Owner:"<<*it <<" Buddy:"<<ownerToId << " Desc:"<<ownerDesc);
			if (ownerDesc!=DESC_FRIEND) {
				continue;
			}
			SnapshotEntry entryOwner;
			entryOwner.toId = ownerToId;
			entryOwner.desc = BuddyDescHelper::translateDesc(ownerDesc);
			ownerSnap.push_back(entryOwner);
		}
		result[*it] = ownerSnap;
	}
	return result;
}
Example #5
0
void AssFile::Sort(EntryList &lst, CompFunc comp, std::set<AssDialogue*> const& limit) {
	AssEntryComp compE;
	compE.comp = comp;
	// Sort each block of AssDialogues separately, leaving everything else untouched
	for (entryIter begin = lst.begin(); begin != lst.end(); ++begin) {
		if (!is_dialogue(&*begin, limit)) continue;
		entryIter end = begin;
		while (end != lst.end() && is_dialogue(&*end, limit)) ++end;

		// used instead of std::list::sort for partial list sorting
		EntryList tmp;
		tmp.splice(tmp.begin(), lst, begin, end);
		tmp.sort(compE);
		lst.splice(end, tmp);

		begin = --end;
	}
}
Example #6
0
 bool insert( Entry& e , vec_type& v )
 {
   if ( entries.find( e.ID() ) != entries.end() ) { return false; }
   for ( typename vec_type::size_type ii=0; ii<v.size(); ++ii ) {
     table[ii].insert( EDE( e , v[ii]) );
   }
   entries.insert( e.ID() );
   return true;
 }
 void MamdaOrderBookPriceLevel::MamdaOrderBookPriceLevelImpl::clearEntries (
     EntryList& entries)
 {
     EntryList::iterator itr   = entries.begin();
     EntryList::iterator end   = entries.end();
     for (; itr != end; itr++)
     {
         delete *itr;
     }
     entries.clear();
 }
Example #8
0
void AssFile::Sort(EntryList<AssDialogue> &lst, CompFunc comp, std::set<AssDialogue*> const& limit) {
	if (limit.empty()) {
		lst.sort(comp);
		return;
	}

	// Sort each selected block separately, leaving everything else untouched
	for (auto begin = lst.begin(); begin != lst.end(); ++begin) {
		if (!limit.count(&*begin)) continue;
		auto end = begin;
		while (end != lst.end() && limit.count(&*end)) ++end;

		// sort doesn't support only sorting a sublist, so move them to a temp list
		EntryList<AssDialogue> tmp;
		tmp.splice(tmp.begin(), lst, begin, end);
		tmp.sort(comp);
		lst.splice(end, tmp);

		begin = --end;
	}
}
Example #9
0
void ConfigSection::remove_entry(const char* key) {
	E_ASSERT(key != NULL);

	int klen = strlen(key);
	unsigned int hh = do_hash(key, klen);
	EntryListIter it = entry_list.begin();

	for(; it != entry_list.end(); ++it) {
		ConfigEntry* e = *it;
		if(hh == e->hash && strncmp(e->key, key, e->keylen) == 0)
			entry_list.erase(it);
	}
}
Example #10
0
Profile::EntryList Profile::list(List type)
{
    EntryList parentList;
    if (m_parent)
        parentList = m_parent->list(type);
    EntryList list = parentList;
    for (EntryList::iterator it = list.begin(); it != list.end(); ++it)
        (*it).derived = true;
    QStringList &personalList = listByType(type);
    for (QStringList::const_iterator it = personalList.begin(); it != personalList.end(); ++it)
        list.append(Entry(*it, false));
    return list;
}
DB_Error DataBaseSqlite::AddUser(shared_ptr<User> user)
{
    DB_Error ret = CreateTable("User");
    if (ret == DB_OK)
    {
        EntryList entries = m_pTableComponent->GetTableFormat("User");
        PDEBUG ("entry size: %lu\n", entries.size());
        if (!entries.empty())
        {
            string sql(INSERT_TABLE);
            sql += string("User") + VALUE + LPARENT;
            EntryList::iterator iter = entries.begin();
            EntryList::iterator end  = entries.end();
            for (; iter != end;)
            {
                sql += "@" + iter->name;
                if (++iter != end)
                {
                    sql += ", ";
                }
            }
            sql += string(RPARENT) + SEMI;

            SqliteCommand cmd(this, sql);

            // Ugly hard code!!
            PDEBUG ("Begin binding\n");
            ret = cmd.Bind("@name", user->name());
            ret = ret ? ret : cmd.Bind("@uuid", user->uuid());
            int64 date = 0;
            if (user->has_reg_date())
            {
                ret = user->reg_date();
            }
            ret = ret ? ret : cmd.Bind("@reg_date", date);

            date = 0;

            if (user->has_last_login())
            {
                date = user->last_login();
            }
            ret = ret ? ret : cmd.Bind("@last_login", date);
            // Bind others ...
            ret = ret ? ret : cmd.Execute();
            // Execute ....
        }
    }
    return ret;
}
Example #12
0
ConfigEntry* ConfigSection::find_entry(const char* key) {
	E_ASSERT(key != NULL);

	int klen = strlen(key);
	unsigned int hh = do_hash(key, klen);
	EntryListIter it = entry_list.begin(), it_end = entry_list.end();

	for (; it != it_end; ++it) {
		ConfigEntry* e = *it;
		if (hh == e->hash && strncmp(e->key, key, e->keylen) == 0)
			return e;
	}
	return NULL;
}
Example #13
0
  void print( std::ostream& o = std::cout ) const
  {
    o << "ED LOOKUP TABLE\n";
    for ( typename EDTable::size_type ii=0; ii<table.size(); ++ii ) {
      o << "\tDIMENSION: " << ii << '\n';
      for ( typename DimensionEntries::const_iterator jj=table[ii].begin() ;
	    jj!=table[ii].end(); ++jj ) {
	(jj)->print(o);
      }
    }
    o << "\tCURRENT ENTRIES:\n";
    for ( typename EntryList::const_iterator ii=entries.begin(); 
	  ii!=entries.end(); ++ii ) { o << *ii << '\n'; }
  }
Example #14
0
void BuddyRelationLogic::addBuddyRelationData(Ice::Int id, 
		const BuddyRelationDataPtr& data) {
    EntryList list;
    ostringstream info;
    for (RelationEntryList::iterator en = data->list.begin(); en != data->list.end(); ++en) {
        Entry entry(en->id, BuddyDescHelper::translateInt(en->desc));
        list.push_back(entry);
        info << "<" << en->id << "/" << BuddyDescHelper::translateInt(en->desc) << "> ";
    }
    MCE_DEBUG("BuddyRelationLogic::addBuddyRelationData, id "<< id << " relations " << info.str());
    sort(list.begin(), list.end(), less_entry());
    EntryListHolderPtr holder = new EntryListHolder(id, list);

    writeObject(id, holder);
}
Example #15
0
void FillTask::handle() {
	ObjectResultPtr result = new ObjectResult();
	for ( std::map<long, Ice::ObjectPtr>::const_iterator it = _buddyData->data.begin();
			it!= _buddyData->data.end(); ++it ){
		BuddyRelationDataPtr data = BuddyRelationDataPtr::dynamicCast(it->second);
		EntryList list;
		list.reserve(data->list.size());
		for(RelationEntryList::iterator en = data->list.begin(); en != data->list.end(); ++en) {
			Entry entry(en->id, BuddyDescHelper::translateInt(en->desc));
			list.push_back(entry);
		}
		sort(list.begin(), list.end(), less_entry());
		EntryListHolderPtr holder = new EntryListHolder(it->first, list);
		result->data[it->first] = holder;
	}
	
	_logic->writeObjects(result);
}
Example #16
0
/*******************private interface***********************/
void BuddyRelationLogic::createRelation(const Relationship& relation,
		BuddyDesc desc) {
    BuddyRelationDataPtr data = BuddyRelationFactory::instance().create(relation.from);
    EntryList list;
    for(RelationEntryList::iterator en = data->list.begin(); en != data->list.end(); ++en) {
        Entry entry(en->id, BuddyDescHelper::translateInt(en->desc));
        list.push_back(entry);
    }
    sort(list.begin(), list.end(), less_entry());
    EntryListHolderPtr holder = new EntryListHolder(relation.from, list);

    Entry key;
    key.to = relation.to;
    key.desc = BuddyDescHelper::translateInt(desc);

    holder->add(key);

    writeObject(relation.from, holder);
}
DB_Error DataBaseSqlite::CreateTable(const string& name)
{
    DB_Error ret = DB_INVAL;


    EntryList entries = m_pTableComponent->GetTableFormat(name);
    PDEBUG ("entry size: %lu\n", entries.size());
    if (!entries.empty())
    {
        string sql(CREATE_TABLE);
        sql += IFNEXT + name + LPARENT;
        EntryList::iterator iter = entries.begin();
        EntryList::iterator end  = entries.end();
        for (; iter != end;)
        {
            sql += iter->name + " " +
                   g_SqlteKeywordMapping[iter->type];

            if (iter->primary)
            {
                sql += PRIMARY_KEY;
            }

            if (++iter != end)
            {
                sql += ", ";
            }
        }
        sql += string(RPARENT) + SEMI;

        SqliteCommand cmd(this, sql);
        ret = cmd.Execute();
    }


    PDEBUG ("Create %s, ret: %d\n", name.c_str(), ret);
    return ret;
}
Example #18
0
void KNewFileMenuSingleton::parseFiles()
{
    //kDebug(1203);
    filesParsed = true;
    KNewFileMenuSingleton::EntryList::iterator templ = templatesList->begin();
    const KNewFileMenuSingleton::EntryList::iterator templ_end = templatesList->end();
    for (; templ != templ_end; ++templ)
    {
        QString iconname;
        QString filePath = (*templ).filePath;
        if (!filePath.isEmpty())
        {
            QString text;
            QString templatePath;
            // If a desktop file, then read the name from it.
            // Otherwise (or if no name in it?) use file name
            if (KDesktopFile::isDesktopFile(filePath)) {
                KDesktopFile desktopFile( filePath);
                text = desktopFile.readName();
                (*templ).icon = desktopFile.readIcon();
                (*templ).comment = desktopFile.readComment();
                QString type = desktopFile.readType();
                if (type == "Link")
                {
                    templatePath = desktopFile.desktopGroup().readPathEntry("URL", QString());
                    if (templatePath[0] != '/' && !templatePath.startsWith("__"))
                    {
                        if (templatePath.startsWith("file:/"))
                            templatePath = KUrl(templatePath).toLocalFile();
                        else
                        {
                            // A relative path, then (that's the default in the files we ship)
                            QString linkDir = filePath.left(filePath.lastIndexOf('/') + 1 /*keep / */);
                            //kDebug(1203) << "linkDir=" << linkDir;
                            templatePath = linkDir + templatePath;
                        }
                    }
                }
                if (templatePath.isEmpty())
                {
                    // No URL key, this is an old-style template
                    (*templ).entryType = KNewFileMenuSingleton::Template;
                    (*templ).templatePath = (*templ).filePath; // we'll copy the file
                } else {
                    (*templ).entryType = KNewFileMenuSingleton::LinkToTemplate;
                    (*templ).templatePath = templatePath;
                }

            }
            if (text.isEmpty())
            {
                text = KUrl(filePath).fileName();
                if (text.endsWith(".desktop"))
                    text.truncate(text.length() - 8);
            }
            (*templ).text = text;
            /*kDebug(1203) << "Updating entry with text=" << text
                          << "entryType=" << (*templ).entryType
                          << "templatePath=" << (*templ).templatePath;*/
        }
        else {
            (*templ).entryType = KNewFileMenuSingleton::Separator;
        }
    }
}
Example #19
0
void Code::generateFormals(EntryList& entrylist)
{
  EntryList::iterator it;
  for(it = entrylist.begin(); it != entrylist.end(); it++)
    generate(cd_FPARAM,NULL,NULL,*it);
}
Example #20
0
void Code::generateVariables(EntryList& entrylist)
{
  EntryList::iterator it;
  for(it = entrylist.begin(); it != entrylist.end(); it++)
    generate(cd_VAR,NULL,NULL,*it);
}
Example #21
0
///////////////////////////////////////////////////////////////////////////////
// ReadRecursive
//
size_t DirectoryIterator::ReadRecursive(const char16_t* pBaseDirectory, EntryList& entryList, 
                                      const char16_t* pFilterPattern, int nEntryTypeFlags, 
                                      bool bIncludeBaseDirectoryInSearch, bool bFullPaths, 
                                      size_t maxResultCount)
{
    EA::IO::Path::PathString16  pathTemp;
    //char16_t pathTemp[kMaxPathLength];

    if(mnRecursionIndex++ == 0) // If being called for the first time...
    {
        #if EASTL_NAME_ENABLED // If the EntryList doesn't have a unique name, we give it one here.
            if(entryList.get_allocator().get_name() && !strcmp(EASTL_LIST_DEFAULT_NAME, entryList.get_allocator().get_name()))
                entryList.get_allocator().set_name(ENTRYLIST_NAME);
        #endif

        mnListSize           = 0;
        mpBaseDirectory      = pBaseDirectory;
        mBaseDirectoryLength = (eastl_size_t)EAIOStrlen16(pBaseDirectory);
        if(!mBaseDirectoryLength || !IsFilePathSeparator(pBaseDirectory[mBaseDirectoryLength - 1]))
            mBaseDirectoryLength++;
    }

    if((nEntryTypeFlags & kDirectoryEntryFile) && 
       (bIncludeBaseDirectoryInSearch || (mnRecursionIndex > 1)) && 
       (mnListSize < maxResultCount))
    {
        // Add all files in the current directory into the list, using the filter pattern.
        const size_t additionCount = Read(pBaseDirectory, entryList, pFilterPattern, kDirectoryEntryFile, maxResultCount - mnListSize);

        EntryList::iterator it(entryList.end());
        eastl::advance(it, -(int32_t)(uint32_t)additionCount);

        for(; it != entryList.end(); ++it)
        {
            Entry& entry = *it;

            mnListSize++;

            const eastl_size_t savedLength = entry.msName.length();
            entry.msName.insert(0, pBaseDirectory);
            const eastl_size_t directoryEnd = entry.msName.length() - savedLength;

            if(directoryEnd && !IsFilePathSeparator(entry.msName[directoryEnd - 1]))
                entry.msName.insert(directoryEnd, 1, kFilePathSeparator16);

            if(!bFullPaths)
                entry.msName.erase(0, mBaseDirectoryLength);
        }
    }

    if(mnListSize < maxResultCount)
    {
        // To do: Find a way to avoid this temporary list.
        // Since the list is only a list of directories under the 
        // current directory, it shouldn't need all that many entries.
        EntryList entryListTemp(entryList.get_allocator());

        // Add all directories in the current directory into the list, ignoring the filter pattern.
        Read(pBaseDirectory, entryListTemp, NULL, kDirectoryEntryDirectory, kMaxEntryCountDefault);

        for(EntryList::iterator it = entryListTemp.begin(); (it != entryListTemp.end()) && (mnListSize < maxResultCount); ++it)
        {
            const Entry& entry = *it; 

            pathTemp.assign( pBaseDirectory );
            EA::IO::Path::Append( pathTemp, entry.msName.c_str() );  // This previously was Join but Join was calling Normalize, which was modifying the pBaseDirectory part of the path string, and we don't want that messed with. Actually we don't need any normalization.

            //ConcatenatePathComponents(pathTemp, pBaseDirectory, entry.msName.c_str());

            // Possibly add this directory to the entry list.
            if(nEntryTypeFlags & kDirectoryEntryDirectory)
            {
                if(!pFilterPattern || FnMatch(pFilterPattern, entry.msName.c_str(), kFNMCaseFold))
                {
                    mnListSize++;
                    entryList.push_back();
                    Entry& listEntry = entryList.back();
                    listEntry.mType  = kDirectoryEntryDirectory;
                    listEntry.msName = pathTemp.c_str();

                    if(!bFullPaths)
                        listEntry.msName.erase(0, mBaseDirectoryLength);
                }
            }

            // Now recursively read the subdirectory.
            ReadRecursive(pathTemp.c_str(), entryList, pFilterPattern, nEntryTypeFlags, true, bFullPaths, maxResultCount);
        }
    }

    mnRecursionIndex--;

    return mnListSize;
}
Example #22
0
SnapshotEntrySeqMap BuddyCoreSnapshotI::getEntry4CommonFriend(
		::Ice::Int userId, const Ice::Current& current) {
	SnapshotEntrySeqMap result;
	ServiceI& service = ServiceI::instance();
	EntryListHolderPtr owner = service.findObject<EntryListHolderPtr>(
			CATEGORY_ENTRY, userId);
	if (!owner) {
		return result;
	}
	EntryList ownerList = owner->getAll();
	SnapshotEntrySeq ownerSnap;
	for (EntryList::iterator ownerIt = ownerList.begin(); ownerIt
			!= ownerList.end(); ++ownerIt) {
		int ownerToId = ownerIt->to;
		uint32_t ownerDesc = ownerIt->desc;
		SnapshotEntry entryOwner;
		entryOwner.toId = ownerToId;
		entryOwner.desc = BuddyDescHelper::translateDesc(ownerDesc);
		ownerSnap.push_back(entryOwner);

		EntryListHolderPtr ownerBuddy = service.findObject<EntryListHolderPtr>(
				CATEGORY_ENTRY, ownerToId);
		if (!ownerBuddy) {
			continue;
		}

		if (ownerDesc == DESC_FRIEND) {
			EntryList buddyList = ownerBuddy->getAll();
			SnapshotEntrySeq buddySnap;
			for (EntryList::iterator buddyIt = buddyList.begin(); buddyIt
					!= buddyList.end(); ++buddyIt) {
				int buddyToId = buddyIt->to;
				uint32_t buddyDesc = buddyIt->desc;
				if (buddyDesc==DESC_FRIEND || buddyDesc == DESC_APPLY) {
					SnapshotEntry entryFF;
					entryFF.toId = buddyToId;
					entryFF.desc = BuddyDescHelper::translateDesc(buddyDesc);
					buddySnap.push_back(entryFF);
				}
			}
			result[ownerToId] = buddySnap;
		}

		if (ownerDesc == DESC_APPLY) {
			EntryList buddyList = ownerBuddy->getAll();
			SnapshotEntrySeq buddySnap;
			for (EntryList::iterator buddyIt = buddyList.begin(); buddyIt
					!= buddyList.end(); ++buddyIt) {
				int buddyToId = buddyIt->to;
				uint32_t buddyDesc = buddyIt->desc;
				if (buddyDesc==DESC_FRIEND) {
					SnapshotEntry entryAF;
					entryAF.toId = buddyToId;
					entryAF.desc = BuddyDescHelper::translateDesc(buddyDesc);
					buddySnap.push_back(entryAF);
				}
			}
			result[ownerToId] = buddySnap;
		}
	}
	result[userId] = ownerSnap;
	return result;
}