当前位置: 首页>>代码示例>>C++>>正文


C++ FileIO类代码示例

本文整理汇总了C++中FileIO的典型用法代码示例。如果您正苦于以下问题:C++ FileIO类的具体用法?C++ FileIO怎么用?C++ FileIO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileIO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: openTable

void DBMS::openTable(queue<Token> params){
	FileIO fileManager;
	string table_name;
	relation intoTable;

	//first token in string is name of table
	table_name=params.front().value;
	params.pop();
	try{
		intoTable = fileManager.readFromFile(table_name, 0);
	}catch(...){
		cout<<"Error: Table "<<table_name<<" could not be found"<<endl;
		return;
	}
	
	//Table already in memory, delete it from queryResults and 6then push back the new one
	vector<relation>::iterator it;
	for (it= queryResults.begin(); it < queryResults.end(); it++){
		if (it->name == table_name){
			queryResults.erase(it);
			break;
		}
	}
		
	queryResults.push_back(intoTable);
}
开发者ID:ecobost,项目名称:miniDBMS,代码行数:26,代码来源:DBMS.cpp

示例2: Load

//----------------------------------------------------------------------------
bool Lattice::Load (FileIO& inFile)
{
    int numBytes = (int)strlen(msHeader) + 1;
    char* buffer = new1<char>(numBytes);
    inFile.Read(sizeof(char), numBytes, buffer);
    buffer[numBytes-1] = 0;
    if (strncmp(buffer, msHeader, numBytes) != 0)
    {
        delete1(buffer);
        mNumDimensions = 0;
        mQuantity = 0;
        mBounds = 0;
        mOffsets = 0;
        return false;
    }
    delete1(buffer);

    inFile.Read(sizeof(int), &mNumDimensions);

    delete1(mBounds);
    mBounds = new1<int>(mNumDimensions);
    inFile.Read(sizeof(int), mNumDimensions, mBounds);

    delete1(mOffsets);
    mOffsets = new1<int>(mNumDimensions);

    ComputeQuantityAndOffsets();

    return true;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:31,代码来源:Wm5Lattice.cpp

示例3:

void * FileIO::threadFunction(void * ptr) {
	FileIO *me = (FileIO *)ptr;
//	printf("D: %d\n", me->mDuration);
	
#ifdef DO_TIMING
	int sleepTime;
	struct timeval *meThen = &me->mThen;
	struct timeval *meNow = & me->mNow;
#endif
	while (me->mIsPlaying) {			// loop until turned off
#ifdef DO_TIMING
		GET_TIME(meThen);
#endif
		me->writeNextBuffer();			// get and write the next buffer
#ifdef DO_TIMING
		GET_TIME(meNow);
		me->printTimeStatistics(meNow, meThen, & me->mThisSec, & me->mTimeSum, & me->mTimeVals);
		GET_TIME(meNow);
		sleepTime = me->mDuration - (((meNow->tv_sec - meThen->tv_sec) * 1000000) + (meNow->tv_usec - meThen->tv_usec));
	//	printf("S: %d\n", sleepTime);
		if (sleepTime > 0)
			csl::sleepUsec(sleepTime);
#else
		csl::sleepUsec(me->mDuration);
#endif
	}
				// do this to prevent a race condition
	me->mIsThreadRunning = false;
	logMsg("Stopping sound file output thread");
	return 0;
}
开发者ID:eriser,项目名称:CSL,代码行数:31,代码来源:FileIO.cpp

示例4: handleDownloadedFirmware

void SessionItem::handleDownloadedFirmware()
{
    FileIO f;
    f.writeRawByFilename(getTmpPathForFirmware() + "/firmware.bin",  m_firmware_fd->downloadedData());
    emit firmwareDownloaded();
    disconnect(m_firmware_fd, SIGNAL(downloaded()), this, SLOT(handleDownloadedFirmware()));
}
开发者ID:analogdevicesinc,项目名称:Pixelpulse2,代码行数:7,代码来源:SMU.cpp

示例5: FileIO

Matrix* Picture::getPerspectiveTransform(char* fileName, int width, int height)
{
   FileIO* inputFile = new FileIO(fileName, 1);  //for reading

   //fov
   string line = inputFile->readLine();  //skip this line
   line = inputFile->readLine();
   double fov = atof(line.c_str());

   double angle = 3.1415927*fov/180.0;  //get the angle in radians
   double xmax = tan(angle/2);           //the width of the camera is determined by its fov
   double ymax = xmax*(height)/(width);  //the height of the camera is determined by the aspect ratio of the panel upon which the image will be rendered

   //zmax
   line = inputFile->readLine();  //skip this line
   line = inputFile->readLine();
   double zmax = atof(line.c_str());

   //zmin
   line = inputFile->readLine();  //skip this line
   line = inputFile->readLine();
   double zmin = atof(line.c_str());

   Matrix* pn = AffineTransforms::perspectiveNorm(xmax, ymax, zmax, zmin);

   delete inputFile;
   return pn;
}
开发者ID:alwalker,项目名称:TTU,代码行数:28,代码来源:Picture.cpp

示例6: ene

void CDAccess_Image::ImageOpenBinary(const char *path, bool isIso)
{
	NumTracks = FirstTrack = LastTrack = 1;
	total_sectors = 0;
	disc_type = DISC_TYPE_CDDA_OR_M1;
	auto &track = Tracks[1];
	track = {};
	FileIO fp;
	if(fp.open(path) != OK)
	{
		ErrnoHolder ene(errno);
		throw(MDFN_Error(ene.Errno(), _("Could not open file \"%s\": %s"), path, ene.StrError()));
	}
	track.fp = std::make_shared<FileIO>(std::move(fp));
	track.FirstFileInstance = 1;
	track.DIFormat = DI_FORMAT_MODE1_RAW;
	if(isIso)
	{
		track.DIFormat = DI_FORMAT_MODE1;
		track.postgap = 150;
		total_sectors += track.postgap;
	}

	track.sectors = GetSectorCount(&track);
	total_sectors += track.sectors;
}
开发者ID:kiorter,项目名称:emu-ex-plus-alpha,代码行数:26,代码来源:CDAccess_Image.cpp

示例7: main

int main(int argc, char *argv[]) {
	if (argc != 3) {
		std::cerr << "Usage: " << argv[0] << " inputfile outputfile" << std::endl;
		return 1;
	}
	FileIO fileIO;
	try {
		fileIO.loadFromFile(argv[1]);
	} catch(const std::runtime_error& e) {
		std::cerr << e.what() << std::endl;
		return 2;
	}

	std::cout << "Calibrating..." << std::endl;
	Eigen::Matrix3d calibrationMatrix = OdometryCalibration::calibrateOdometry(fileIO.measurements);
	std::cout << "Calibration finished. The calibration matrix is: " << std::endl;
	std::cout << calibrationMatrix << std::endl;
	std::vector<Odometry> calibratedOdometry;
	calibratedOdometry.reserve(fileIO.uncalibrated.size());
	for (std::vector<Odometry>::const_iterator it = fileIO.uncalibrated.begin(); it != fileIO.uncalibrated.end(); ++it) {
		calibratedOdometry.push_back(OdometryCalibration::applyOdometryCorrection(*it, calibrationMatrix));
	}
	try {
		fileIO.writeToFile(argv[2], calibratedOdometry);
	} catch(const std::runtime_error& e) {
		std::cerr << e.what() << std::endl;
		return 3;
	}

	return 0;

}
开发者ID:CheHaoKang,项目名称:HumanoidRobotics,代码行数:32,代码来源:main.cpp

示例8: Save

//----------------------------------------------------------------------------
bool Lattice::Save (FileIO& outFile) const
{
    outFile.Write(sizeof(char), (int)strlen(msHeader) + 1, msHeader);
    outFile.Write(sizeof(int), &mNumDimensions);
    outFile.Write(sizeof(int), mNumDimensions, mBounds);
    return true;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:8,代码来源:Wm5Lattice.cpp

示例9: main

int main()
{
  cout<<"hello World"<<endl;
   FileIO f;// = new FileIO();
  f.openFile("a.txt");

  return 0;
}
开发者ID:dipankar08,项目名称:craZyeXp,代码行数:8,代码来源:persistence.cpp

示例10: handleDownloadedFirmware

void SessionItem::handleDownloadedFirmware()
{
    FileIO f;
    BossacWrapper bw;
    f.writeRawByFilename(bw.getTmpPathForFirmware() + "/firmware.bin",  m_firmware_fd->downloadedData());

    delete m_firmware_fd;
    m_firmware_fd = NULL;
}
开发者ID:MrWilson1,项目名称:Pixelpulse2,代码行数:9,代码来源:SMU.cpp

示例11: fopen

 void HMMObservations::dump(std::string filename) {
     FILE* fp = fopen(filename.c_str(), "w");
     assert(fp);
     FileIO fio;
     fio.writeUInt32(fp, nseq);
     fio.writeUInt32Array(fp, slen, nseq);
     fio.writeUInt32Array(fp, y, tot_len);
     fclose(fp);
 }
开发者ID:brunodigiorgi,项目名称:fdhmm,代码行数:9,代码来源:HMM.cpp

示例12: lock

// ---------------------------------------------------------------------------
//	スナップショット保存
//
bool WinCore::SaveShapshot(const char* filename)
{
	LockObj lock(this);

	bool docomp = !!(config.flag2 & Config::compresssnapshot);

	uint size = devlist.GetStatusSize();
	uint8* buf = new uint8[docomp ? size * 129 / 64 + 20 : size];
	if (!buf)
		return false;
	memset(buf, 0, size);

	if (devlist.SaveStatus(buf))
	{
		ulong esize = size * 129 / 64 + 20-4;
		if (docomp)
		{
			if (Z_OK != compress(buf+size+4, &esize, buf, size))
			{
				delete[] buf;
				return false;
			}
			*(int32*) (buf+size) = -(long)esize;
			esize += 4;
		}

		SnapshotHeader ssh;
		memcpy(ssh.id, SNAPSHOT_ID, 16);

		ssh.major = ssmajor;
		ssh.minor = ssminor;
		ssh.datasize = size;
		ssh.basicmode = config.basicmode;
		ssh.clock = int16(config.clock);
		ssh.erambanks = uint16(config.erambanks);
		ssh.cpumode = int16(config.cpumode);
		ssh.mainsubratio = int16(config.mainsubratio);
		ssh.flags = config.flags | (esize < size ? 0x80000000 : 0);
		ssh.flag2 = config.flag2;
		for (uint i=0; i<2; i++)
			ssh.disk[i] = (int8) diskmgr->GetCurrentDisk(i);

		FileIO file;
		if (file.Open(filename, FileIO::create))
		{
			file.Write(&ssh, sizeof(ssh));
			if (esize < size)
				file.Write(buf+size, esize);
			else
				file.Write(buf, size);
		}
	}
	delete[] buf;
	return true;
}
开发者ID:pololei,项目名称:m88,代码行数:58,代码来源:wincore.cpp

示例13:

bool Delaunay<Real>::Save (FileIO& outFile) const
{
    // Fixed-size members.
    int type = (int)mQueryType;
    outFile.Write(sizeof(int), &type);

    outFile.Write(sizeof(int), &mNumVertices);
    outFile.Write(sizeof(int), &mDimension);
    outFile.Write(sizeof(int), &mNumSimplices);
    outFile.Write(sizeof(Real), &mEpsilon);

    // The member mOwner is not streamed because on a Load call, this
    // object will allocate the vertices and own this memory.

    // Variable-size members.
    int numIndices;
    if (1 <= mDimension && mDimension <= 3)
    {
        numIndices = (mDimension+1)*mNumSimplices;
        outFile.Write(sizeof(int), &numIndices);
        outFile.Write(sizeof(int), numIndices, mIndices);
        outFile.Write(sizeof(int), numIndices, mAdjacencies);
        return true;
    }

    numIndices = 0;
    outFile.Write(sizeof(int), &numIndices);
    return mDimension == 0;
}
开发者ID:JackTing,项目名称:SkpColl,代码行数:29,代码来源:Wm5Delaunay.cpp

示例14: TEST

TEST(OdometryCalibration, Calibration) {
	FileIO fileIO;
	std::string path = ros::package::getPath("odometry_calibration") + "/data/calib.dat";
	try {
		fileIO.loadFromFile(path.c_str());
	} catch(const std::runtime_error& e) {
		ASSERT_TRUE(false) << "Could not load calibration data file";
	}
	Eigen::Matrix3d calibrationMatrix = OdometryCalibration::calibrateOdometry(fileIO.measurements);
	ASSERT_NEAR(-0.0754092, calibrationMatrix.determinant(), 1e-5);
}
开发者ID:CheHaoKang,项目名称:HumanoidRobotics,代码行数:11,代码来源:test_odometry_calibration.cpp

示例15: SaveVertexBuffer

//----------------------------------------------------------------------------
void Visual::SaveVertexBuffer (FileIO& outFile)
{
    int numElements = mVBuffer->GetNumElements();
    int elementSize = mVBuffer->GetElementSize();
    Buffer::Usage vbusage = mVBuffer->GetUsage();
    int usage = (int)vbusage;
    outFile.Write(sizeof(int), &numElements);
    outFile.Write(sizeof(int), &elementSize);
    outFile.Write(sizeof(int), &usage);

    VertexBufferAccessor vba(mVFormat, mVBuffer);
    vba.Write(outFile);
}
开发者ID:Kiichi77,项目名称:WildMagic,代码行数:14,代码来源:Wm5Visual.cpp


注:本文中的FileIO类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。