void CsvFile::write(const HeaderList& header, const DataMap& data) throw (FileException) { std::ofstream file(filename.c_str()); if (!file) throw FileException("Cannot open file", filename, __FUNCTION_NAME__); // Print raw of headers for (HeaderList::const_iterator it = header.begin(); it != header.end(); ++it) { file << separator << *it; } // End of line file << std::endl; // Print all data raws for (DataMap::const_iterator rawit = data.begin() ; rawit != data.end(); ++rawit) { file<< rawit->first; for (DataRaw::const_iterator it = rawit->second.begin(); it != rawit->second.end(); ++it) { if (*it > 0) file << separator << *it; else file << separator; } // End of line file << std::endl; } };
int main() { DataMap sightings; generate_n( inserter(sightings, sightings.begin()), 50, SightingGen(animals)); // Print everything: copy(sightings.begin(), sightings.end(), ostream_iterator<Sighting>(cout, "\n")); // Print sightings for selected animal: while (true) { cout << "select an animal or 'q' to quit: "; for (int i = 0; i < animals.size(); i++) cout << '[' << i << ']' << animals[i] << ' '; cout << endl; string reply; cin >> reply; if (reply.at(0) == 'q') return 0; istringstream r(reply); int i; r >> i; // Convert to int i %= animals.size(); // Iterators in "range" denote begin, one // past end of matching range: pair<DMIter, DMIter> range = sightings.equal_range(animals[i]); copy(range.first, range.second, ostream_iterator<Sighting>(cout, "\n")); } } ///:~
bool CacheManagerI::loadListCache(const std::string& key, const std::string& namespace_id, const std::string& business_id, bool use_master, const Ice::Current& current) { std::ostringstream otem; otem << "CacheManageI::loadListCache() key:" << key << "\tnamespace_id:" << namespace_id << "\tbusiness_id:" << business_id; MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, otem.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO); ProducerManagerClientPtr producer = getProducer(); if(producer == NULL) { return false; } KeySeq keys; keys.push_back(key); DataMap data = producer->produce(keys, business_id, use_master, 0); if (data.empty()) { return true; } std::string list_key; StrList list_value; DataMap::const_iterator iter = data.begin(); list_key = iter->second; for (; iter != data.end(); ++iter) { list_value.push_back(iter->first); } RedisCacheClientPtr redis_client = GetRedisCache(); redis_client->Set(list_key, list_value, namespace_id, business_id); return true; }
void TripodClient::getMissedKeys(const DataMap& res, const KeySeq& keys, KeySeq& missedKeys) { for(KeySeq::const_iterator it = keys.begin(); it != keys.end(); ++it) { if(res.find(*it) == res.end()) { missedKeys.push_back(*it); } } }
void writeout_file(char *time_peroid){ char sql[1024]; int retcode; sprintf(sql, "SELECT * FROM history"); retcode = sqlite3_exec(pDB, sql, &sqlite3_exec_callback, time_peroid, &errmsg); if(SQLITE_OK!=retcode){ printf("retcode of sqlite3_exec():%d description:%s", retcode, errmsg); sqlite3_free(errmsg); } char filename[1024]; sprintf(filename, "%s.csv", time_peroid); FILE *fp = fopen(filename, "wt"); if(NULL!=fp){ printf("\nWriting file:%s...", filename); for(DataMap::iterator it = dataMap.begin(); it != dataMap.end(); it++){ struct tm *st = localtime(&(it->second.timestamp)); fprintf(fp, "%04d.%02d.%02d,%02d:%02d,%lf,%lf,%lf,%lf,%lf\n", st->tm_year+1900, st->tm_mon+1, st->tm_mday, st->tm_hour, st->tm_min, it->second.open, it->second.high, it->second.low, it->second.close, it->second.amount); /* printf("timestamp:%s open:%lf high:%lf low:%lf close:%lf amount:%lf\n", ctime(&(it->second.timestamp)), it->second.open, it->second.high, it->second.low, it->second.close, it->second.amount); */ } printf("done", filename); fclose(fp); } dataMap.clear(); // clear all the data in map }
void writeVtkData(const std::array<int, 3>& dims, const std::array<double, 3>& cell_size, const DataMap& data, std::ostream& os) { // Dimension is hardcoded in the prototype and the next two lines, // but the rest is flexible (allows dimension == 2 or 3). int dimension = 3; int num_cells = dims[0]*dims[1]*dims[2]; assert(dimension == 2 || dimension == 3); assert(num_cells == dims[0]*dims[1]* (dimension == 2 ? 1 : dims[2])); os << "# vtk DataFile Version 2.0\n"; os << "Structured Grid\n \n"; os << "ASCII \n"; os << "DATASET STRUCTURED_POINTS\n"; os << "DIMENSIONS " << dims[0] + 1 << " " << dims[1] + 1 << " "; if (dimension == 3) { os << dims[2] + 1; } else { os << 1; } os << "\n"; os << "ORIGIN " << 0.0 << " " << 0.0 << " " << 0.0 << "\n"; os << "SPACING " << cell_size[0] << " " << cell_size[1]; if (dimension == 3) { os << " " << cell_size[2]; } else { os << " " << 0.0; } os << "\n"; os << "\nCELL_DATA " << num_cells << '\n'; for (DataMap::const_iterator dit = data.begin(); dit != data.end(); ++dit) { std::string name = dit->first; os << "SCALARS " << name << " float" << '\n'; os << "LOOKUP_TABLE " << name << "_table " << '\n'; const std::vector<double>& field = *(dit->second); // We always print only the first data item for every // cell, using 'stride'. // This is a hack to get water saturation nicely. // \TODO: Extend to properly printing vector data. const int stride = field.size()/num_cells; const int num_per_line = 5; for (int c = 0; c < num_cells; ++c) { os << field[stride*c] << ' '; if (c % num_per_line == num_per_line - 1 || c == num_cells - 1) { os << '\n'; } } } }
void MapEditor2D::SaveToBinFile (const char *fn) { SaveToTextFile((string(fn)+".tmp").c_str()); DataMap *Tmp = new DataMap(); Tmp->LoadFromFile((string(fn)+".tmp").c_str()); Tmp->SaveToBytecode(fn); delete Tmp; remove((string(fn)+".tmp").c_str()); }
char* _spUtil_readFile(const char* path, int* length) { const DataMap data{Path(path)}; *length = static_cast<int>(data.size()); char* blob = new char[data.size()]; memcpy(blob, data.data(), data.size()); return blob; }
void init() { if(inited) return; inited = true; #include "default_config.cpp" if(map.has("core.config")) map.load(map.get("core.config")); }
// -- FACTORY METHODS -- static Epetra_Map epetraMap( DataMap const& dmap ) { std::vector<int> e( dmap.nMyElements() ); std::copy( dmap.myGlobalElements().begin(), dmap.myGlobalElements().end(), e.begin() ); return Epetra_Map( -1, dmap.nMyElements(), e.data(), 0, Epetra_MpiComm( dmap.comm() ) ); }
void WorkspaceSerializer::Read(const QString& fileName, SignalData& data, PlotInfo& plotInfo) { DataMap newData; ::Read(fileName, data, plotInfo, [&](Signal&& signal){ auto signalName = signal.name; newData.emplace(std::move(signalName), std::move(signal)); }, [&]{ data.add(std::move(newData)); }); }
DataMap TripodClient::getWithMissed(const KeySeq& keys, long expiredTime, bool useMaster, const long timeout) { KeySeq missedKeys; DataMap res = get(keys, missedKeys, timeout); if(!missedKeys.empty()) { DataMap missedRes = getMissed(missedKeys, expiredTime, useMaster, timeout); res.insert(missedRes.begin(), missedRes.end()); } return res; }
map<string, MenuTripodDataPtr> MenuCacheManagerI::getWithKeys(const KeySeq& keys) { map<string, MenuTripodDataPtr> result; KeySeq missedKeys; DataMap dataMap = tripodClient_->get(keys, missedKeys); for (DataMap::const_iterator it = dataMap.begin(); it != dataMap.end(); ++it) { string byteArray(it->second.begin(), it->second.end()); MenuTripodDataPtr ptr = new MenuTripodData(byteArray); result.insert(make_pair<string, MenuTripodDataPtr>(it->first, ptr)); } return result; }
void WAbstractItemModel::copyData(const WAbstractItemModel *source, const WModelIndex& sIndex, WAbstractItemModel *destination, const WModelIndex& dIndex) { DataMap values = destination->itemData(dIndex); for (DataMap::const_iterator i = values.begin(); i != values.end(); ++i) destination->setData(dIndex, boost::any(), i->first); destination->setItemData(dIndex, source->itemData(sIndex)); }
TicketData TicketAdapter::queryTicket(const string& ticket) { TicketData data; if(TicketUtil::isSTicketLegal(ticket)) { KeySeq keys, missedKeys; keys.push_back(ticket); DataMap dataMap = _tripodClient->get(keys, missedKeys); DataMap::const_iterator it = dataMap.find(ticket); if(it != dataMap.end()) { string value(it->second.begin(), it->second.end()); istringstream in(value); data.ParseFromIstream(&in); } } return data; }
bool SQLiteMgr::sessionConfigurate(const DataMap &data) { QSqlQuery query; if( ! data.isEmpty() ) { QString query_string; for (auto i = 0; i < data.count(); i++) /// \warning TODO: БЫЛО <= ПРОВЕРИТЬ { query_string += "PRAGMA" + data.keys().at(i) + " = " + data.values().at(i) + " \n"; } return query.exec(query_string); } return false; }
void RemoveThreadData(image_key_t iid, thread_key_t tid){ uint32_t h = HashThread(tid); assert(threaddata.count(iid) == 1); assert(datamap.count(iid) == 1); assert(datamap[iid].count(tid) == 1); ThreadData* td = threaddata[iid]; uint32_t actual = h; while (td[actual].id != tid){ actual = (actual + 1) % (ThreadHashMod + 1); } td[actual].id = 0; td[actual].data = 0; }
/* *Function: *Inputs:noneSeekMaxMinTimeLine *Outputs:none *Returns:none */ void Graph::SeekMaxMinTimeLine(DataMap &l) // seek max and min in a line { IT_IT("Graph::SeekMaxMinTimeLine"); if(l.size() > 0) { if(minTime > (*l.begin()).first) { minTime = (*l.begin()).first; }; if(maxTime < (*l.rbegin()).first) { maxTime = (*l.rbegin()).first; }; }; };
/* *Function:SeekMaxMinYLine *Inputs:none *Outputs:none *Returns:none */ void Graph::SeekMaxMinYLine(DataMap &l) { IT_IT("Graph::SeekMaxMinYLine"); for(DataMap::iterator j = l.begin(); !(j == l.end());j++) { if(minY > (*j).second) { minY = (*j).second; } else if(maxY < (*j).second) { maxY = (*j).second; }; }; };
void FreezeScript::AssignVisitor::visitDictionary(const DictionaryDataPtr& dest) { Slice::TypePtr type = dest->getType(); DictionaryDataPtr d = DictionaryDataPtr::dynamicCast(_src); if(d && isCompatible(type, _src->getType())) { DataMap& srcMap = d->getElements(); DataMap destMap; Slice::DictionaryPtr dictType = Slice::DictionaryPtr::dynamicCast(type); assert(dictType); Slice::TypePtr keyType = dictType->keyType(); Slice::TypePtr valueType = dictType->valueType(); string typeName = typeToString(type); for(DataMap::const_iterator p = srcMap.begin(); p != srcMap.end(); ++p) { DataPtr key = _factory->create(keyType, false); Destroyer<DataPtr> keyDestroyer(key); DataPtr value = _factory->create(valueType, false); Destroyer<DataPtr> valueDestroyer(value); AssignVisitor keyVisitor(p->first, _factory, _errorReporter, _convert, typeName + " key"); key->visit(keyVisitor); AssignVisitor valueVisitor(p->second, _factory, _errorReporter, _convert, typeName + " value"); value->visit(valueVisitor); DataMap::const_iterator q = destMap.find(key); if(q != destMap.end()) { error("duplicate dictionary key in " + typeToString(dictType)); } else { destMap.insert(DataMap::value_type(key, value)); keyDestroyer.release(); valueDestroyer.release(); } } DataMap& m = dest->getElements(); m.swap(destMap); } else { typeMismatchError(type, _src->getType()); } }
bool CacheManagerI::loadListCache(const std::string& key, const std::string& namespace_id, const std::string& biz_id, bool use_master, const Ice::Current& current) { std::ostringstream os; os << "key :" << key; os << " namespaceId :" << namespace_id; os << " businessId :" << biz_id; os << " use_master :" << use_master; MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, os.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO); ProducerManagerClientPtr producer = getProducer(); if(!producer) { MCE_ERROR("CacheManagerI::loadListCache() getProducer() return NULL!!!"); return false; } KeySeq input_keys; input_keys.push_back(key); KeySeq locked_keys; KeySeq failed_locked_keys; bool result = false; while(true) { xce::tempmutext::Locks<std::string> locks(&tempMutexManager_, input_keys, locked_keys, failed_locked_keys); if(!locked_keys.empty()) { DataMap data; try { data = producer->produce(locked_keys, biz_id, use_master, 10000); } catch (Ice::Exception& e) { MCE_ERROR("CacheManagerI::loadListCache() rpc call produce() " << e.what()); } DataMap::const_iterator iter = data.begin(); for (; iter != data.end(); ++iter) { if (!iter->second.empty()) { ListOrHashValue list_value; list_value.ParseFromArray(iter->second.data(), iter->second.size()); if (list_value.values_size() > 0) { StrList str_list; BOOST_FOREACH(const std::string& v, list_value.values()) { str_list.push_back(v); } RedisCacheClientPtr cache = GetRedisCache(); if (!cache) { MCE_ERROR("CacheManagerI::loadListCache() GetRedisCache() return NULL !!!"); continue; } result = cache->SetList(key, str_list, namespace_id, biz_id); } } }
bool WAbstractItemModel::setItemData(const WModelIndex& index, const DataMap& values) { bool result = true; bool wasBlocked = dataChanged().isBlocked(); dataChanged().setBlocked(true); for (DataMap::const_iterator i = values.begin(); i != values.end(); ++i) // if (i->first != EditRole) if (!setData(index, i->second, i->first)) result = false; dataChanged().setBlocked(wasBlocked); dataChanged().emit(index, index); return result; }
void SceneManager::SetWeatherParameters(DataMap *parameters) { DataMap currParams; GetWeatherParameters(&currParams); bool indoor = parameters->GetBool("Indoor", currParams.GetBool("Indoor")); if (indoor) SetToIndoor(); else { SetToOutdoor(); mWeatherController->GetCaelumSystem()->getSun()->setAmbientMultiplier(parameters->GetOgreCol("AmbientLight", currParams.GetOgreCol("AmbientLight"))); mWeatherController->GetCaelumSystem()->getSun()->setDiffuseMultiplier(parameters->GetOgreCol("Sun_DiffuseLight", currParams.GetOgreCol("Sun_DiffuseLight"))); mWeatherController->GetCaelumSystem()->getSun()->setSpecularMultiplier(parameters->GetOgreCol("Sun_SpecularLight", currParams.GetOgreCol("Sun_SpecularLight"))); mWeatherController->Update(0); } Ogre::GpuSharedParametersPtr hdrParams = Ogre::GpuProgramManager::getSingleton().getSharedParameters("HDRParams"); Ogre::ColourValue col = parameters->GetOgreCol("Luminence_Factor", currParams.GetOgreCol("Luminence_Factor")); col.a = 0; hdrParams->setNamedConstant("Luminence_Factor", col); hdrParams->setNamedConstant("Tonemap_White", parameters->GetFloat("Tonemap_White")); col = parameters->GetOgreCol("Brightpass_Threshold", currParams.GetOgreCol("Brightpass_Threshold")); col.a = 0; hdrParams->setNamedConstant("Brightpass_Threshold", col); col = parameters->GetOgreCol("BrightpassAmbient_Threshold", currParams.GetOgreCol("BrightpassAmbient_Threshold")); col.a = 0; hdrParams->setNamedConstant("BrightpassAmbient_Threshold", col); hdrParams->setNamedConstant("BloomAmbient_GlareScale", parameters->GetValue<float>("BloomAmbient_GlareScale", 0.5f)); hdrParams->setNamedConstant("BloomAmbient_GlarePower", parameters->GetValue<float>("BloomAmbient_GlarePower", 0.5f)); hdrParams->setNamedConstant("Bloom_GlareScale", parameters->GetValue<float>("Bloom_GlareScale", parameters->GetFloat("Bloom_GlareScale"))); hdrParams->setNamedConstant("Bloom_GlarePower", parameters->GetValue<float>("Bloom_GlarePower", parameters->GetFloat("Bloom_GlarePower"))); hdrParams->setNamedConstant("Bloom_StarScale", parameters->GetValue<float>("Bloom_StarScale", parameters->GetFloat("Bloom_StarScale"))); hdrParams->setNamedConstant("Bloom_StarPower", parameters->GetValue<float>("Bloom_StarPower", parameters->GetFloat("Bloom_StarPower"))); hdrParams->setNamedConstant("LinearTonemap_KeyLumScale", parameters->GetFloat("LinearTonemap_KeyLumScale", parameters->GetFloat("LinearTonemap_KeyLumScale"))); hdrParams->setNamedConstant("LinearTonemap_KeyMax", parameters->GetFloat("LinearTonemap_KeyMax", parameters->GetFloat("LinearTonemap_KeyMax"))); hdrParams->setNamedConstant("LinearTonemap_KeyMaxOffset", parameters->GetFloat("LinearTonemap_KeyMaxOffset", parameters->GetFloat("LinearTonemap_KeyMaxOffset"))); hdrParams->setNamedConstant("LinearTonemap_KeyMin", parameters->GetFloat("LinearTonemap_KeyMin", parameters->GetFloat("LinearTonemap_KeyMin"))); hdrParams->setNamedConstant("LightAdaption_Exponent", parameters->GetValue<float>("LightAdaption_Exponent", parameters->GetFloat("LightAdaption_Exponent"))); hdrParams->setNamedConstant("LightAdaption_Factor", parameters->GetValue<float>("LightAdaption_Factor", parameters->GetFloat("LightAdaption_Factor"))); hdrParams->setNamedConstant("ShadowAdaption_Exponent", parameters->GetValue<float>("ShadowAdaption_Exponent", parameters->GetFloat("ShadowAdaption_Exponent"))); hdrParams->setNamedConstant("ShadowAdaption_Factor", parameters->GetValue<float>("ShadowAdaption_Factor", parameters->GetFloat("ShadowAdaption_Factor"))); }
void SignalListPresenter::OnNewData(const DataMap& dataMap) { OnClearData(); auto currentCount = signalList->rowCount(); signalList->setRowCount(currentCount + dataMap.size()); for (const auto& sign : dataMap) { const auto& name = sign.first; const auto& currentSignal = sign.second; // name item auto chanNameItem = new QTableWidgetItem(name); chanNameItem->setCheckState(currentSignal.graphic.visible ? Qt::Checked : Qt::Unchecked); // domain value item auto chanValueItem = new QTableWidgetItem(); chanValueItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); // color item auto colorButton = new QPushButton(signalList); colorButton->setEnabled(currentSignal.graphic.visible); colorButton->setStyleSheet(MakeBackgroundStylesheet(currentSignal.graphic.color)); colorButton->setAutoFillBackground(true); const auto& currColor = currentSignal.graphic.color; QObject::connect(colorButton, &QPushButton::clicked, [&currColor, name, colorButton, this]{ const auto color = QColorDialog::getColor(currColor, this->signalList, QString("Change color of %1").arg(name)); if (color.isValid()) { this->data.setColor(name, color); } }); auto removeButton = new QPushButton(signalList); removeButton->setText("X"); QObject::connect(removeButton, &QPushButton::clicked, [name, this]{ const auto reply = QMessageBox::question(nullptr, "Anvedi", QString("Sure to remove '%1'?").arg(name), QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { this->data.remove(name); } }); // adding them all signalList->setItem(currentCount, SignalNameIdx, chanNameItem); signalList->setItem(currentCount, SignalValueAtDomainIdx, chanValueItem); signalList->setCellWidget(currentCount, SignalColorIdx, colorButton); signalList->setCellWidget(currentCount, SignalRemoveIdx, removeButton); currentCount++; } if (auto domain = data.getDomain()) { OnDomainChanged(*domain); } OnSignalFilterEdited(filterEdit->text()); }
void WeatherScreen::newData(QString loc, units_t units, DataMap data) { (void) loc; (void) units; DataMap::iterator itr = data.begin(); while (itr != data.end()) { setValue(itr.key(), *itr); ++itr; } // This may seem like overkill, but it is necessary to actually update the // static and animated maps when they are redownloaded on an update if (!prepareScreen()) LOG(VB_GENERAL, LOG_ERR, "Theme is missing a required widget!"); emit screenReady(this); }
DataToReplay PrepareReplay(const QString& file, SignalData& signalData) { SignalData data; PlotInfo info; WorkspaceSerializer::Read(file, data, info); DataMap toSet; vector < pair<QString, QVector<qreal>>> toSend; data.onSignals([&](const Signal& signal){ toSet.emplace(signal.name, Signal{ signal.name, {}, signal.graphic }); toSend.emplace_back(make_pair(signal.name, std::move(signal.y))); }); for (auto& signal : toSet) { signalData.addIfNotExists(std::move(signal.second)); } signalData.setAsDomain(data.getDomain()->name); return toSend; }
TopGenerator::TopGenerator(const DataMap &data) : lang(data.getLang().lang) { DynArray<TypeDef::Kind *> kind_list(DoReserve,1024); for(auto &synt : data.getLang().synts.getRange() ) for(auto &kind : synt.kinds.getRange() ) kind_list.append_copy(&kind); ulen len=kind_list.getLen(); table.extend_default(len); ulen count=0; while( count<len ) { bool flag=false; for(ulen ind=count; ind<len ;ind++) { auto *kind=kind_list[ind]; if( auto *rule=findRule(kind) ) { defRule(kind,rule); if( ind>count ) Swap(kind_list[ind],kind_list[count]); count++; flag=true; } } if( !flag ) { Printf(Exception,"App::TopGenerator::TopGenerator(...) : bad lang"); } } }
bool CacheManagerI::load(const KeySeq& keys, const std::string& namespaceId, const std::string& businessId, long expiredTime, bool useMaster, const Ice::Current& current) { std::ostringstream os; os<<"Key : "; for(KeySeq::const_iterator it = keys.begin(); it != keys.end(); ++it) { os<<*it<<" "; } os<<" namespaceId :"<<namespaceId; os<<" businessId :"<<businessId; os<<" expiredTime :"<<expiredTime; os<<" useMaster :"<<useMaster; MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, os.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO); ProducerManagerClientPtr producer = getProducer(); if(producer == NULL) { return false; } bool sucFlag = true; KeySeq inputKeys(keys.begin(), keys.end()); KeySeq lockedKeys; KeySeq failedLockedKeys; DataMap res; while(true) { xce::tempmutext::Locks<std::string> locks(&tempMutexManager_, inputKeys, lockedKeys, failedLockedKeys); if(!lockedKeys.empty()) { DataMap singleRes = producer->produce(keys, businessId, useMaster, 1000); if(!singleRes.empty()) { res.insert(singleRes.begin(), singleRes.end()); } CacheClientPtr cache = getCache(); if(cache != NULL) { for(DataMap::const_iterator it = singleRes.begin(); it != singleRes.end(); ++it) { sucFlag &= cache->set(it->first, it->second, namespaceId, businessId, expiredTime, 1000); } } if(failedLockedKeys.empty()) { break; } } inputKeys.swap(failedLockedKeys); lockedKeys.clear(); failedLockedKeys.clear(); } return sucFlag; }
int main() { DataMap sightings; generate_n( inserter(sightings, sightings.begin()), 50, SightingGen(animals)); // Print everything: copy(sightings.begin(), sightings.end(), ostream_iterator<Sighting>(cout, "")); // Print sightings for selected animal: for(int count = 1; count < 10; count++) { // Use menu to get selection: // int i = menu(); // Generate randomly (for automated testing): int i = rand() % animals.size(); // Iterators in "range" denote begin, one // past end of matching range: pair<DMIter, DMIter> range = sightings.equal_range(animals[i]); copy(range.first, range.second, ostream_iterator<Sighting>(cout, "")); } } ///:~
void ConstructAndAddUser(string strLine, TextFileDataSource* tfds) { DataMap* pdmUsers = tfds->getUsersCollection(); vector<string> vecstrLineSplit = StringUtils::splitString(strLine, ','); int nUserID = TypeConverter(vecstrLineSplit[TextFileDataSource::USER_NAME]); string strPassword = vecstrLineSplit[TextFileDataSource::PASSWORD]; int nUserType = TypeConverter(vecstrLineSplit[TextFileDataSource::USER_TYPE]); if (nUserType == User::CUSTOMER) { // TODO ASSERTS HERE string strName = vecstrLineSplit[TextFileDataSource::NAME]; string strAddress = vecstrLineSplit[TextFileDataSource::ADDRESS]; string strPhone = vecstrLineSplit[TextFileDataSource::PHONE_NUMBER]; Customer* pu = new Customer(nUserID, strPassword, strName, strAddress, strPhone); // add accoutn ids vector<string> vecstrAccountIds = StringUtils::splitString(vecstrLineSplit[TextFileDataSource::ACCOUNT_IDS],';'); for (unsigned nId = 0; nId < vecstrAccountIds.size(); nId++) { pu->addAccount(TypeConverter(vecstrAccountIds[nId])); } pdmUsers->Add(pu); } else if (nUserType == User::BANK_CLERK) { pdmUsers->Add ( new BankClerk(nUserID, strPassword) ); } }