예제 #1
0
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;
}
예제 #2
0
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;
}
예제 #3
0
파일: ccObject.cpp 프로젝트: Windlkx/trunk
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);
        }
    }
예제 #4
0
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;
}
예제 #5
0
파일: ccHObject.cpp 프로젝트: vivzqs/trunk
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;
}
예제 #6
0
파일: tiffdump.c 프로젝트: fleaplus/libtiff
/*
 * Read the next TIFF directory from a file
 * and convert it to the internal format.
 * We read directories sequentially.
 */
static uint64
ReadDirectory(int fd, unsigned int ix, uint64 off)
{
	uint16 dircount;
	uint32 direntrysize;
	void* dirmem = NULL;
	uint64 nextdiroff = 0;
	uint32 n;
	uint8* dp;

	if (off == 0)			/* no more directories */
		goto done;
	if (_TIFF_lseek_f(fd, (_TIFF_off_t)off, SEEK_SET) != (_TIFF_off_t)off) {
		Fatal("Seek error accessing TIFF directory");
		goto done;
	}
	if (!bigtiff) {
		if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) {
			ReadError("directory count");
			goto done;
		}
		if (swabflag)
			TIFFSwabShort(&dircount);
		direntrysize = 12;
	} else {
		uint64 dircount64 = 0;
		if (read(fd, (char*) &dircount64, sizeof (uint64)) != sizeof (uint64)) {
			ReadError("directory count");
			goto done;
		}
		if (swabflag)
			TIFFSwabLong8(&dircount64);
		if (dircount64>0xFFFF) {
			Error("Sanity check on directory count failed");
			goto done;
		}
		dircount = (uint16)dircount64;
		direntrysize = 20;
	}
	dirmem = _TIFFmalloc(TIFFSafeMultiply(tmsize_t,dircount,direntrysize));
	if (dirmem == NULL) {
		Fatal("No space for TIFF directory");
		goto done;
	}
	n = read(fd, (char*) dirmem, dircount*direntrysize);
	if (n != dircount*direntrysize) {
		n /= direntrysize;
		Error(
#if defined(__WIN32__) && defined(_MSC_VER)
	    "Could only read %lu of %u entries in directory at offset %#I64x",
		      (unsigned long)n, dircount, (unsigned __int64) off);
#else
	    "Could only read %lu of %u entries in directory at offset %#llx",
		      (unsigned long)n, dircount, (unsigned long long) off);
#endif
		dircount = n;
		nextdiroff = 0;
	} else {
예제 #7
0
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;
}
예제 #8
0
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;
}
예제 #9
0
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;
}
예제 #10
0
  /**
   * To read data previously serialized on disk.
   */
  void read(std::string dirName, std::string nodeName) {
  	std::string fileName = dirName + nodeName + ".xml";
  	cv::FileStorage fs(fileName, cv::FileStorage::READ);
  	if(!fs.isOpened())
  		throw ReadError("Cannot read file '" + fileName + "'");

  	cv::FileNode node = fs[nodeName];
  	if(node.isNone())
  		throw ReadError("Cannot parse node '" + nodeName + "'");

  	node["cameraMatrix"] >> cameraMatrix;
  	node["distCoeffs"] >> distCoeffs;
  	node["imageSize"] >> imageSize;
  }
void ClusterFileCharacterSource::fillBuffer(void)
	{
	int readSize;
	if(pipe==0||pipe->isMaster())
		{
		/* Read at most one buffer's worth of data from the input file: */
		readSize=int(read(inputFd,buffer,bufferSize));
		if(readSize<0) // That's an error condition
			{
			if(pipe!=0)
				{
				/* Signal the read error to the slaves: */
				pipe->write<int>(-1);
				pipe->finishMessage();
				}
			throw ReadError();
			}
		
		if(pipe!=0)
			{
			/* Send the read buffer to the slaves: */
			pipe->write<int>(readSize);
			pipe->write<unsigned char>(buffer,readSize);
			pipe->finishMessage();
			}
		}
	else
		{
		/* Receive the size of the read data from the master: */
		readSize=pipe->read<int>();
		if(readSize<0) // That's an error condition
			throw ReadError();
		
		/* Receive the read buffer: */
		pipe->read<unsigned char>(buffer,readSize);
		}
	
	/* Check if the end of file has been read: */
	if(size_t(readSize)<bufferSize)
		{
		/* Set the buffer end pointer and the EOF pointer to the shortened content: */
		bufferEnd=buffer+readSize;
		eofPtr=bufferEnd;
		}
	
	/* Reset the read pointer: */
	rPtr=buffer;
	}
