示例#1
0
文件: DBMS.cpp 项目: ecobost/miniDBMS
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
0
//----------------------------------------------------------------------------
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
0
文件: FileIO.cpp 项目: eriser/CSL
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
0
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
0
文件: Picture.cpp 项目: alwalker/TTU
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;
}
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
0
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
0
//----------------------------------------------------------------------------
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
0
int main()
{
  cout<<"hello World"<<endl;
   FileIO f;// = new FileIO();
  f.openFile("a.txt");

  return 0;
}
示例#10
0
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
0
 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
0
文件: wincore.cpp 项目: pololei/m88
// ---------------------------------------------------------------------------
//	スナップショット保存
//
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
0
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;
}
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
0
//----------------------------------------------------------------------------
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);
}
示例#16
0
 void HMM::save_parameters(std::string filename) {
     FileIO fio;
     FILE* fp = fopen(filename.c_str(), "w");
     assert(fp);
     
     fio.writeUInt32(fp, hs);
     fio.writeUInt32(fp, os);
     fio.writeDoubleArray(fp, nu, hs);
     fio.writeDoubleArray(fp, Q, hs*hs);
     fio.writeDoubleArray(fp, g, hs*os);
     
     fclose(fp);        
 }
示例#17
0
bool Delaunay<Real>::Load (FileIO& inFile)
{
    delete1(mIndices);
    delete1(mAdjacencies);

    // Fixed-size members.
    int type;
    inFile.Read(sizeof(int), &type);
    mQueryType = (Query::Type)type;

    inFile.Read(sizeof(int), &mNumVertices);
    inFile.Read(sizeof(int), &mDimension);
    inFile.Read(sizeof(int), &mNumSimplices);
    inFile.Read(sizeof(Real), &mEpsilon);

    // Variable-size members.
    int numIndices;
    inFile.Read(sizeof(int), &numIndices);
    if (1 <= mDimension && mDimension <= 3)
    {
        assertion(numIndices == (mDimension+1)*mNumSimplices,
            "Inconsistent index count\n");
        mIndices = new1<int>(numIndices);
        mAdjacencies = new1<int>(numIndices);
        inFile.Read(sizeof(int), numIndices, mIndices);
        inFile.Read(sizeof(int), numIndices, mAdjacencies);
        return true;
    }

    mIndices = 0;
    mAdjacencies = 0;
    return mDimension == 0;
}
示例#18
0
bool FormatSniffer::wrap(FileIO& fin, bool caching) {
  char buf[caching?32768:100];
  cache = "";
  size_t bytes_read;
  if (caching) {
    while ((bytes_read=fin.fread(buf,1,sizeof(buf)))>0) {
      cache.append(buf,bytes_read);
    }
  } else {
    bytes_read = fin.fread(buf,1,sizeof(buf));
    cache.append(buf,bytes_read);
  }
  return true;
}
示例#19
0
double soundReadSample24L_L(FileIO& soundfile) {
   unsigned char temp[3];
   int32_t sample;
   soundfile.readLittleEndian(temp[2]);
   soundfile.readLittleEndian(temp[1]);
   soundfile.readLittleEndian(temp[0]);
   sample = temp[0];
   sample = (sample << 8) | temp[1];
   sample = (sample << 8) | temp[2];
   if (temp[0] & 0x80) {
      sample = sample | 0xff000000;
   }
   return (double)sample / (int32_t)0x800000;
}
示例#20
0
文件: DBMS.cpp 项目: ecobost/miniDBMS
void DBMS::writeTable(queue<Token> params){
	FileIO fileManager;
	vector<relation>::iterator it;
	for (it= queryResults.begin(); it < queryResults.end(); it++){
		if (it->name == params.front().value){
			fileManager.printToFile(*it);
			break;
		}
	}
	if(it==queryResults.end()){
		cout<<"Table "<<params.front().value<<" is not charged in memory."<<endl;
		return;
	}
	params.pop();
}
int main(){
	FileIO * file = new FileIO("tube.txt");

	vector<Station *> station_list = file->read_file_to_station_list();
	vector<Station *> sorted_list = file->read_file_to_station_list();
	std::sort(sorted_list.begin(), sorted_list.end(), sort_by_name);
//	print_all(sorted_list, station_list);

//	search_by_keyword(sorted_list, station_list);
//	mode_selection(sorted_list, station_list);
	//test section

	node<int> *_node = new node<int>();
//	cout<<sorted_list[0]->get_station_index()<<endl;
	_node->data = sorted_list[0]->get_station_index();
	AVL<int> *tree = new AVL<int>(_node); //new binary_tree<int>(_node);

	for(vector<Station *>::iterator it = sorted_list.begin() + 1;it != sorted_list.end();++it){
		bool b_return = tree->insert((*it)->get_station_index());
//		cout<<(*it)->get_station_index()<<"  "<<b_return<<endl;
	}
	cout<<"done!"<<endl;
//	tree->traverse_inorder(tree->root);
	cout<<"Tree height is "<<tree->tree_height<<endl;
	node<int> *returned_node = tree->search(0);
	cout<<returned_node->data<<" "<<returned_node->height<<endl;
	node<int> *rhs = tree->root;
//	cout<<rhs->data<<" "<<rhs->height<<endl;
	rhs = rhs->rhs;
	node<int> min, max;
//	cout<<"d 1"<<endl;
	tree->find_min_from(rhs, min);
//	cout<<"d 2"<<endl;
	tree->find_max_from((tree->root)->lhs, max);
	cout<<"min in right branch is "<<min.data<<" "<<min.height<<endl;
	cout<<"max in left branch is "<<max.data<<" "<<max.height<<endl;

	cout<<"depth is "<<tree->find_depth(tree->root)<<endl;
	cout<<"left branch depth is "<<tree->find_depth((tree->root)->lhs)<<endl;
	cout<<"right branch depth is "<<tree->find_depth((tree->root)->rhs)<<endl;
	cout<<"balance factor is "<<tree->balance_factor(tree->root)<<endl;
	cout<<"tree is balanced? "<<tree->is_balanced(tree->root)<<endl;

	cout<<"tree root "<<(tree->root)->data<<endl;
//	delete[] tree->root;
	delete tree;
	return 0;
}
//----------------------------------------------------------------------------
void VertexBufferAccessor::Write (FileIO& outFile)
{
	assertion(mStride == mVBuffer->GetElementSize(),
		"Format stride and vertex size must match (for now).\n");

	// 为VertexBuffer的顶点属性建立一张表。每个顶点的属性都有offset,属性元素字
	// 节大小以及属性元素个数。举例来说,一个元素属性的offset为0,格式为AT_FLOAT3
	// 具有的(offset,size,numComponents) = (0,4,3)。
	Tuple<3, unsigned int> table[VertexFormat::AM_MAX_ATTRIBUTES];
	const int numAttributes = mVFormat->GetNumAttributes();
	unsigned int streamIndex, offset, index;
	VertexFormat::AttributeType type;
	VertexFormat::AttributeUsage usage;
	int j;
	for (j = 0; j < numAttributes; ++j)
	{
		mVFormat->GetAttribute(j, streamIndex, offset, type, usage, index);
		table[j][0] = offset;
		table[j][1] = VertexFormat::GetComponentSize(type);
		table[j][2] = VertexFormat::GetNumComponents(type);
	}

	// 将顶点持久化
	const int numElements = mVBuffer->GetNumElements();
	char* vertex = mData;
	for (int i = 0; i < numElements; ++i, vertex += mStride)
	{
		for (j = 0; j < numAttributes; ++j)
		{
			outFile.Write(table[j][1], table[j][2], vertex + table[j][0]);
		}
	}
}
//----------------------------------------------------------------------------
void VertexBufferAccessor::Write (FileIO& outFile)
{
	assertion(mStride == mVBuffer->GetElementSize(),
	          "Format stride and vertex size must match (for now).\n");

	// Build a table for the attributes of the vertex buffer.  Each attribute
	// has an offset, a size for a component of the attribute, and the number
	// of components of that size.  For example, an attribute with offset 0
	// and type AT_FLOAT3 has (offset,size,numComponents) = (0,4,3).
	Tuple<3, unsigned int> table[VertexFormat::AM_MAX_ATTRIBUTES];
	const int numAttributes = mVFormat->GetNumAttributes();
	unsigned int streamIndex, offset, index;
	VertexFormat::AttributeType type;
	VertexFormat::AttributeUsage usage;
	int j;
	for (j = 0; j < numAttributes; ++j)
	{
		mVFormat->GetAttribute(j, streamIndex, offset, type, usage, index);
		table[j][0] = offset;
		table[j][1] = VertexFormat::GetComponentSize(type);
		table[j][2] = VertexFormat::GetNumComponents(type);
	}

	// Write vertices one at a time to allow for byte swapping (endianness).
	const int numElements = mVBuffer->GetNumElements();
	char* vertex = mData;
	for (int i = 0; i < numElements; ++i, vertex += mStride)
	{
		for (j = 0; j < numAttributes; ++j)
		{
			outFile.Write(table[j][1], table[j][2], vertex + table[j][0]);
		}
	}
}
示例#24
0
/**
*    getZValues
*    Obtain the values for fov and zmax/zmin.
*    Preconditions:
*        The filename to read from.
*        The array to store the information.
*    Postconditions:
*        The array is filled:
*            0 - fov
*            1 - zmax
*            2 - zmin
*/
void Picture::getZValues( char* fileName, double zs[] )
{
   FileIO* inputFile = new FileIO(fileName, 1);  //for reading

   //eye vertex
   string line = inputFile->readLine();  //skip this line
   line = inputFile->readLine();
   zs[0] = atof(line.c_str());
   line = inputFile->readLine();
   line = inputFile->readLine();
   zs[1] = atof(line.c_str());
   line = inputFile->readLine();
   line = inputFile->readLine();
   zs[2] = atof(line.c_str());
  
   delete inputFile;
}
GLuint Renderer::compileShaders(const char* code, GLenum shaderType){
	GLuint ret = 0;
	ret = glCreateShader(shaderType);
	FileIO file;
	file;

	const char* adapt[1];
	std::string temp(file.file2String(code));

	adapt[0] = temp.c_str();
	glShaderSource(ret, 1, adapt, 0);

	glCompileShader(ret);
	checkCompileStatuts(ret);

	return ret;
}
示例#26
0
//----------------------------------------------------------------------------
void Visual::SaveVertexFormat (FileIO& outFile)
{
    int numAttributes = mVFormat->GetNumAttributes();
    outFile.Write(sizeof(int), &numAttributes);

    for (int i = 0; i < numAttributes; ++i)
    {
        unsigned int streamIndex, offset, usageIndex;
        VertexFormat::AttributeType vftype;
        VertexFormat::AttributeUsage vfusage;
        mVFormat->GetAttribute(i, streamIndex, offset, vftype, vfusage,
                               usageIndex);
        int type = (int)vftype;
        int usage = (int)vfusage;

        outFile.Write(sizeof(unsigned int), &streamIndex);
        outFile.Write(sizeof(unsigned int), &offset);
        outFile.Write(sizeof(int), &type);
        outFile.Write(sizeof(int), &usage);
        outFile.Write(sizeof(unsigned int), &usageIndex);
    }

    int stride = mVFormat->GetStride();
    outFile.Write(sizeof(int), &stride);
}
示例#27
0
/**
 * Saves the board to a file
 *
 * @param fname
 *  Name of file to save to
 * @return
 *  True if board is successfully saved
 */
