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


C++ QFile::read方法代码示例

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


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

示例1: load

/**
 * Load the object data from file.
 * The file is expected to be already open for reading.
 * The data will be read and the file will not be closed.
 * @returns True on success, false on failure
 */
bool UAVObject::load(QFile & file)
{
    QMutexLocker locker(mutex);
    quint8 buffer[numBytes];
    quint8 tmpId[4];

    // Read the object ID
    if (file.read((char *)tmpId, 4) != 4) {
        return false;
    }

    // Check that the IDs match
    if (qFromLittleEndian<quint32>(tmpId) != objID) {
        return false;
    }

    // Read the instance ID
    if (file.read((char *)tmpId, 2) != 2) {
        return false;
    }

    // Check that the IDs match
    if (qFromLittleEndian<quint16>(tmpId) != instID) {
        return false;
    }

    // Read and unpack the data
    if (file.read((char *)buffer, numBytes) != numBytes) {
        return false;
    }
    unpack(buffer);

    // Done
    return true;
}
开发者ID:MarcProe,项目名称:LibrePilot,代码行数:41,代码来源:uavobject.cpp

示例2: fromFile

bool ccObject::fromFile(QFile& in, short dataVersion)
{
	assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));

	if (dataVersion<20)
		return CorruptError();

	//DGM: if we are here, we assume the class ID has already been read!
	//Call ccObject::readClassIDFromFile if necessary
	////class ID (dataVersion>=20)
	//uint32_t classID = 0;
	//if (in.read((char*)&classID,4)<0)
	//	return ReadError();

	//unique ID (dataVersion>=20)
	//DGM: this ID will be usefull to recreate dynamic links between entities!
	uint32_t uniqueID = 0;
	if (in.read((char*)&uniqueID,4)<0)
		return ReadError();
	m_uniqueID = (unsigned)uniqueID;

	//name (dataVersion>=20)
	if (in.read(m_name,256)<0)
		return ReadError();

	//flags (dataVersion>=20)
	uint32_t flags = 0;
	if (in.read((char*)&flags,4)<0)
		return ReadError();
	m_flags = (unsigned)flags;

	return true;
}
开发者ID:whatnick,项目名称:CloudCompare,代码行数:33,代码来源:ccObject.cpp

示例3: load

void QAniTransferFunctionInstance::load(QFile & file) {
	file.read((char *)&m_resolution, 4);
	file.read((char *)&m_tfResolutionChange, 4);
	m_tfDrawArrayChange = new float[m_resolution];
	file.read((char *)m_tfDrawArrayChange, 4 * m_resolution);

	int size;
	file.read((char *)&size, 4);
	for (int i = 0; i < size; ++i) {
		double mean,sigma,height;
		file.read((char *)&mean, 8);
		file.read((char *)&sigma, 8);
		file.read((char *)&height, 8);
		GaussianObjectChange goc(mean, sigma, height);
		m_gaussianObjectChange.push_back(goc);
	}
	file.read((char *)&size, 4);
	for (int i = 0; i < size; ++i) {
		float x;
		Vector4 color;
		file.read((char *)&x, 4);
		file.read((char *)((double*)color), 32);
		ColorTickChange ctc(x, color);
		m_tfColorTickChange.push_back(ctc);
	}
}
开发者ID:gnavvy,项目名称:Paraft,代码行数:26,代码来源:QAniInstance.cpp

示例4: fromFile_MeOnly

bool ccGenericPointCloud::fromFile_MeOnly(QFile& in, short dataVersion)
{
	if (!ccHObject::fromFile_MeOnly(in, dataVersion))
		return false;

	if (dataVersion<20)
		return CorruptError();

	//'coordinates shift' (dataVersion>=20)
	if (in.read((char*)m_originalShift,sizeof(double)*3)<0)
		return ReadError();

	//'visibility' array (dataVersion>=20)
	bool hasVisibilityArray = false;
	if (in.read((char*)&hasVisibilityArray,sizeof(bool))<0)
		return ReadError();
	if (hasVisibilityArray)
	{
		if (!m_visibilityArray)
		{
			m_visibilityArray = new VisibilityTableType();
			m_visibilityArray->link();
		}
		if (!ccSerializationHelper::GenericArrayFromFile(*m_visibilityArray,in,dataVersion))
		{
			unallocateVisibilityArray();
			return false;
		}
	}

	return true;
}
开发者ID:whatnick,项目名称:CloudCompare,代码行数:32,代码来源:ccGenericPointCloud.cpp

