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


C++ readBuffer函数代码示例

本文整理汇总了C++中readBuffer函数的典型用法代码示例。如果您正苦于以下问题:C++ readBuffer函数的具体用法?C++ readBuffer怎么用?C++ readBuffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: readBuffer

qint64 Downloader::read(char* data, qint64 maxlen)
{
    qint64 len = 0;
    mutex_.lock();
    if (!stream_.icy_meta_data || stream_.icy_metaint == 0)
    {
        len = readBuffer(data, maxlen);
    }
    else
    {
        qint64 nread = 0;
        qint64 to_read;
        while (maxlen > nread && stream_.buf_fill > nread)
        {
            to_read = qMin<qint64>(stream_.icy_metaint - meta_count_, maxlen - nread);
            //to_read = (maxlen - nread);
            qint64 res = readBuffer(data + nread, to_read);
            nread += res;
            meta_count_ += res;
            if (meta_count_ == stream_.icy_metaint)
            {
                meta_count_ = 0;
                mutex_.unlock();
                readICYMetaData();
                mutex_.lock();
            }

        }
        len = nread;

    }
    mutex_.unlock();
    return len;
}
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:34,代码来源:downloader.cpp

示例2: switch

void RecorderClient::react( Event e )
{
    EString tmp;
    switch( e ) {
    case Read:
        tmp = readBuffer()->string( readBuffer()->size() );
        d->toClient.append( tmp );
        d->server->enqueue( tmp );
        readBuffer()->remove( tmp.length() );
        if ( d->toClient.find( '\n' ) )
            d->dump( RecorderData::ToServer );
        break;
    case Close:
        d->dump( RecorderData::ToServer );
        d->dump( RecorderData::ToClient );
        d->assertEmpty();
        d->server->close();
        delete d->log;
        d->log = 0;
        break;
    default:
        {
            // an error of some sort
        }
        break;
    }

}
开发者ID:aox,项目名称:aox,代码行数:28,代码来源:recorder.cpp

示例3: readBuffer

int8 RingBuffer::read(uint8 *dat)
{
    uint32 bufsize = 0;
    uint32 tmprp = 0;
    
    if (g_wcounter <= (g_rcounter+1))
    {
        tmprp = 0;
    }
    if (checkReadData() < 0)
    {
        return -1;
    }
    g_rcounter++;
    tmprp = readBuffer(sizeof(bufsize), this->m_rp, (uint8 *)&bufsize);
    
    //没到结尾处,直接取
    if (bufsize + this->m_rp < this->m_size)
    {
        std::string ret = std::string(this->m_buffer[tmprp], bufsize);
        dat = (uint8 *)ret.c_str();
        tmprp = (tmprp + bufsize) % this->m_size;
     }
    else
        tmprp = readBuffer(bufsize, tmprp, dat);
    
    setReadPoint(tmprp);
    
    return 0;
}
开发者ID:quinsmpang,项目名称:mlua,代码行数:30,代码来源:RingBuffer.cpp

示例4: writeRegister

OperationResult Enc28j60::receiveFrame(uint8_t* buffer, uint32_t* length)
{
    uint32_t payloadLength = 0;

    if (readRegisterByte(EPKTCNT) > 0)
    {
        writeRegister(ERDPT, nextPacketPtr);

        struct {
            uint16_t nextPacket;
            uint16_t byteCount;
            uint16_t status;
        } receiveHeader;

        // Read the header
        readBuffer((uint8_t*) &receiveHeader, sizeof(receiveHeader));

        // Update the pointer to the next packet
        nextPacketPtr = receiveHeader.nextPacket;

         // Remove the CRC count
        payloadLength = receiveHeader.byteCount - 4;

        // Check for buffer overflow
        if (payloadLength > *length - 1)
        {
            payloadLength = *length - 1;
        }

        // Check for CRC errors
        if ((receiveHeader.status & 0x0080) == 0)
        {
            return ResultError;
        }
        else
        {
            // Copy the packet to the buffer
            readBuffer(buffer, payloadLength);
        }

        // Clear last buffer position
        buffer[payloadLength] = 0;

        // Errata #14: Receive hardware may corrupt receive buffer
        if (nextPacketPtr - 1 > RXSTOP_INIT)
        {
            writeRegister(ERXRDPT, RXSTOP_INIT);
        }
        else
        {
            writeRegister(ERXRDPT, nextPacketPtr - 1);
        }

        // Decrement the number of packets
        writeOperation(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC);
    }

    return ResultSuccess;
}
开发者ID:OsamaWajiha,项目名称:firmware,代码行数:59,代码来源:Enc28j60.cpp