예제 #12
0
void SF2Reader::readExpect(const char* tag) {
    Assert(std::strlen(tag)==4);
    char tmp[4];
    readBytes(tmp, 4);
    if(memcmp(tmp, tag, 4)!=0)
        throw ReadError(std::string("expected ")+tag);
}
예제 #13
0
파일: mainwindow.cpp 프로젝트: pjh130/qt
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    tcpClient = new QTcpSocket(this);
    ui->pushSent->setEnabled(false);
    this->ui->timeBut->setEnabled(false);
    tcpClient->abort();
    connect(tcpClient,&QTcpSocket::readyRead,
            [&](){this->ui->textEdit->append(tr("%1 Server Say:%2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(QString(this->tcpClient->readAll())));});
    connect(tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(ReadError(QAbstractSocket::SocketError)));
    connect(&tm,&QTimer::timeout,[&](){
            int i = qrand() % 6;
            this->ui->textEdit->append(tr("%1 Timer Sent: %2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(list.at(i)));
            tcpClient->write(list.at(i).toUtf8());
    });
    connect(tcpClient,&QTcpSocket::disconnected,[](){qDebug()<< "123333" ;});
    list << "我是谁?" << "渡世白玉" << "hello" << "哈哈哈哈哈" << "你是坏蛋!" <<  "测试一下下了" << "不知道写什么" ;
    QTime time;
    time= QTime::currentTime();
    qsrand(time.msec()+time.second()*1000);
    this->ui->txtIp->setText("127.0.0.1");
    this->ui->txtPort->setText("6666");
}
예제 #14
0
void BinaryDataHandler::readBuffer(void)
{
    BuffersT::iterator i;
    UInt32             size,nsize;
    UInt32             readSize;

    // read buffer size
    read(reinterpret_cast<MemoryHandle>(&nsize), sizeof(UInt32));
    size = osgntohl(nsize);

    // read rest of buffer
    for(i = readBufBegin(); size != 0; ++i)
    {
        if(i == readBufEnd())
        {
            SFATAL << "Read buffer is to small. " << size
                   << "bytes missing" << std::endl;

            throw ReadError("Read buffer to small for whole block");
        }

        readSize = osgMin(size, i->getSize());

        read(i->getMem(), readSize);

        i->setDataSize(readSize);

        size -= readSize;
    }

    for(; i != readBufEnd(); ++i)
    {
        i->setDataSize(0);
    }
}
예제 #15
0
파일: NTask.cpp 프로젝트: x414e54/nano
//============================================================================
//		NTask::Execute : Execute the task.
//----------------------------------------------------------------------------
NString NTask::Execute(NTime waitFor)
{	NString		theResult;
	NTime		endTime;
	NStatus		theErr;



	// Get the state we need
	endTime = NTimeUtilities::GetTime() + waitFor;



	// Execute the command
	theErr = Launch();
	NN_ASSERT_NOERR(theErr);



	// Wait for the results
	while (IsRunning())
		{
		if (waitFor >= kNTimeNone && NTimeUtilities::GetTime() >= endTime)
			break;

		UpdateTask(kTaskSleep);
		}

	theResult = ReadOutput() + ReadError();

	return(theResult);
}
예제 #16
0
bool ccImage::fromFile_MeOnly(QFile& in, short dataVersion, int flags)
{
	if (!ccHObject::fromFile_MeOnly(in, dataVersion, flags))
		return false;

	//as the associated sensor can't be saved directly (as it may be shared by multiple images)
	//we only store its unique ID (dataVersion >= 38) --> 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 sensorUniqueID = 0;
	if (in.read((char*)&sensorUniqueID,4) < 0)
		return ReadError();
	//[DIRTY] WARNING: temporarily, we set the vertices unique ID in the 'm_associatedCloud' pointer!!!
	*(uint32_t*)(&m_associatedSensor) = sensorUniqueID;

	QDataStream inStream(&in);
	inStream >> m_width;
	inStream >> m_height;
	inStream >> m_aspectRatio;
	inStream >> m_texU;
	inStream >> m_texV;
	inStream >> m_texAlpha;
	inStream >> m_image;
#ifdef INCLUDE_IMAGE_FILENAME
	inStream >> m_completeFileName;
#else
	QString fakeString;
	inStream >> fakeString;
#endif

	return true;
}
예제 #17
0
파일: tcpsocket.cpp 프로젝트: pjh130/qt
TcpSocket::TcpSocket(QObject *parent) :
    QTcpSocket(parent)
{
    connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(ReadError(QAbstractSocket::SocketError)));
    connect(this,&TcpSocket::readyRead,[&](){QString str(QString::number(this->peerPort())); str += " : ";
    str += this->readAll(); emit this->sentdata(str);});
}
예제 #18
0
파일: Endpoint.cpp 프로젝트: jvanns/oodles
void
Endpoint::raw_recv_callback(const error_code& e, size_t b)
{
    recv_guard.unlock();
    
    if (!e && b > 0) {
        size_t n = inbound.producer().commit_buffer(b),
               u = protocol->buffer2message(inbound.consumer().data(), n);
        
        n = inbound.consumer().consume_buffer(u);
        protocol->handle_messages(dispatcher);
        
        /*
         * Re-register any further reads and update running statistics
         */
        protocol->receive_data();
        recv_rate.update(b);
    } else {
        if (e == boost::asio::error::operation_aborted)
            return;
        
        stop();
    
        if (e != boost::asio::error::eof)
            throw ReadError("Endpoint::raw_recv_callback",
                            e.value(),
                            e.message().c_str());
    }
}
예제 #19
0
std::pair<char,bool> SerialPort::readByteNonBlocking(void)
	{
	char readByte;
	ssize_t bytesReceived=read(port,&readByte,1);
	if(bytesReceived<0&&errno!=EAGAIN)
		throw ReadError();
	return std::pair<char,bool>(readByte,bytesReceived==1);
	}
예제 #20
0
void SF2Reader::readList(SimpleArray<T, E>& a, const chunkHeader& h) {
    size_t n = h.chunkSize;
    if(n%sizeof(T)!=0)
        throw ReadError("list "+std::string(h.chunkId, 4)+" not a multiple of record size");
    Assert(n/sizeof(T)>=E);
    a.resize(n/sizeof(T)-E);
    readArray(a.begin(), a.size()+E);
}
예제 #21
0
DataList Base::parseFile(QString const& fileName)
{
   QFile file(fileName);
   if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) throw ReadError();
   QTextStream textStream(&file);
   parse(textStream);
   file.close();
   return m_dataList;
}
예제 #22
0
  // --------------------------
  // Null_IO::getVolumeFileInfo
  // --------------------------
  // Purpose:
  //   Throws an error since this class is not intended for actual IO.
  // ---- Change History ----
  // 12/04/2009 -- Joe R. -- Initial implementation.
  void Null_IO::getVolumeFileInfo(VolumeFileInfo::Data& /*data*/,
				  const std::string& /*filename*/) const
  {
    throw ReadError(
      boost::str(
	boost::format("%1% unimplemented") % BOOST_CURRENT_FUNCTION
      )
    );
  }
예제 #23
0
size_t SerialPort::readBytesRaw(size_t maxNumBytes,char* bytes)
	{
	ssize_t bytesRead=read(port,bytes,maxNumBytes);
	if(bytesRead>=0)
		return bytesRead;
	else if(errno==EAGAIN)
		return 0;
	else
		throw ReadError();
	}
예제 #24
0
uint8_t Icom::Controller::get() const
{
    uint8_t x;
    ssize_t n=0;
    while(n==0)
        n = read(m_fd, &x, 1);
    if(n < 0)
        throw ReadError();
    return x;
}
예제 #25
0
void SF2Reader::readSdtaList() {
    chunkHeader listHeader;
    read(listHeader);
    if( listHeader.id()!=ChunkId::LIST )
        throw ReadError("sdta must be LIST");
    if( listHeader.chunkSize<=4 )
        throw ReadError("sdta too short");
    readExpect("sdta");
    chunkHeader smplHeader;
    read(smplHeader);
    if( smplHeader.id()!=ChunkId::smpl )
        throw ReadError("smpl subchunk expected");
    myBank->samples.resize(smplHeader.chunkSize/2);
    readArray(myBank->samples.begin(),myBank->samples.size());
    if( size_t m = listHeader.chunkSize-4-8-smplHeader.chunkSize ) {
        // FIXME - use 24-bit data
        skip(m);
    }
}
예제 #26
0
파일: reader.cpp 프로젝트: RayHuo/iASP
Input::Format detectFormat(std::istream& in) {
	std::istream::int_type x = in.peek();
	if (x != std::char_traits<char>::eof()) {
		unsigned char c = static_cast<unsigned char>(x);
		if (c >= '0' && c <= '9') return Input::SMODELS;
		if (c == 'c' || c == 'p') return Input::DIMACS;
		if (c == '*')             return Input::OPB;
	}
	throw ReadError(1, "Unrecognized input format!\n");
}
예제 #27
0
int
main(int argc, char *argv[])
{
	SQLINTEGER cnamesize;

	Connect();

	/* issue print statement and test message returned */
	if (CommandWithResult(Statement, "print 'Test message'") != SQL_SUCCESS_WITH_INFO) {
		printf("SQLExecDirect should return SQL_SUCCESS_WITH_INFO\n");
		return 1;
	}
	ReadError();
	if (!strstr((char *) output, "Test message")) {
		printf("Message invalid\n");
		return 1;
	}

	/* issue invalid command and test error */
	if (CommandWithResult(Statement, "SELECT donotexistsfield FROM donotexiststable") != SQL_ERROR) {
		printf("SQLExecDirect returned strange results\n");
		return 1;
	}
	ReadError();

	/* test no data returned */
	if (SQLFetch(Statement) != SQL_ERROR) {
		printf("Row fetched ??\n");
		return 1;
	}
	ReadError();

	if (SQLGetData(Statement, 1, SQL_C_CHAR, output, sizeof(output), &cnamesize) != SQL_ERROR) {
		printf("Data ??\n");
		return 1;
	}
	ReadError();

	Disconnect();

	printf("Done.\n");
	return 0;
}
예제 #28
0
파일: ccSubMesh.cpp 프로젝트: 3660628/trunk
bool ccSubMesh::fromFile_MeOnly(QFile& in, short dataVersion, int flags)
{
	if (!ccGenericMesh::fromFile_MeOnly(in, dataVersion, flags))
		return false;

	//as the associated mesh can't be saved directly
	//we only store its unique ID (dataVersion>=29) --> 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 meshUniqueID = 0;
	if (in.read((char*)&meshUniqueID,4) < 0)
		return ReadError();
	//[DIRTY] WARNING: temporarily, we set the mesh unique ID in the 'm_associatedMesh' pointer!!!
	*(uint32_t*)(&m_associatedMesh) = meshUniqueID;

	//references (dataVersion>=29)
	if (!ccSerializationHelper::GenericArrayFromFile(*m_triIndexes,in,dataVersion))
		return ReadError();

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

	//vector size (dataVersion>=34)
	uint32_t count = 0;
	if (in.read((char*)&count,4) < 0)
		return ReadError();

	//try to resize the vector accordingly
	try
	{
		resize(count);
	}
	catch (const std::bad_alloc&)
	{
		//not enough memory
		return MemoryError();
	}

	//transformations (dataVersion>=34)
	for (ccIndexedTransformationBuffer::iterator it=begin(); it!=end(); ++it)
		if (!it->fromFile(in, dataVersion, flags))
			return false;

	//display options
	{
		//Show polyline (dataVersion>=34)
		if (in.read((char*)&m_showAsPolyline,sizeof(bool)) < 0)
			return ReadError();
		//Show trihedrons (dataVersion>=34)
		if (in.read((char*)&m_showTrihedrons,sizeof(bool)) < 0)
			return ReadError();
		//Display scale (dataVersion>=34)
		if (in.read((char*)&m_trihedronsScale,sizeof(float)) < 0)
			return ReadError();
	}

	return true;
}
예제 #30
0
  // -----------------------
  // Null_IO::readVolumeFile
  // -----------------------
  // Purpose:
  //   Throws an error since this class is not intended for actual IO.
  // ---- Change History ----
  // 12/04/2009 -- Joe R. -- Initial implementation.
  void Null_IO::readVolumeFile(Volume& /*vol*/,
			       const std::string& /*filename*/, 
			       unsigned int /*var*/, unsigned int /*time*/,
			       uint64 /*off_x*/, uint64 /*off_y*/, uint64 /*off_z*/,
			       const Dimension& /*subvoldim*/, const CVC::Dimension& maxdim) const
  {
    throw ReadError(
      boost::str(
	boost::format("%1% unimplemented") % BOOST_CURRENT_FUNCTION
      )
    );
  }