示例5: fromFile_MeOnly

bool ccGenericMesh::fromFile_MeOnly(QFile& in, short dataVersion, int flags)
{
	if (!ccHObject::fromFile_MeOnly(in, dataVersion, flags))
		return false;

	//'show wired' state (dataVersion>=20)
	if (in.read((char*)&m_showWired,sizeof(bool))<0)
		return ReadError();

	//'per-triangle normals shown' state (dataVersion>=29))
	if (dataVersion >= 29)
	{
		if (in.read((char*)&m_triNormsShown,sizeof(bool))<0)
			return ReadError();

		//'materials shown' state (dataVersion>=29))
		if (in.read((char*)&m_materialsShown,sizeof(bool))<0)
			return ReadError();

		//'polygon stippling' state (dataVersion>=29))
		if (in.read((char*)&m_stippling,sizeof(bool))<0)
			return ReadError();
	}

	return true;
}
开发者ID:Aerochip7,项目名称:trunk,代码行数:26,代码来源:ccGenericMesh.cpp

示例6: fromFile

bool ccObject::fromFile(QFile& in, short dataVersion, int flags)
{
    assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));

    if (dataVersion<20)
        return CorruptError();

    //DGM: if we are here, we assume the class ID has already been read!
    //Call ccObject::readClassIDFromFile if necessary
    ////class ID (dataVersion>=20)
    //uint32_t classID = 0;
    //if (in.read((char*)&classID,4) < 0)
    //	return ReadError();

    //unique ID (dataVersion>=20)
    //DGM: this ID will be usefull to recreate dynamic links between entities!
    uint32_t uniqueID = 0;
    if (in.read((char*)&uniqueID,4) < 0)
        return ReadError();
    m_uniqueID = (unsigned)uniqueID;

    //name
    if (dataVersion < 22) //old style
    {
        char name[256];
        if (in.read(name,256) < 0)
            return ReadError();
        setName(name);
    }
    else //(dataVersion>=22)
    {
        QDataStream inStream(&in);
        inStream >> m_name;
    }

    //flags (dataVersion>=20)
    uint32_t objFlags = 0;
    if (in.read((char*)&objFlags,4) < 0)
        return ReadError();
    m_flags = (unsigned)objFlags;

    //meta data (dataVersion>=30)
    if (dataVersion >= 30)
    {
        //count
        uint32_t metaDataCount = 0;
        if (in.read((char*)&metaDataCount,4) < 0)
            return ReadError();

        //"key + value" pairs
        for (uint32_t i=0; i<metaDataCount; ++i)
        {
            QDataStream inStream(&in);
            QString key;
            QVariant value;
            inStream >> key;
            inStream >> value;
            setMetaData(key,value);
        }
    }
开发者ID:Windlkx,项目名称:trunk,代码行数:60,代码来源:ccObject.cpp

示例7: fromFile

bool ccHObject::fromFile(QFile& in, short dataVersion)
{
    assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));

    //read 'ccObject' header
    if (!ccObject::fromFile(in,dataVersion))
        return false;

    //read own data
    if (!fromFile_MeOnly(in,dataVersion))
        return false;

    //(serializable) child count (dataVersion>=20)
    uint32_t serializableCount = 0;
    if (in.read((char*)&serializableCount,4)<0)
        return ReadError();

    //read serializable children (if any)
    for (uint32_t i=0; i<serializableCount; ++i)
    {
        //read children class ID
        unsigned classID=0;
        if (!ReadClassIDFromFile(classID, in, dataVersion))
            return false;

        //create corresponding child object
        ccHObject* child = New(classID);
        assert(child && child->isSerializable());
        if (child)
        {
            if (child->fromFile(in,dataVersion))
            {
                addChild(child,child->getFlagState(CC_FATHER_DEPENDANT));
            }
            else
            {
                delete child;
                return false;
            }
        }
        else
        {
            return CorruptError();
        }
    }

    //write current selection behavior (dataVersion>=23)
    if (dataVersion>=23)
    {
        if (in.read((char*)&m_selectionBehavior,sizeof(SelectionBehavior))<0)
            return ReadError();
    }
    else
    {
        m_selectionBehavior = SELECTION_AA_BBOX;
    }

    return true;
}
开发者ID:vivzqs,项目名称:trunk,代码行数:59,代码来源:ccHObject.cpp

