Пример #1
0
Boolean IMDB::SetRecord(const String &strRecordName,
                        const Record &recSrc,
                        Boolean bCreate,
                        Boolean bAll)
{
  MapStrRec::iterator iter = m_mpRecords.find(strRecordName);
  if(iter == m_mpRecords.end())
    {
      if(!bCreate) 
      {
      	return FALSE;
      }
      m_mpRecords[strRecordName] = recSrc.Map();			// !!! not right
    }
  else
    {
      MapStringToField &mpDest = iter->second;

      if(bAll)
        {
          Record::const_iterator it = recSrc.begin();
          while(it != recSrc.end()) { mpDest.insert(*it); it++; }
        }
      else
        {
          SetOfStrings::const_iterator itDirty;
          itDirty = recSrc.GetFirstDirty();
          while(itDirty != recSrc.GetLastDirty())
            {
              String str = *itDirty;
              Record::const_iterator itSrcField = recSrc.find(*itDirty);
              if(itSrcField != recSrc.end())
              {
                  mpDest.insert(*itSrcField);
              }
              else
                {
                  MapStringToField::iterator it =
                    mpDest.find(*itDirty);
                  mpDest.erase(it);
                }
              ++itDirty;
            }
        }
    }

  return TRUE;
}
Пример #2
0
void Table::addEntry(Record& new_record)
{
	vector<field>::iterator iter_record = new_record.begin();

	string *fields = new string("(");
	string *values= new string("(");

	bool start = true;;

	while( iter_record != new_record.end() ){
		if (!start){
			fields->append(",");
			values->append(",");
		}
		fields->append(iter_record->label);
		iter_record->getString(values);

		std::cout << "label: " << iter_record->label << ",data; " ; iter_record->print();
		iter_record++;
		start = false;
	}

	fields->append(")");
	values->append(")");

	stringstream queryStream;
	queryStream << "INSERT INTO " << this->_name << " " << *fields << " VALUES " << *values << ";";

	delete fields;
	delete values;

	this->execute( this->conn, queryStream.str());
}
void DumpD3DResourceReleaseResults()
{
	Record::const_iterator ri = record.begin();

	//INFO_MSG( "Dumping D3D resource release results...\n\n" );
	//INFO_MSG( "Resource, Total time, Total calls\n" );

	while ( ri != record.end() )
	{
		double seconds = double(ri->second.first)/double( stampsPerSecond() );

		//INFO_MSG("%s, %f, %d\n",
		//	ri->first.c_str(), seconds, ri->second.second );
		ri++;
	}
}
// Use stack tracker to work out what the caller was for ComObject release,
// and tabulate each type of release.
void ProfileD3DResourceRelease( uint64 t )
{
	if ( !g_doProfileD3DResourceRelease )
		return;

	std::string callerName = StackTracker::getStackItem( 0 );
	Record::iterator ri = record.find( callerName );

	if ( ri != record.end() )
	{
		ri->second.first += t;
		ri->second.second += 1;
	}
	else
	{
		record[ callerName ] = std::make_pair(t,1);
	}
}