Boolean IMDB::GetRecord(const String &strRecordName, Record &rec, Boolean bCreate, Boolean bAppend) { MapStrRec::iterator iter = m_mpRecords.find(strRecordName); if(iter == m_mpRecords.end()) { if(!bCreate) { return FALSE; } rec.SetOrigin(strRecordName, this); if(!bAppend) { rec.Map().clear(); } return TRUE; } rec.SetOrigin(strRecordName, this); if(!bAppend) { rec.Map().clear(); } MapStringToField::iterator it = iter->second.begin(); while(it != iter->second.end()) { rec.Map().insert(*it); ++it; } return TRUE; }
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; }