示例8: fromFile_MeOnly

bool ccPolyline::fromFile_MeOnly(QFile& in, short dataVersion, int flags)
{
	if (!ccHObject::fromFile_MeOnly(in, dataVersion, flags))
		return false;

	if (dataVersion<28)
		return false;

	//as the associated cloud (=vertices) can't be saved directly (as it may be shared by multiple polylines)
	//we only store its unique ID (dataVersion>=28) --> we hope we will find it at loading time (i.e. this
	//is the responsibility of the caller to make sure that all dependencies are saved together)
	uint32_t vertUniqueID = 0;
	if (in.read((char*)&vertUniqueID,4) < 0)
		return ReadError();
	//[DIRTY] WARNING: temporarily, we set the vertices unique ID in the 'm_associatedCloud' pointer!!!
	*(uint32_t*)(&m_theAssociatedCloud) = vertUniqueID;

	//number of points (references to) (dataVersion>=28)
	uint32_t pointCount = 0;
	if (in.read((char*)&pointCount,4) < 0)
		return ReadError();
	if (!reserve(pointCount))
		return false;

	//points (references to) (dataVersion>=28)
	for (uint32_t i=0; i<pointCount; ++i)
	{
		uint32_t pointIndex = 0;
		if (in.read((char*)&pointIndex,4) < 0)
			return ReadError();
		addPointIndex(pointIndex);
	}

	QDataStream inStream(&in);

	//Closing state (dataVersion>=28)
	inStream >> m_isClosed;

	//RGB Color (dataVersion>=28)
	inStream >> m_rgbColor[0];
	inStream >> m_rgbColor[1];
	inStream >> m_rgbColor[2];

	//2D mode (dataVersion>=28)
	inStream >> m_mode2D;

	//Foreground mode (dataVersion>=28)
	inStream >> m_foreground;

	//Width of the line (dataVersion>=31)
	if (dataVersion >= 31)
		ccSerializationHelper::CoordsFromDataStream(inStream,flags,&m_width,1);
	else
		m_width = 0;

	return true;
}
开发者ID:gadomski,项目名称:cloudcompare-trunk,代码行数:57,代码来源:ccPolyline.cpp

示例9: fromFile_MeOnly

bool ccGenericPointCloud::fromFile_MeOnly(QFile& in, short dataVersion, int flags)
{
	if (!ccHObject::fromFile_MeOnly(in, dataVersion, flags))
		return false;

	if (dataVersion < 20)
		return CorruptError();

	if (dataVersion < 33)
	{
		//'coordinates shift' (dataVersion>=20)
		if (in.read((char*)m_globalShift.u,sizeof(double)*3) < 0)
			return ReadError();

		m_globalScale = 1.0;
	}
	else
	{
		//'global shift & scale' (dataVersion>=33)
		if (!loadShiftInfoFromFile(in))
			return ReadError();
	}

	//'visibility' array (dataVersion>=20)
	bool hasVisibilityArray = false;
	if (in.read((char*)&hasVisibilityArray,sizeof(bool)) < 0)
		return ReadError();
	if (hasVisibilityArray)
	{
		if (!m_pointsVisibility)
		{
			m_pointsVisibility = new VisibilityTableType();
			m_pointsVisibility->link();
		}
		if (!ccSerializationHelper::GenericArrayFromFile(*m_pointsVisibility,in,dataVersion))
		{
			unallocateVisibilityArray();
			return false;
		}
	}

	//'point size' (dataVersion>=24)
	if (dataVersion >= 24)
	{
		if (in.read((char*)&m_pointSize,1) < 0)
			return WriteError();
	}
	else
	{
		m_pointSize = 0; //= follows default setting
	}

	return true;
}
开发者ID:LiuZhuohao,项目名称:trunk,代码行数:54,代码来源:ccGenericPointCloud.cpp

示例10: loadShiftInfoFromFile

