Example #1
0
 virtual void append_result(CaliperMetadataDB& db, EntryList& list) {
     if (m_count > 0) {
         list.push_back(Entry(m_config->get_avg_attribute(db),
                              m_sum.to_double() / m_count));
         list.push_back(Entry(m_config->get_min_attribute(db), m_min));
         list.push_back(Entry(m_config->get_max_attribute(db), m_max));
     }
 }
Example #2
0
// compare this to Table::list_entries(), which uses the underlying map.
// Class keeps an explicit list of entries so it can deliver entries
// in _order of declaration_.  No doubt there is more than one way to
// do this
void Class::list_entries(EntryList &el, int flags)
{
    if ((flags & DO_PARENT) && base_class() != NULL) base_class()->list_entries(el,flags);
    EntryList::iterator eli;
    for(eli = m_entries.begin(); eli != m_entries.end(); ++eli)
        if (check_entry(*eli,flags)) el.push_back(*eli);
}
Example #3
0
/*
 * Add new key/value, but first check
 * do we alread have and key, so if
 * we do, just update value
 */
void ConfigSection::add_entry(const char* key, const char* value) {
	E_ASSERT(key != NULL);
	E_ASSERT(value != NULL);

	ConfigEntry* e = find_entry(key);
	if (!e) {
		e = new ConfigEntry;
		e->keylen = strlen(key);
		e->valuelen = strlen(value);
		e->key = strdup(key);
		e->value = strdup(value);
		// hash the key
		e->hash = do_hash(e->key, e->keylen);

		E_ASSERT(e->key != NULL);
		E_ASSERT(e->value != NULL);
#ifdef CONFIG_INTERNAL
		printf("Adding: |%s| = |%s| hash = %i section = %s\n", e->key, e->value, e->hash, sname);
#endif
		entry_list.push_back(e);
	} else {
#ifdef CONFIG_INTERNAL
		printf("!!! found duplicate for %s\n", e->key);
#endif
		free(e->value);
		e->valuelen = strlen(value);
		e->value = strdup(value);
		E_ASSERT(e->value != NULL);
	}
}
Example #4
0
 virtual void append_result(CaliperMetadataDB& db, EntryList& list) {
     uint64_t count = m_count.load();
     
     if (count > 0)
         list.push_back(Entry(m_config->attribute(db),
                              Variant(CALI_TYPE_UINT, &count, sizeof(uint64_t))));
 }
Example #5
0
/*
 * Add new key/value, but first check
 * do we alread have and key, so if
 * we do, just update value
 */
void ConfigSection::add_entry(const char* key, const char* value) {
	E_ASSERT(key != NULL);
	E_ASSERT(value != NULL);

	ConfigEntry* e = find_entry(key);
	if (!e) {
		e = new ConfigEntry;
		e->keylen   = strlen(key);
		e->valuelen = strlen(value);
		e->key      = strdup(key);
		e->value    = strdup(value);
		e->hash     = do_hash(e->key, e->keylen);

		E_ASSERT(e->key != NULL);
		E_ASSERT(e->value != NULL);

		entry_list.push_back(e);
	} else {
		free(e->value);
		e->valuelen = strlen(value);
		e->value    = strdup(value);

		E_ASSERT(e->value != NULL);
	}
}
Example #6
0
bool YumemiArchive_Base::DeserializeList(std::istream &is, uint32_t list_count, uint32_t filesize, EntryList &list)
{
  for(uint16_t i = 0; i < list_count; ++i) {
    Entry entry;
    uint16_t magic;
    char     padding[8];
    is.read((char *)&magic, 2);
    if(is.fail()) return false;
    is.read((char *)&entry.key, 1);
    if(is.fail()) return false;
    is.read(entry.name, 13);
    if(is.fail()) return false;
    is.read((char *)&entry.compsize, 2);
    if(is.fail()) return false;
    is.read((char *)&entry.origsize, 2);
    if(is.fail()) return false;
    is.read((char *)&entry.offset, 4);
    if(is.fail()) return false;
    is.read(padding, 8);
    if(is.fail()) return false;

    if(magic == 0) break;

    if(magic != 0x9595 && magic != 0xF388) return false;
    if(entry.offset >= filesize) return false;
    if((uint32_t)filesize - entry.offset < entry.compsize) return false;
    if(!ValidateName(entry.name)) return false;
    list.push_back(entry);
  }
  return true;
}
Example #7
0
void Parser::parseExpressionListPrime(EntryList& expList){
	if(isNext(tc_COMMA)){
		match(tc_COMMA);
		expList.push_back(parseExpression());
		parseExpressionListPrime(expList);
	}
}
Example #8
0
void Parser::parseExpressionList(SymbolTableEntry* prevEntry){
	EntryList expList = *(new EntryList());
	//expList.push_back(prevEntry);
	expList.push_back(parseExpression());
	parseExpressionListPrime(expList);
	m_code->generateCall(prevEntry, expList);
}
Example #9
0
bool BuddyCoreSnapshotI::loadIncreament() {
	multimap<int, SnapshotEntrySeqMap> incs;
	{
		IceUtil::Mutex::Lock lock(_increamentsMutex);
		if (_increaments.empty()) {
			MCE_DEBUG("Increaments is empty.");
			return false;
		}
		incs.swap(_increaments);
	}
	int usersize4log = 0;
	for (multimap<int, SnapshotEntrySeqMap>::iterator it = incs.begin(); it
			!= incs.end(); ++it) {
		SnapshotEntrySeqMap smaps = it -> second;
		usersize4log += smaps.size();
		for (SnapshotEntrySeqMap::iterator smapsIt = smaps.begin(); smapsIt
				!= smaps.end(); ++smapsIt) {
			int userId = smapsIt -> first;
			EntryList el;
			for (SnapshotEntrySeq::iterator sentryIt = smapsIt->second.begin(); sentryIt
					!= smapsIt->second.end(); ++sentryIt) {
				SnapshotEntry entry = *sentryIt;
				switch (entry.desc) {
				case Friend:
					el.push_back(Entry(entry.toId, DESC_FRIEND));
					break;
				case Apply:
					el.push_back(Entry(entry.toId, DESC_APPLY));
					break;
				case Block:
					el.push_back(Entry(entry.toId, DESC_BLOCK));
					break;
				default:
					continue;
					break;
				}
			}
			ServiceI::instance().addObject(new EntryListHolder(userId, el), CATEGORY_ENTRY, userId);
			MCE_DEBUG("loadIncreament for id="<<userId<<" done");
		}
	}
	MCE_INFO("loadIncreament for "<<usersize4log<<" users in "<<incs.size()
			<<" batches. done.");
	return true;
}
Example #10
0
    void unpack_key(const unsigned char* key, const CaliperMetadataDB& db, EntryList& list) {
        // key format: 2*N + node flag, node id, N * (attr id, Variant)

        size_t   p = 0;
        uint64_t n = vldec_u64(key + p, &p);

        if (n % 2 == 1)
            list.push_back(Entry(db.node(vldec_u64(key + p, &p))));

        for (unsigned i = 0; i < n/2; ++i) {
            bool      ok   = true;
            
            cali_id_t id   = static_cast<cali_id_t>(vldec_u64(key+p, &p));
            Variant   data = Variant::unpack(key+p, &p, &ok);

            if (ok)
                list.push_back(Entry(db.attribute(id), data));
        }
    }