bool Board::Export(const string & fname) const {
    FileIO file;

    FILEIO_TABLE table;
    for (int i = 0; i < 9; ++i) {
        FILEIO_ROW row;
        for (int j = 0; j < 9; ++j) {
            char s[2]; // Because it needs to be added as a char*
            s[0] = m_board[j][i] + '0';
            s[1] = '\0';
            row.push_back(s); // Fill a row
        }
        table.push_back(row); // Add the row to the table w're going to save
    }

    file.SetFileName(fname); // Prepare FileIO object for saving.
    file.SetTable(table);

    return file.Save(); // Save returns true if all is successful.
}
示例#28
0
文件: diskmgr.cpp 项目: pololei/m88
// ---------------------------------------------------------------------------
//	UpdateDrive
//
void DiskManager::UpdateDrive(Drive* drv)
{
	if (!drv->holder || drv->sizechanged)
		return;

	CriticalSection::Lock lock(cs);
	int t;
	for (t=0; t<164 && !drv->modified[t]; t++)
		;
	if (t < 164)
	{
		FileIO* fio = drv->holder->GetDisk(drv->index);
		if (fio)
		{
			for (; t<164; t++)
			{
				if (drv->modified[t])
				{
					FloppyDisk::Sector* sec;
					int tracksize = 0;
					
					for (sec = drv->disk.GetFirstSector(t); sec; sec=sec->next)
						tracksize += sec->size + sizeof(SectorHeader);
					
					if (tracksize <= drv->tracksize[t])
					{
						drv->modified[t] = false;
						fio->Seek(drv->trackpos[t], FileIO::begin);
						WriteTrackImage(fio, drv, t);
					}
					else
					{
						drv->sizechanged = true;
						break;
					}
				}
			}
		}
	}
}
示例#29
0
 void HMM::load_parameters(std::string filename) {
     FileIO fio;
     FILE* fp = fopen(filename.c_str(), "r");
     assert(fp);
     
     uint32_t hs_ {0};
     fio.readUInt32(fp, &hs_);
     hs = (int)hs_;
     
     uint32_t os_ {0};
     fio.readUInt32(fp, &os_);
     os = (int)os_;
     
     allocate_parameters();
     
     fio.readDoubleArray(fp, nu, hs);
     fio.readDoubleArray(fp, Q, hs*hs);
     fio.readDoubleArray(fp, g, hs*os);
     update_log_parameters();
     
     fclose(fp);
 }
示例#30
0
//----------------------------------------------------------------------------
void Visual::SaveIndexBuffer (FileIO& outFile)
{
    if (mIBuffer)
    {
        int numElements = mIBuffer->GetNumElements();
        int elementSize = mIBuffer->GetElementSize();
        Buffer::Usage ibusage = mIBuffer->GetUsage();
        int usage = (int)ibusage;
        int offset = mIBuffer->GetOffset();
        outFile.Write(sizeof(int), &numElements);
        outFile.Write(sizeof(int), &elementSize);
        outFile.Write(sizeof(int), &usage);
        outFile.Write(sizeof(int), &offset);

        outFile.Write(elementSize, mIBuffer->GetNumBytes()/elementSize,
                      mIBuffer->GetData());
    }
    else
    {
        int numElements = 0;
        outFile.Write(sizeof(int), &numElements);
    }
}