本文整理汇总了C++中FileMap::end方法的典型用法代码示例。如果您正苦于以下问题:C++ FileMap::end方法的具体用法?C++ FileMap::end怎么用?C++ FileMap::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileMap
的用法示例。
在下文中一共展示了FileMap::end方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare_files
//*******************************************************************
// compare_files PRIVATE
//-------------------------------------------------------------------
// Porownanie wszystkich przyslanych plikow.
// Kryterium porownywania jest czas ich ostatniej modyfikacji.
//*******************************************************************
void QBtCompareDirsDialog::compare_files( const FileMap& in_data1, const FileMap& in_data2 )
{
QBtShared::idle();
if( !continue_ ) return;
AllItems data_all = AllItems();
join_files( data_all, in_data1 );
join_files( data_all, in_data2 );
if( data_all.empty() ) return;
RowData row_data;
AllItems::const_iterator it = data_all.begin();
const AllItems::const_iterator end = data_all.end();
while( continue_ && ( it != end ) ) {
const QString name = it.key();
const FileMap::const_iterator it1 = in_data1.find( name );
const FileMap::const_iterator it2 = in_data2.find( name );
const bool is1 = ( it1 != in_data1.end() );
const bool is2 = ( it2 != in_data2.end() );
row_data.reset();
if( is1 ) row_data.set_lft( name, it1.value().absoluteFilePath() );
if( is2 ) row_data.set_rgt( name, it2.value().absoluteFilePath() );
if( is1 && is2 ) {
row_data.separator( check_files( row_data.path1(), row_data.path2() ) );
}
add_row( row_data );
++it;
}
}
示例2: release
// Call instead of delete:
void DataFile::release ()
{
if (--_ref_count <= 0)
{
FileMap::iterator i = open_data_files.find (_filename);
LOG_ASSERT (i != open_data_files.end ());
open_data_files.erase (i);
delete this;
}
}
示例3: join_files
//*******************************************************************
// join_files PRIVATE
//*******************************************************************
void QBtCompareDirsDialog::join_files( AllItems& out_set, const FileMap& in_map ) const
{
if( in_map.empty() ) return;
FileMap::const_iterator it = in_map.begin();
const FileMap::const_iterator end = in_map.end();
while( continue_ && ( it != end ) ) {
out_set.insert( it.key(), QString() );
++it;
}
}
示例4: DataFile
DataFile *DataFile::reference (const stdString &filename, bool for_write)
{
DataFile *file;
FileMap::iterator i = open_data_files.find (filename);
if (i == open_data_files.end ())
{
file = new DataFile (filename, for_write);
open_data_files.insert (FileMap::value_type (file->getFilename(), file));
}
else
{
file = i->second;
file->reference ();
}
return file;
}
示例5: FillReadDir
void CacheBase::FillReadDir(const char* path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
BlockLockMutex lock(this);
DirEntry* dir = dynamic_cast<DirEntry*>(Path2File(path));
if(!dir)
throw NoSuchFileOrDir();
FileMap files = dir->GetFiles();
for(FileMap::const_iterator it = files.begin(); it != files.end(); ++it)
{
if(it->second->IsRemoved())
continue;
struct stat st;
memset(&st, 0, sizeof st);
/*st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;*/
if(filler(buf, it->second->GetName().c_str(), &st, 0))
break;
}
}
示例6: SaveToStreams
void ObjectCollection::SaveToStreams()
{
typedef std::pair<String, Array<TypedCompoundPointer>> FileEntry;
typedef std::unordered_map<String, Array<TypedCompoundPointer>> FileMap;
FileMap map;
for (TypedCompoundPointer& p : mObjects)
{
String* loc = p.GetCompoundMember<String>("!location");
gAssert(loc != nullptr);
FileMap::iterator i = map.find(*loc);
if (i == map.end())
map.insert(FileEntry(*loc, Array<TypedCompoundPointer>(&p, 1)));
else
i->second.Append(p);
}
for (const FileEntry& entry : map)
{
Path target_path(entry.first);
StreamDevice* d = gDevices.FindDevice(target_path.GetDeviceName());
gAssert(d != nullptr);
Stream* s = d->CreateStream(target_path, smWrite);
gAssert(s != nullptr);
ObjectWriter wr(*s);
std::cout << "Opened stream to " << target_path << std::endl;
for (const TypedCompoundPointer& object : entry.second)
{
const String* name = object.GetCompoundMember<String>("!name");
const String* loc = object.GetCompoundMember<String>("!location");
std::cout << " Writing: " << (loc != nullptr ? *loc : String("<noloc>")) << " : " << (name != nullptr ? *name : String("<noname>")) << std::endl;
wr.WriteTypedCompoundPointer(object);
}
d->CloseStream(s);
}
}
示例7: createGenoCalling
void createGenoCalling(string fname)
{
int recordLength = gtcHash.size() * 18;
char *buffer = new char[recordLength];
memset(buffer,' ',recordLength);
buffer[recordLength-1] = '\n';
// Sort the SNPs into position order
sort(manifest->snps.begin(), manifest->snps.end(), SortByPosition);
// Create lockfile
string lockFileName = fname + ".lock";
FILE *lockfile = fopen(lockFileName.c_str(), "w");
if (!lockfile) throw (strerror(errno));
fclose(lockfile);
//
// Create all of the output files - one for each chromosome
//
for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
fstream *f = outFile[snp->chromosome];
if (!f) {
f = new fstream();
string fullFname = fname + "_gtu_" + snp->chromosome + ".txt";
filenameArray.push_back("_gtu_" + snp->chromosome + ".txt");
if (verbose) cout << timestamp() << "creating file " << fullFname << endl;
f->open(fullFname.c_str(), ios::in | ios::out | ios::trunc);
// write sample names from all the gtc files
for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
*f << "\t" << i->first;
}
*f << endl;
// associate the file handle with the chromosome
outFile[snp->chromosome] = f;
}
f = outFile[snp->chromosome];
*f << snp->name;
filePos[snp->name] = f->tellp(); // store next position to write
f->write(buffer,recordLength); // fill with nulls (or spaces)
gcCache[snp->name] = "";
}
//
// Process each GTC file in turn
//
int n=1;
int cacheIndex = 0;
for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
if (verbose) cout << timestamp() << "Processing GTC file " << n++ << " of " << gtcHash.size() << endl;
gtc.open(i->second,Gtc::GENOTYPES | Gtc::BASECALLS | Gtc::SCORES); // reload GTC file to read required arrays
for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
int idx = snp->index - 1; // index is zero based in arrays, but starts from 1 in the map file
char buffer[128];
if (gtc.genotypes[idx] > 3)
cout << "Unknown genotype value: " << gtc.genotypes[idx] << endl;
if (gtc.genotypes[idx] == 0)
sprintf(buffer,"\tNN;%f", gtc.scores[idx]);
else
sprintf(buffer,"\t%c%c;%f", gtc.baseCalls[idx].a, gtc.baseCalls[idx].b, gtc.scores[idx]);
gcCache[snp->name] += buffer;
}
cacheIndex++;
if (cacheIndex == GCCACHESIZE) { flushgcCache(cacheIndex); cacheIndex=0; }
}
flushgcCache(cacheIndex);
// close all of the files
for (pos = outFile.begin(); pos != outFile.end(); pos++) {
pos->second->close();
}
// delete lockfile and create donefile
string doneFileName = lockFileName;
string::size_type dot = doneFileName.find(".lock");
doneFileName.replace(dot, 5, ".g2i");
rename(lockFileName.c_str(), doneFileName.c_str());
if (verbose) cout << timestamp() << "Renamed " << lockFileName << " to " << doneFileName << endl;
}
示例8: goForIt
//
// We've read the Manifest and all the GTC files
// Now it's time to create the output files
//
void goForIt(string fname)
{
int recordLength = gtcHash.size() * 10 * 2;
if (binary) recordLength = gtcHash.size() * sizeof(float) * 2;
char *buffer = new char[recordLength];
if (binary) {
memset(buffer,0,recordLength);
} else {
memset(buffer,' ',recordLength);
buffer[recordLength-1] = '\n';
}
// Sort the SNPs into position order
sort(manifest->snps.begin(), manifest->snps.end(), SortByPosition);
// Create lockfile
string lockFileName = fname + ".lock";
FILE *lockfile = fopen(lockFileName.c_str(), "w");
if (!lockfile) {
cerr << "Can't create lock file " << lockFileName << endl;
cerr << strerror(errno) << endl;
exit(1);
}
fclose(lockfile);
//
// Create all of the output files - one for each chromosome
//
for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
fstream *f = outFile[snp->chromosome];
if (!f) {
f = new fstream();
string fullFname = fname + "_intu_" + snp->chromosome + ".txt";
filenameArray.push_back("_intu_" + snp->chromosome + ".txt");
if (verbose) cout << timestamp() << "creating file " << fullFname << endl;
if (binary) f->open(fullFname.c_str(), ios::in | ios::out | ios::trunc | ios::binary);
else f->open(fullFname.c_str(), ios::in | ios::out | ios::trunc);
*f << "SNP\tCoor\tAlleles";
// write sample names from all the gtc files
for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
*f << "\t" << i->first << "A\t" << i->first << "B";
}
*f << endl;
// associate the file handle with the chromosome
outFile[snp->chromosome] = f;
}
f = outFile[snp->chromosome];
*f << snp->name << "\t" << snp->position << "\t" << snp->snp[0] << snp->snp[1];
filePos[snp->name] = f->tellp(); // store next position to write
f->write(buffer,recordLength); // fill with nulls (or spaces)
cache[snp->name] = new float[CACHESIZE];
}
//
// Process each GTC file in turn
//
int n=1;
int cacheIndex = 0;
for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
if (verbose) cout << timestamp() << "Processing GTC file " << n++ << " of " << gtcHash.size() << endl;
gtc.open(i->second,Gtc::XFORM | Gtc::INTENSITY); // reload GTC file to read XForm and Intensity arrays
for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
int idx = snp->index - 1; // index is zero based in arrays, but starts from 1 in the map file
unsigned int norm = manifest->normIdMap[snp->normId];
XFormClass *XF = >c.XForm[norm];
double xn, yn;
if (normalise) {
// first do the normalisation calculation
double tempx = gtc.xRawIntensity[idx] - XF->xOffset;
double tempy = gtc.yRawIntensity[idx] - XF->yOffset;
double cos_theta = cos(XF->theta);
double sin_theta = sin(XF->theta);
double tempx2 = cos_theta * tempx + sin_theta * tempy;
double tempy2 = -sin_theta * tempx + cos_theta * tempy;
double tempx3 = tempx2 - XF->shear * tempy2;
double tempy3 = tempy2;
xn = tempx3 / XF->xScale;
yn = tempy3 / XF->yScale;
} else {
xn = gtc.xRawIntensity[idx];
yn = gtc.yRawIntensity[idx];
}
cache[snp->name][cacheIndex] = xn;
cache[snp->name][cacheIndex+1] = yn;
//.........这里部分代码省略.........
示例9: save_changes
bool FileContainerTemporary::save_changes(const std::string &filename, bool as_copy)
{
if (file_is_opened()) return false;
etl::handle< FileContainerZip > container;
std::string fname_abs = fix_slashes(filename);
if (!is_absolute_path(fname_abs)) fname_abs = absolute_path(fname_abs);
bool save_at_place = filename.empty() || fname_abs == container_filename_;
if (save_at_place) as_copy = false;
if (save_at_place)
{
if (!container_->is_opened()) return false;
container = container_;
}
else
{
if (container_->is_opened())
{
{ // copy container
ReadStreamHandle read_steram = container_->get_read_stream_whole_container();
if (read_steram.empty()) return false;
WriteStreamHandle write_stream = file_system_->get_write_stream(filename);
if (write_stream.empty()) return false;
if (!write_stream->write_whole_stream(read_steram)) return false;
}
// open container
container = new FileContainerZip();
if (!container->open(filename)) return false;
}
else
{
// create container
container = new FileContainerZip();
if (!container->create(filename)) return false;
}
}
FileMap files = files_;
// remove files
bool processed = true;
while(processed)
{
processed = false;
for(FileMap::iterator i = files.begin(); i != files.end(); i++)
{
if (i->second.is_removed && container->file_remove(i->second.name))
{
processed = true;
files.erase(i);
break;
}
}
}
// create directories
processed = true;
while(processed)
{
processed = false;
for(FileMap::iterator i = files.begin(); i != files.end(); i++)
{
if (!i->second.is_removed
&& i->second.is_directory
&& container->directory_create(i->second.name))
{
processed = true;
files.erase(i);
break;
}
}
}
// create files
for(FileMap::iterator i = files.begin(); i != files.end();)
{
if (!i->second.is_removed
&& !i->second.is_directory
&& !i->second.tmp_filename.empty()
&& copy(file_system_, i->second.tmp_filename, container, i->second.name))
{
file_system_->file_remove(i->second.tmp_filename);
processed = true;
files.erase(i++);
}
else i++;
}
// try to save container
if (container->save())
{
// update internal state
if (save_at_place)
{
files_ = files;
//.........这里部分代码省略.........
示例10: listMembers
int InstallShieldCabinet::listMembers(Common::ArchiveMemberList &list) const {
for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
list.push_back(getMember(it->_key));
return _map.size();
}