本文整理汇总了C++中ofstream::write方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::write方法的具体用法?C++ ofstream::write怎么用?C++ ofstream::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofstream
的用法示例。
在下文中一共展示了ofstream::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void write(int count)
{
// append the data to the file
file.write((const char*)&data[0], count * sizeof(T));
typename vector<T>::iterator i;
for(i=data.begin();i!=data.end();i++)
{
txtfile << *i << endl;
}
data.clear(); // erase the data
}
示例2: write
bool succintCode::write(ofstream& fout)
{
if(fout)
{
fout.write((char*)&_size,sizeof(_size));
fout.write((char*)&z,sizeof(z));
fout.write((char*)&w,sizeof(w));
if(rt->write(fout) && qt->write(fout))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
示例3: save_file_integralg3
int save_file_integralg3(double** integral_data, int anzahl_sets)
{
for(int ii = 0; ii < (anzahl_sets * anzahl_sets); ii++){
for(int jj = 0; jj < 8; jj++){
filek_groundstate.write((char*) &integral_data[ii][jj], sizeof(double));
}
}
return(0);
}
示例4: sizeof
int
StatRandomVibrationSimulation::sampletofile(int nstep, ofstream& record)
{
long streampos=record.tellp();
//nt sz=U->Size();
// record.write(reinterpret_cast<const char*>(&time), sizeof(time));
//
double val;
for( int i=0 ; i<nstep; i++) {
val=(*samplExc)(i);
record.write(
reinterpret_cast<const char*>(&val), sizeof( val));
}
for(int i=0 ; i<nstep; i++) {
val=(*samplResp)(i);
record.write(
reinterpret_cast<const char*>(&val), sizeof( val));
}
record.flush();
return streampos;
}
示例5: WriteHeader
void WriteHeader()
{
// set up the header before we write the data so it's easier to put in the
// correct values
for(int i = 0; i < files.size(); i++)
{
int o = 0;
outfile.write((char*)&o, 4); // offset
outfile.write((char*)&o, 4); // size
}
}
示例6: writeSample
/**
* @brief writeSample Write a sample out to a file
* @param sample
* @param file
*/
void writeSample(short sample, ofstream &file)
{
// Calculate sample offset
int sampleOffset = 44 + (this->samplesWritten * 2);
// Seek to location of next sample and write
file.seekp(sampleOffset);
file.write((char*)&sample, sizeof(sample));
// Increment number samples written
this->samplesWritten++;
}
示例7: WriteData
void MachLin::WriteData(ofstream &outf)
{
int s=odim*idim + odim;
outf.write((char*) &s,sizeof(int));
s=sizeof(REAL);
outf.write((char*) &s,sizeof(int));
#ifdef BLAS_CUDA
cudaSetDevice(cuda_dev);
REAL *local_mem=new REAL[odim*idim];
cublasGetVector(odim*idim,CUDA_SIZE,w,1,local_mem,1);
cuda_check_error("transfer of weight matrix from GPU memory");
outf.write((char*)local_mem,odim*idim*sizeof(REAL));
delete [] local_mem;
local_mem=new REAL[odim];
cublasGetVector(odim,CUDA_SIZE,b,1,local_mem,1);
cuda_check_error("transfer of bias vector from GPU memory");
outf.write((char*)local_mem,odim*sizeof(REAL));
delete [] local_mem;
#else
outf.write((char*) w,odim*idim*sizeof(REAL));
outf.write((char*) b,odim*sizeof(REAL));
#endif
}
示例8: write_coltable
static bool write_coltable()
{
rgb_color white,black;
white.blue=255;
white.red=255;
white.green=255;
black.blue=0;
black.red=0;
black.green=0;
fout.write((char *) &(white.blue), sizeof(char));
if (!fout.good()) return 0;
fout.write((char *) &(white.green), sizeof(char));
if (!fout.good()) return 0;
fout.write((char *) &(white.red), sizeof(char));
if (!fout.good()) return 0;
fout.write((char *) &(black.blue), sizeof(char));
if (!fout.good()) return 0;
fout.write((char *) &(black.green), sizeof(char));
if (!fout.good()) return 0;
fout.write((char *) &(black.red), sizeof(char));
if (!fout.good()) return 0;
//fout.write((char *) &(black.alpha), sizeof(char));
//if (!fout.good()) return 0;
return 1;
}
示例9: writeHorizontalFirstLine
void DistanceMatrix::writeHorizontalFirstLine( vector<ProteinSequence> p, ofstream& oFile, string tab )
{
ScoreMatrix convert;
vector<string> SeqNumber;
int countSeq = 0;
//oFile.write( tab.c_str(), tab.size());
for( size_t i = 0; i < p.size(); i++ )
{
oFile.write( tab.c_str(), tab.size());
if ( i > 0)
{
oFile.write( tab.c_str(), tab.size());
}
countSeq++;
string s = "S";
string seqNum = convert.number_to_string(countSeq);
s = s + seqNum;
SeqNumber.push_back(s);
oFile.write( s.c_str(), s.size() );
}
}
示例10: WriteFrame
// Called when an audio frame arrives
virtual bool WriteFrame()
{
if (!started)
return false;
size_t frameSize = GetDataSize();
if (!frameSize)
return true;
if (!buf)
buf = new char[frameSize];
GetData(buf, frameSize);
f.write(buf, frameSize);
return true;
}
示例11: store_snaps_direct
bool store_snaps_direct(ofstream& ofs, vector<snapshot_t>& vecSnaps, Source_Props& properties){
properties.scomSnap.clear();
for (uint32_t i = 0; i < vecSnaps.size(); ++i){
vector < U32 > scom;
for (uint32_t j = 0; j < vecSnaps[i].size(); ++j){
ofs.write((char *)&*vecSnaps[i][j].begin(), sizeof(U32)*vecSnaps[i][j].size());
scom.push_back(vecSnaps[i][j].size());
}
properties.scomSnap.push_back(scom);
scom.clear();
}
return 1;
}
示例12: aFatString
/**
Creates the FAT Table
@internalComponent
@released
@param ofstream
*/
void CFat16FileSystem::CreateFatTable(ofstream& aOutPutStream)
{
int FATSizeInBytes = (iFAT16BootSector.FatSectors()) * (iFAT16BootSector.BytesPerSector());
// Each FAT16 entries occupies 2 bytes, hence divided by 2
unsigned int totalFatEntries = FATSizeInBytes / 2;
unsigned short *FatTable = new unsigned short[totalFatEntries];
unsigned short int clusterCounter = 1;
int previousCluster;
FatTable[0] = KFat16FirstEntry;
/**Say cluster 5 starts at 5 and occupies clusters 7 and 9. The FAT table should have the
value 7 at cluster location 5, the value 9 at cluster 7 and 'eof' value at cluster 9.
Below algorithm serves this algorithm
*/
Iterator itr = iClustersPerEntry->begin();
while(itr != iClustersPerEntry->end())
{
previousCluster = itr->second;
if(iClustersPerEntry->count(itr->first) > 1)
{
for(unsigned int i = 1; i < iClustersPerEntry->count(itr->first); i++)
{
FatTable[previousCluster] = (unsigned short)(++itr)->second;
previousCluster = itr->second;
++clusterCounter;
}
}
FatTable[previousCluster] = EOF16;
itr++;
++clusterCounter;
}
// Each FAT16 entries occupies 2 bytes, hence multiply by 2
std::string aFatString(reinterpret_cast<char*>(FatTable),clusterCounter*2);
delete[] FatTable;
if(clusterCounter < totalFatEntries)
{
// Each FAT16 entries occupies 2 bytes, hence multiply by 2
aFatString.append((totalFatEntries - clusterCounter)*2, 0);
}
MessageHandler::ReportMessage (INFORMATION,FATTABLEWRITEMSG,"FAT16");
// Write FAT table multiple times depending upon the No of FATS set.
unsigned int noOfFats = iFAT16BootSector.NumberOfFats();
for(unsigned int i=0; i<noOfFats; i++)
{
aOutPutStream.write(aFatString.c_str(),aFatString.length());
}
aFatString.erase();
aOutPutStream.flush();
}
示例13: Write
//=============================================================================
void CLM::Write(ofstream &s, bool binary)
{
if(!binary){
s << IO::CLM << " " << _patch.size() << " ";
_pdm.Write(s);
IO::WriteMat(s,_refs);
for(size_t i = 0; i < _cent.size(); i++)
IO::WriteMat(s,_cent[i]);
for(size_t i = 0; i < _visi.size(); i++)
IO::WriteMat(s,_visi[i]);
for(size_t i = 0; i < _patch.size(); i++){
for(int j = 0; j < _pdm.nPoints(); j++)
_patch[i][j].Write(s, binary);
}
}
else{
int t = IOBinary::CLM;
s.write(reinterpret_cast<char*>(&t), sizeof(t));
t = _patch.size();
s.write(reinterpret_cast<char*>(&t), sizeof(t));
_pdm.Write(s, binary);
IOBinary::WriteMat(s,_refs);
for(size_t i = 0; i < _cent.size(); i++)
IOBinary::WriteMat(s,_cent[i]);
for(size_t i = 0; i < _visi.size(); i++)
IOBinary::WriteMat(s,_visi[i]);
for(size_t i = 0; i < _patch.size(); i++){
for(int j = 0; j < _pdm.nPoints(); j++){
_patch[i][j].Write(s, binary);
// if(j%46==0 && _patch[i][j]._p.size()){
// std::cout << i << " " <<j << std::endl;
// std::cout << _patch[i][j]._p[0]._W << std::endl;
// }
}
}
}
return;
}
示例14: write
void Transaction::write(ofstream &fp, LINT cid, LINT incrtid)
{
if (nitems == 0)
return;
sort();
tid++;
if (cid == 0) // no customer-id; set cust-id to trans-id
cid = tid;
if (print_cid)
fp.write((char *) &cid, sizeof(LINT));
if (incrtid == -1)
fp.write((char *) &tid, sizeof(LINT));
else
fp.write((char *) &incrtid, sizeof(LINT));
fp.write((char *) &nitems, sizeof(LINT));
fp.write((char *) items, nitems * sizeof(LINT));
//cout << "TTT " << cid << " " << tid << " " << incrtid << " "
//<< nitems << endl;
}
示例15: copyToFile
int HTTPRequest::copyToFile(ofstream& ofs)
{
size_t contentLength = atoi(getHTTPHeader("Content-Length").c_str());
if (ofs.good())
{
ofs.write(m_requestBody.c_str(), contentLength);
}
if (ofs.bad())
return -1;
return 0;
}