示例5: readBuffer

	void BinaryFileReader::readString(core::stringc &str)
	{
		str = "";
		c8 c;
		readBuffer(&c,sizeof(char));
		while(c != 0)
		{
			str += c;
			readBuffer(&c,sizeof(char));
		}
	}
开发者ID:RealBadAngel,项目名称:irrlicht.netcp,代码行数:11,代码来源:CCSMLoader.cpp

示例6: readBuffer

status_t NuPlayer::GenericSource::seekTo(int64_t seekTimeUs) {
    if (mVideoTrack.mSource != NULL) {
        int64_t actualTimeUs;
        readBuffer(false /* audio */, seekTimeUs, &actualTimeUs);

        seekTimeUs = actualTimeUs;
    }

    if (mAudioTrack.mSource != NULL) {
        readBuffer(true /* audio */, seekTimeUs);
    }

    return OK;
}
开发者ID:3dsfr3ak,项目名称:android_frameworks_av,代码行数:14,代码来源:GenericSource.cpp

示例7: doSyncRead

int MSAConnection::doSyncRead(MSA &result_)
{
  MSBuffer *hb=headBuffer();
  MSBuffer *db=readBuffer();
  int s,n;

  if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return 0;
  if ((s=hb->put()-hb->get())<4)
   {
     if ((n=readTheBuffer(hb,4-s))<0) return 0;
     if((s=hb->put()-hb->get())<4) return 0;
     _bytesToNextMessage=MSA::longAt(hb->get());
   }
  if((n=readTheBuffer(db,_bytesToNextMessage))<0) return 0;
  if((_bytesToNextMessage-=n)==0)
   {
     result_=MSA::importAObject((char *) db->get(), db->put()-db->get(), (char *)0);
     hb->reset();
     db->clear();
     unset(MSProtocolConnection<MSA>::Read);
     if((result_.aStructPtr())==(MSAStruct *)0){resetWithError(MSProtocolConnection<MSA>::Read);return 0;}
   }
  
  return 1;
}
开发者ID:dbremner,项目名称:aplusdev,代码行数:25,代码来源:MSAConnection.C

示例8: getAobjectFromBuffer

MSA MSAConnection::getAobjectFromBuffer(MSBuffer *buf_)
{
  MSBuffer *hb=headBuffer();
  MSBuffer *db=readBuffer();
  int s,n;
  if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return MSA();
  if((s=hb->put()-hb->get())<4)
   {
     if((n=MSBuffer::buffToBuff(buf_,hb,4-s))<0) return MSA();
     if((s=hb->put()-hb->get())<4) return MSA();
     _bytesToNextMessage=MSA::longAt(hb->get());
     if (_bytesToNextMessage<=0) 
      {
	hb->reset();
        unset(MSProtocolConnection<MSA>::Read);
	return MSA();
      }
   }
  if((n=MSBuffer::buffToBuff(buf_,db,_bytesToNextMessage))<0) return MSA();
  if((_bytesToNextMessage-=n)==0)
   {
     MSA d=MSA::importAObject( (char *) db->get(), db->put()-db->get(), (char *)0);
     hb->reset();
     db->clear();
     unset(MSProtocolConnection<MSA>::Read);
     if(d.isNullMSA()==MSTrue)
      {
        resetWithError(MSProtocolConnection<MSA>::Read);return MSA();
      }
     return d;
   }
  return MSA(); 
}
开发者ID:dbremner,项目名称:aplusdev,代码行数:33,代码来源:MSAConnection.C

示例9: openList

