本文整理汇总了C++中ReadError函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadError函数的具体用法?C++ ReadError怎么用?C++ ReadError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadError
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: assert
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: assert
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: CorruptError
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: assert
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: ReadDirectory
/*
* 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: ReadError
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: CorruptError
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: inStream
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: read
/**
* 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;
}
示例11: ReadError
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: Assert
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: QMainWindow
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: read
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: Launch
//============================================================================
// 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);
}