本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例9: main
int main()
{
cout<<"hello World"<<endl;
FileIO f;// = new FileIO();
f.openFile("a.txt");
return 0;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}