char *getCurrentList(ListItem *list) {
	char *ret;
	char buffer[READ_LENGTH+1];
	int fileHandle;
	char *cursor;
	int attempt, goodPass;
	const int MAX_ATTEMPTS = 3;
	
	buffer[READ_LENGTH] = '\0';
	if (list->currentFilePosition == -1) {
		list->currentFilePosition = 0;		
		for (attempt=0,goodPass=0;attempt < MAX_ATTEMPTS;attempt++) {
			fileHandle = openList(list,NULL);
			readBuffer(fileHandle,buffer,READ_LENGTH);
			if (goodString(buffer,1)) {
				goodPass = 1;
				break;
			}
			close(fileHandle);
			logException(30,0,0); // log failed attempt
		}
		if (!goodPass)
			logException(30,0,RESET);
		buffer[READ_LENGTH] = '\0'; //prevents readLine from searching for \n past buffer
		for (cursor = buffer;*cursor != 0x0a && *cursor != 0x0d && *cursor != 0x00;cursor++);
		*cursor = 0x00;
		close(fileHandle);
		strcpy(list->currentString,buffer);
	}
	ret = list->currentString;
	return ret;
}
开发者ID:billev,项目名称:literacybridge,代码行数:32,代码来源:lists.c

示例10: sizeof

void Apex::LoadDynamicTriangleMesh(int numVerts, PxVec3* verts, ObjectInfo info)
{
	PxRigidDynamic* meshActor = mPhysics->createRigidDynamic(PxTransform::createIdentity());
	PxShape* meshShape, *convexShape;
	if(meshActor)
	{
		//meshActor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);

		PxTriangleMeshDesc meshDesc;
		meshDesc.points.count           = numVerts;
		meshDesc.points.stride          = sizeof(PxVec3);
		meshDesc.points.data            = verts;

		//meshDesc.triangles.count        = numInds/3.;
		//meshDesc.triangles.stride       = 3*sizeof(int);
		//meshDesc.triangles.data         = inds;

		PxToolkit::MemoryOutputStream writeBuffer;
		bool status = mCooking->cookTriangleMesh(meshDesc, writeBuffer);
		if(!status)
			return;

		PxToolkit::MemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());

		PxTriangleMeshGeometry triGeom;
		triGeom.triangleMesh = mPhysics->createTriangleMesh(readBuffer);
		//triGeom.scale = PxMeshScale(PxVec3(info.sx,info.sy,info.sz),physx::PxQuat::createIdentity());
		
		meshShape = meshActor->createShape(triGeom, *defaultMaterial);
		//meshShape->setLocalPose(PxTransform(PxVec3(info.x,info.y,info.z)));
		meshShape->setFlag(PxShapeFlag::eUSE_SWEPT_BOUNDS, true);

		PxConvexMeshDesc convexDesc;
		convexDesc.points.count     = numVerts;
		convexDesc.points.stride    = sizeof(PxVec3);
		convexDesc.points.data      = verts;
		convexDesc.flags            = PxConvexFlag::eCOMPUTE_CONVEX;

		if(!convexDesc.isValid())
			return;
		PxToolkit::MemoryOutputStream buf;
		if(!mCooking->cookConvexMesh(convexDesc, buf))
			return;
		PxToolkit::MemoryInputData input(buf.getData(), buf.getSize());
		PxConvexMesh* convexMesh = mPhysics->createConvexMesh(input);
		PxConvexMeshGeometry convexGeom = PxConvexMeshGeometry(convexMesh);
		convexShape = meshActor->createShape(convexGeom, *defaultMaterial);
		//convexShape->setLocalPose(PxTransform(PxVec3(info.x,info.y,info.z)));
		//convexShape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);

		
		convexShape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
		meshShape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
		meshActor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, false);

		meshActor->setGlobalPose(PxTransform(PxVec3(info.x,info.y,info.z), PxQuat(info.ry, PxVec3(0.0f,1.0f,0.0f))));
		mScene[mCurrentScene]->addActor(*meshActor);
		dynamicActors.push_back(meshActor);
	}
}
开发者ID:schulchr,项目名称:Olympus,代码行数:60,代码来源:apex.cpp

示例11: setReadPtr

uint16_t
Enc28J60Network::readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len)
{
  len = setReadPtr(handle, position, len);
  readBuffer(len, buffer);
  return len;
}
开发者ID:PaulStoffregen,项目名称:arduino_uip,代码行数:7,代码来源:Enc28J60Network.cpp

示例12: while