Example #11
0
NameIterationTester::EntryList
NameIterationTester::getNamesFromIterator (CNameIterator& iter)
{
  EntryList res;

  valtype name;
  CNameData data;
  while (iter.next (name, data))
    res.push_back (std::make_pair (name, data));

  return res;
}
Example #12
0
void Parser::parseIdentifierList(EntryList& idList){
	if(isNext(tc_ID)){
		idList.push_back(m_currentToken->getSymTabEntry());
	}
	match(tc_ID);
	if(m_parserError){
		TokenCode synch[] = {tc_COMMA, tc_COLON, tc_NONE};
		recover(synch);
//		if(isNext(tc_ID)){
//			match(tc_ID);
//		}
	}
	parseIdentifierListPrime(idList);
}
Example #13
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 #14
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 #15
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);
}
Example #16
0
ConfigReader::EntryList ConfigReader::readAll() const
{
    EntryList currentConfig ;  
    using namespace boost::filesystem ;
    path currentPath ( m_currentPath);
    if ( exists(currentPath))
    {
        if ( is_directory(currentPath))
        {
            typedef std::vector<path> FilepathList ;
            FilepathList f ;
            copy(directory_iterator(currentPath), directory_iterator(), std::back_inserter(f));
            std::sort(f.begin(),f.end());

            for (FilepathList::const_iterator it (f.begin()); it != f.end(); ++it)
            {
                ConfigurationEntry ce = loadFromPath(it->leaf().string());
                currentConfig.push_back(ce);
            }

        }
    }
    return currentConfig ;
}
Example #17
0
 virtual void append_result(CaliperMetadataDB& db, EntryList& list) {
     if (m_count > 0)
         list.push_back(Entry(m_config->get_aggr_attr(db), m_sum));
 }
Example #18
0
///////////////////////////////////////////////////////////////////////////////
// Read
//
size_t DirectoryIterator::Read(const char16_t* pDirectory, EntryList& entryList, 
                             const char16_t* pFilterPattern, int nDirectoryEntryFlags, 
                             size_t maxResultCount)
{
    EntryFindData entryFindData, *pEntryFindData;
    size_t        resultCount = 0;

    #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

    // Iterate entries.
    for(pEntryFindData = EntryFindFirst(pDirectory, pFilterPattern, &entryFindData); pEntryFindData && (resultCount < maxResultCount); )
    {
        if(!StrEq16(pEntryFindData->mName, EA_DIRECTORY_CURRENT_16) && // If it is neither "./" nor "../"
           !StrEq16(pEntryFindData->mName, EA_DIRECTORY_PARENT_16))
        {
            if(pEntryFindData->mbIsDirectory)
            {
                if(nDirectoryEntryFlags & kDirectoryEntryDirectory)
                {
                    resultCount++;
                    entryList.push_back();
                    entryList.back().mType  = kDirectoryEntryDirectory;
                    entryList.back().msName = pEntryFindData->mName;
                }
            }
            else
            {
                if(nDirectoryEntryFlags & kDirectoryEntryFile)
                {
                    resultCount++;
                    entryList.push_back();
                    entryList.back().mType  = kDirectoryEntryFile;
                    entryList.back().msName = pEntryFindData->mName;
                }
            }
        }

        if(!EntryFindNext(pEntryFindData))
        {
            EntryFindFinish(pEntryFindData);
            break;
        }
    }

    if(pEntryFindData)
    {
        if((nDirectoryEntryFlags & kDirectoryEntryCurrent) && (resultCount < maxResultCount))
        {
            resultCount++;
            entryList.push_front();
            entryList.front().mType  = kDirectoryEntryDirectory;
            entryList.front().msName = EA_DIRECTORY_CURRENT_16;
        }

        if((nDirectoryEntryFlags & kDirectoryEntryParent) && (resultCount < maxResultCount))
        {
            // To do: We don't want to do this if the directory is a root directory.
            resultCount++;
            entryList.push_front();
            entryList.front().mType  = kDirectoryEntryDirectory;
            entryList.front().msName = EA_DIRECTORY_PARENT_16;
        }
    }

    return resultCount;
}
Example #19
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;
}