bool ccShiftedObject::loadShiftInfoFromFile(QFile& in)
{
	//'coordinates shift'
	if (in.read((char*)m_globalShift.u,sizeof(double)*3) < 0)
		return ccSerializableObject::ReadError();
	//'global scale'
	if (in.read((char*)&m_globalScale,sizeof(double)) < 0)
		return ccSerializableObject::ReadError();

	return true;
}
开发者ID:MrCairo90,项目名称:CloudCompare,代码行数:11,代码来源:ccShiftedObject.cpp

示例11: fromFile

bool ccColorScale::fromFile(QFile& in, short dataVersion, int flags)
{
	if (dataVersion < 27) //structure appeared at version 27!
		return false;
	
	QDataStream inStream(&in);

	//name (dataVersion>=27)
	inStream >> m_name;

	//UUID (dataVersion>=27)
	inStream >> m_uuid;

	//relative state (dataVersion>=27)
	if (in.read((char*)&m_relative,sizeof(bool)) < 0)
		return ReadError();

	//Absolute min value (dataVersion>=27)
	if (in.read((char*)&m_absoluteMinValue,sizeof(double)) < 0)
		return ReadError();
	//Absolute range (dataVersion>=27)
	if (in.read((char*)&m_absoluteRange,sizeof(double)) < 0)
		return ReadError();

	//locked state (dataVersion>=27)
	if (in.read((char*)&m_locked,sizeof(bool)) < 0)
		return ReadError();

	//steps list (dataVersion>=27)
	{
		//steps count
		uint32_t stepCount = 0;
		if (in.read((char*)&stepCount,4) < 0)
			return ReadError();

		//read each step
		m_steps.clear();
		for (uint32_t i=0; i<stepCount; ++i)
		{
			double relativePos = 0.0;
			QColor color(Qt::white);
			inStream >> relativePos;
			inStream >> color;

			m_steps.push_back(ccColorScaleElement(relativePos,color));
		}

		update();
	}

	return true;
}
开发者ID:fredericoal,项目名称:trunk,代码行数:52,代码来源:ccColorScale.cpp

示例12: readMatrix

bool Matrix::readMatrix(QFile &file)
{
	releaseData();
	file.read((char *)&nRow,sizeof(int));
	file.read((char *)&nCol,sizeof(int));
	if(nRow*nCol>0)
	{
		allocate(nRow,nCol);
		if(file.read((char *)pData,sizeof(double)*nRow*nCol)!=sizeof(double)*nRow*nCol)
			return false;
	}
	return true;
}
开发者ID:MarcBS,项目名称:Motion_Video_Segmentation,代码行数:13,代码来源:Matrix.cpp

示例13: skipUselessChucks

void skipUselessChucks( WavFileHeader& header, QFile& file )
{
    // We only care about the 'data' chuck
    while ( memcmp( header.dataChuckID, "data", 4 ) != 0 )
    {
        int skipByteCount = header.dataSize;
        std::vector<char> skipData( skipByteCount );
        file.read( skipData.data(), skipByteCount );

        file.read( (char*)&header.dataChuckID, 4 );
        file.read( (char*)&header.dataSize, 4 );
    }
}
开发者ID:linganesan,项目名称:pencil,代码行数:13,代码来源:movieexporter.cpp

示例14: readVector

bool Vector::readVector(QFile &file)
{
	releaseData();
	file.read((char *)&nDim,sizeof(int));
	if(nDim<0)
		return false;
	if(nDim>0)
	{
		allocate(nDim);
		if(file.read((char *)pData,sizeof(double)*nDim)!=sizeof(double)*nDim)
			return false;
	}
	return true;
}
开发者ID:MarcBS,项目名称:Motion_Video_Segmentation,代码行数:14,代码来源:Vector.cpp

示例15: read_MAT_MAPNAME_chunk

QString read_MAT_MAPNAME_chunk( QFile &src )
{
    TA3D_3DS_CHUNK_DATA chunk;
	src.read( (char*)&chunk.ID, 2 );
	src.read( (char*)&chunk.length, 4 );
    switch( chunk.ID )
    {
    case MAT_MAPNAME:
        return read_ASCIIZ( src );
    default:
		src.read( chunk.length - 6 );
    };
    return NULL;
}
开发者ID:joaocc,项目名称:ta3d-git,代码行数:14,代码来源:3ds.cpp


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