void CommsProcessor::serverCallback() {
	string sourceAddress;								// Address of datagram source
	unsigned short sourcePort;					// Port of datagram source
	listenSocket.setLocalPort( svrPort );

	// set up the listening socket
	this->listenSocket.setRecvTimeout( 500 ); // 500 ms

	while( running ) {
		int bytesRcvd;

		bytesRcvd = this->listenSocket.recvFrom( recvBuf, maxMsgSize, sourceAddress, sourcePort );

		// if recieve call timedout then just start loop over
		if( bytesRcvd == 0 )
			continue;

		Message *buf = (Message*)recvBuf;
		switch( MessageType(buf->header.msgType) ) {
			case MessageType::CLIENT_EVENT:
			{
				BufferReader readBuffer( buf->payload, buf->header.len);
				EventType type = Event::getType( readBuffer );
				Event* event = owner->eventCtors->invoke(readBuffer);
				handoffQ->push( event );

				break;
			}
			default:
				break;
		}
	}
}
开发者ID:5-second-rule,项目名称:engine,代码行数:33,代码来源:CommsProcessor.cpp

示例13: Exception

void XMLParser::loadXMLBuffer(const QString &xml_buf)
{
    try
    {
        int pos1=-1, pos2=-1, tam=0;

        if(xml_buf.isEmpty())
            throw Exception(ERR_ASG_EMPTY_XML_BUFFER,__PRETTY_FUNCTION__,__FILE__,__LINE__);

        pos1=xml_buf.indexOf("<?xml");
        pos2=xml_buf.indexOf("?>");
        xml_buffer=xml_buf;

        if(pos1 >= 0 && pos2 >= 0)
        {
            tam=(pos2-pos1)+3;
            xml_decl=xml_buffer.mid(pos1, tam);
            xml_buffer.replace(pos1,tam,"");
        }
        else
            xml_decl="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

        removeDTD();
        readBuffer();
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(), e.getErrorType(), __PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
开发者ID:naveenr1981,项目名称:pgmodeler,代码行数:30,代码来源:xmlparser.cpp

示例14: readBuffer

void BinaryDataHandler::pullBuffer()
{
    readBuffer();

    _currentReadBuffer    = readBufBegin();
    _currentReadBufferPos = 0;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:7,代码来源:OSGBinaryDataHandler.cpp

示例15: PUNTOEXE_FUNCTION_START

///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Read an Huffman code
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
imbxUint32 huffmanTable::readHuffmanCode(streamReader* pStream)
{
	PUNTOEXE_FUNCTION_START(L"huffmanTable::readHuffmanCode");

	// Read initial number of bits
	imbxUint32 readBuffer(pStream->readBits(m_firstValidLength));

	// Validate the current Huffman code. If it's OK, then
	//  return the ordered value
	///////////////////////////////////////////////////////////
	if(readBuffer<=m_maxValuePerLength[m_firstValidLength])
	{
		return m_orderedValues[readBuffer - m_minValuePerLength[m_firstValidLength]];
	}

	imbxUint32 orderedValue(m_valuesPerLength[m_firstValidLength]);

	// Scan all the codes sizes
	///////////////////////////////////////////////////////////
	for(imbxUint8 scanSize(m_firstValidLength + 1), missingBits(0); scanSize != sizeof(m_valuesPerLength)/sizeof(m_valuesPerLength[0]); ++scanSize)
	{
		++missingBits;

		// If the active length is empty, then continue the loop
		///////////////////////////////////////////////////////////
		if(m_valuesPerLength[scanSize] == 0)
		{
			continue;
		}

		readBuffer <<= missingBits;
		if(missingBits == 1)
		{
			readBuffer |= pStream->readBit();
		}
		else
		{
			readBuffer |= pStream->readBits(missingBits);
		}

		// Validate the current Huffman code. If it's OK, then
		//  return the ordered value
		///////////////////////////////////////////////////////////
		if(readBuffer<=m_maxValuePerLength[scanSize])
		{
			return m_orderedValues[orderedValue + readBuffer - m_minValuePerLength[scanSize]];
		}

		orderedValue += m_valuesPerLength[scanSize];

		// Reset the number of bits to read in one go
		///////////////////////////////////////////////////////////
		missingBits = 0;

	}

	PUNTOEXE_THROW(huffmanExceptionRead, "Invalid huffman code found while reading from a stream");

	PUNTOEXE_FUNCTION_END();
}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:4d-plugin-imebra,代码行数:69,代码来源:huffmanTable.cpp


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