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


C++ StreamType类代码示例

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


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

示例1: CGsPacketMetadata

void CVPU1::Cmd_DIRECT(StreamType& stream, CODE nCommand)
{
	uint32 nSize = stream.GetAvailableReadBytes();
	nSize = std::min<uint32>(m_CODE.nIMM * 0x10, nSize);
	assert((nSize & 0x0F) == 0);

	if(nSize != 0)
	{
		uint8* packet = reinterpret_cast<uint8*>(alloca(nSize));
		stream.Read(packet, nSize);

		int32 remainingLength = nSize;
		while(remainingLength > 0)
		{
			uint32 processed = m_vif.GetGif().ProcessPacket(packet, 0, remainingLength, CGsPacketMetadata(2));
			packet += processed;
			remainingLength -= processed;
			assert(remainingLength >= 0);
		}
	}

	m_CODE.nIMM -= (nSize / 0x10);
	if((m_CODE.nIMM == 0) && (nSize != 0))
	{
		m_STAT.nVPS = 0;
	}
	else
	{
		m_STAT.nVPS = 1;
	}
}
开发者ID:RikoudoX,项目名称:Play-,代码行数:31,代码来源:VPU1.cpp

示例2: print_stream_state

void print_stream_state( const StreamType &stream )
{
    cout << "good: " << stream.good() << endl;
    cout << "eof: " << stream.eof() << endl;
    cout << "fail: " << stream.fail() << endl;
    cout << "bad: " << stream.bad() << endl;
    cout << bitset<4>(stream.rdstate()).to_string() << endl;
}
开发者ID:BigR-Lab,项目名称:CodeRes_Cpp,代码行数:8,代码来源:stream_state.cpp

示例3:

bool CVPU::Unpack_V32(StreamType& stream, uint128& result, unsigned int fields)
{
	if(stream.GetAvailableReadBytes() < (fields * 4)) return false;

	stream.Read(&result, (fields * 4));

	return true;
}
开发者ID:cmexp,项目名称:Play-,代码行数:8,代码来源:VPU.cpp

示例4: ProcessPacket

void CVPU::ProcessPacket(StreamType& stream)
{
	while(stream.GetAvailableReadBytes())
	{
		if(m_STAT.nVPS == 1)
		{
			//Command is waiting for more data...
			ExecuteCommand(stream, m_CODE);

			if((m_STAT.nVPS == 1) && (stream.GetAvailableReadBytes() != 0))
			{
				//We have data in our FIFO but we still need more than what's available
				break;
			}
			else
			{
				continue;
			}
		}
		if(m_STAT.nVEW == 1)
		{
			if(IsRunning()) break;
			m_STAT.nVEW = 0;
			//Command is waiting for micro-program to end.
			ExecuteCommand(stream, m_CODE);
			continue;
		}

#ifdef DELAYED_MSCAL
		m_previousCODE = m_CODE;
#endif
		stream.Read(&m_CODE, sizeof(CODE));

		assert(m_CODE.nI == 0);

		m_NUM = m_CODE.nNUM;

		ExecuteCommand(stream, m_CODE);
	}

#ifdef DELAYED_MSCAL
	if(stream.GetAvailableReadBytes() == 0)
	{
		ResumeDelayedMicroProgram();
	}
#endif
}
开发者ID:cmexp,项目名称:Play-,代码行数:47,代码来源:VPU.cpp

示例5: Cmd_MPG

void CVPU::Cmd_MPG(StreamType& stream, CODE nCommand)
{
	uint32 nSize = stream.GetAvailableReadBytes();

	uint32 nNum			= (m_NUM == 0) ? (256) : (m_NUM);
	uint32 nCodeNum		= (m_CODE.nNUM == 0) ? (256) : (m_CODE.nNUM);
	uint32 nTransfered	= (nCodeNum - nNum) * 8;

	nCodeNum *= 8;
	nNum *= 8;

	nSize = std::min<uint32>(nNum, nSize);

	uint32 nDstAddr = (m_CODE.nIMM * 8) + nTransfered;

	//Check if microprogram is running
	if(IsRunning())
	{
		m_STAT.nVEW = 1;
		return;
	}

	if(nSize != 0)
	{
		uint8* microProgram = reinterpret_cast<uint8*>(alloca(nSize));
		stream.Read(microProgram, nSize);

		//Check if there's a change
		if(memcmp(m_microMem + nDstAddr, microProgram, nSize) != 0)
		{
			m_executor.ClearActiveBlocks();
			memcpy(m_microMem + nDstAddr, microProgram, nSize);
		}
	}

	m_NUM -= static_cast<uint8>(nSize / 8);
	if((m_NUM == 0) && (nSize != 0))
	{
		m_STAT.nVPS = 0;
	}
	else
	{
		m_STAT.nVPS = 1;
	}
}
开发者ID:cmexp,项目名称:Play-,代码行数:45,代码来源:VPU.cpp

示例6: insert

const BSONObj* DBController::insert(const char* db, const char* ns, BSONObj* obj, const BSONObj* options) {
	if (_logger->isDebug()) _logger->debug(2, "DBController::insert ns: %s, bson: %s", ns, obj->toChar());
	StreamType* streamData = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);

	DBController::fillRequiredFields(obj);

	//    long crcStructure = checkStructure(obj);

	//    char* text = obj->toChar();
	//    streamData->writeChars(text, strlen(text));
	//    free(text);

	insertIndex(db, ns, obj, streamData->currentPos());

	writeBSON(streamData, obj);

	//CacheManager::objectCache()->add(id, new BSONObj(*obj));
	//
	return obj;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:20,代码来源:dbcontroller.cpp

示例7: update

void DBController::update(const char* db, const char* ns, BSONObj* obj, const BSONObj* options) {
	if (_logger->isDebug()) _logger->debug(2, "DBController::update ns: %s, bson: %s", ns, obj->toChar());
	StreamType* streamData = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);

	Index* index = findIndex(db, ns, obj);

	long currentPos = streamData->currentPos();

	// Moves to the record to update
	streamData->seek(index->posData);

	BSONObj* previous = readBSON(streamData);
	previous->add("_status", 3); // Updated

	streamData->seek(index->posData);
	writeBSON(streamData, previous);

	// Back to the end of the stream
	streamData->seek(currentPos);

	updateIndex(db, ns, obj, streamData->currentPos());

	obj->add("_status", 1); // Active

	writeBSON(streamData, obj);

	//std::string id = obj->getDJString("_id");

	//CacheManager::objectCache()->add(id, new BSONObj(*obj));
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:30,代码来源:dbcontroller.cpp

示例8: remove

void DBController::remove(const char* db, const char* ns, const char* documentId, const char* revision, const BSONObj* options) {
	if (_logger->isDebug()) _logger->debug(2, "DBController::update db: %s, ns: %s, documentId: %s, revision: %s", db, ns, documentId, revision);
	StreamType* streamData = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);

	IndexAlgorithm* impl = IndexFactory::indexFactory.index(db, ns, "_id");

	BSONObj indexBSON;
	indexBSON.add("_id", documentId);
	Index* index = impl->find(&indexBSON);
	if (index != NULL) {

		// TODO check the revision id
		StreamType* out = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);
		out->flush();

		long currentPos = out->currentPos();

		out->seek(index->posData);

		BSONObj* obj = readBSON(out);
		obj->add("_status", 2); // DELETED

		// Get back to the record start
		out->seek(index->posData);
		writeBSON(out, obj);

		// restores the last position
		out->seek(currentPos);

		//std::string id = obj->getDJString("_id");

		//CacheManager::objectCache()->remove(id);
		delete obj;
	}
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:35,代码来源:dbcontroller.cpp

示例9: Cmd_STMASK

void CVPU::Cmd_STMASK(StreamType& stream, CODE command)
{
	if(m_NUM == 0)
	{
		m_NUM = 1;
	}

	while(m_NUM != 0 && stream.GetAvailableReadBytes())
	{
		stream.Read(&m_MASK, 4);
		m_NUM--;
	}

	if(m_NUM == 0)
	{
		m_STAT.nVPS = 0;
	}
	else
	{
		m_STAT.nVPS = 1;
	}
}
开发者ID:cmexp,项目名称:Play-,代码行数:22,代码来源:VPU.cpp

示例10: Cmd_STCOL

void CVPU::Cmd_STCOL(StreamType& stream, CODE nCommand)
{
	if(m_NUM == 0)
	{
		m_NUM = 4;
	}

	while(m_NUM != 0 && stream.GetAvailableReadBytes())
	{
		assert(m_NUM <= 4);
		stream.Read(&m_C[4 - m_NUM], 4);
		m_NUM--;
	}

	if(m_NUM == 0)
	{
		m_STAT.nVPS = 0;
	}
	else
	{
		m_STAT.nVPS = 1;
	}
}
开发者ID:cmexp,项目名称:Play-,代码行数:23,代码来源:VPU.cpp

示例11: assert

void CVif1::Cmd_DIRECT(StreamType& stream, CODE nCommand)
{
    uint32 nSize = stream.GetAvailableReadBytes();
    nSize = std::min<uint32>(m_CODE.nIMM * 0x10, nSize);
    assert((nSize & 0x0F) == 0);

    if(nSize != 0)
    {
        if(m_directBuffer.size() < nSize)
        {
            m_directBuffer.resize(nSize);
        }

        auto packet = m_directBuffer.data();
        stream.Read(packet, nSize);

        int32 remainingLength = nSize;
        while(remainingLength > 0)
        {
            uint32 processed = m_gif.ProcessPacket(packet, 0, remainingLength, CGsPacketMetadata(2));
            packet += processed;
            remainingLength -= processed;
            assert(remainingLength >= 0);
        }
    }

    m_CODE.nIMM -= (nSize / 0x10);
    if((m_CODE.nIMM == 0) && (nSize != 0))
    {
        m_STAT.nVPS = 0;
    }
    else
    {
        m_STAT.nVPS = 1;
    }
}
开发者ID:unpeng,项目名称:Play-,代码行数:36,代码来源:Vif1.cpp

示例12: handle_error

    std::ios_base::iostate handle_error(StreamType& strm) const
        {
        std::ios_base::iostate err(error_m);

        try { throw; }

        catch (std::bad_alloc&)
            {
            set_bad();

            std::ios_base::iostate exception_mask(strm.exceptions());
            
            if (exception_mask & std::ios_base::failbit && !(exception_mask & std::ios_base::badbit))
                strm.setstate(err);
            else if (exception_mask & std::ios_base::badbit)
                {
                try { strm.setstate(err); }
                catch (std::ios_base::failure&) { }
                throw;
                }
            }
        catch (...)
            {
            set_fail();

            std::ios_base::iostate exception_mask(strm.exceptions());

            if ((exception_mask & std::ios_base::badbit) && (err & std::ios_base::badbit))
                strm.setstate(err);
            else if (exception_mask & std::ios_base::failbit)
                {
                try { strm.setstate(err); }
                catch (std::ios_base::failure&) { }
                throw;
                }
            }

        return err;
        }
开发者ID:andyprowl,项目名称:virtual-concepts,代码行数:39,代码来源:manip.hpp

示例13: StreamType

void details::showinfo()
{
    pp = p.getTSPacket(packet);
    int l = 0, c=0;
    for(int i = 0; i<packet.length; i++)
    {
        if(i%16 == 0)
        {
            l+=30;
            c = 0;
        }
        if(i%8 == 0)
            c+=30;
    io = new QGraphicsTextItem;
    io->setPos(c+(i%16)*30,l);
    st = QString::number(pp.rawData[i],16).toUpper();
    io->setPlainText(st);
    io->setToolTip(QString::number(pp.rawData[i],2));
    io->font().setPointSize(30);
    sc->addItem(io);
    }
    pst = p.getPIDList();




    StreamType *streamTypes = new StreamType();
    QString typ = streamTypes->getStreamType(pst[packet.pid].streamType);
    st = QString::number(packet.pid,16).toUpper();

    tw->setGeometry(20,20,550,150);
    tw->setHeaderLabel("Packet");

    //ts header
    twi = new QTreeWidgetItem();
    twi->setText(0,"MPEG-TS Header");
    QTreeWidgetItem *ch = new QTreeWidgetItem();
    ch->setText(0,"Sync Byte: 0x47");
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("Transport Error Indicator: %1 ").arg(pp.tsheader.transportErrorIndicator));
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("Payload Unit Start Indicator: %1 ").arg(pp.tsheader.payloadUnitStartIndicator));
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("Transport Priority: %1 ").arg(pp.tsheader.transportPriority));
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("PID: 0x%1 ").arg(QString::number(pp.tsheader.pid,16)));
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("Scrambling Control: %1 ").arg(pp.tsheader.scramblingControl));
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("Adaptation Field Control: %1 ").arg(pp.tsheader.adaptationFieldControl));
    twi->addChild(ch);
    ch = new QTreeWidgetItem();
    ch->setText(0,QString("Continuity Counter: %1 ").arg(pp.tsheader.continuityCounter));
    twi->addChild(ch);
    tw->addTopLevelItem(twi);

    //adaptation field
    if(pp.tsheader.adaptationFieldControl > 1)
    {
        twi = new QTreeWidgetItem();
        twi->setText(0,"Adaptation Field");
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Adaptation Field Lenght: %1 ").arg(pp.afheader.length));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Discontinuity Indicator: %1 ").arg(pp.afheader.discontinuityIndicator));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Random Access Indicator: %1 ").arg(pp.afheader.randomAccessIndicator));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Elementary stream priority indicator: %1 ").arg(pp.afheader.elementaryStreamPriorityIndicator));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("PCR Flag: %1 ").arg(pp.afheader.pcrFlag));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("OPCR Flag: %1 ").arg(pp.afheader.opcrFlag));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Splicing Point Flag: %1 ").arg(pp.afheader.splicingPointFlag));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Transport Private Data Flag: %1 ").arg(pp.afheader.transportPrivateDataFlag));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,QString("Adaptation Field Extension Flag: %1 ").arg(pp.afheader.extensionFlag));
        twi->addChild(ch);
        ch = new QTreeWidgetItem();
        ch->setText(0,"Adaptation Field Extension");
        twi->addChild(ch);
     //   QTreeWidgetItem *afex = new QTreeWidgetItem();

        tw->addTopLevelItem(twi);
//.........这里部分代码省略.........
开发者ID:ivanbarlog,项目名称:MPEG-TS,代码行数:101,代码来源:details.cpp

示例14: Cmd_UNPACK

void CVPU::Cmd_UNPACK(StreamType& stream, CODE nCommand, uint32 nDstAddr)
{
	assert((nCommand.nCMD & 0x60) == 0x60);

	bool usn = (m_CODE.nIMM & 0x4000) != 0;
	bool useMask = (nCommand.nCMD & 0x10) != 0;
	uint32 cl = m_CYCLE.nCL;
	uint32 wl = m_CYCLE.nWL;

	if(m_NUM == nCommand.nNUM)
	{
		m_readTick = 0;
		m_writeTick = 0;
	}

	uint32 currentNum = (m_NUM == 0) ? 256 : m_NUM;
	uint32 codeNum = (m_CODE.nNUM == 0) ? 256 : m_CODE.nNUM;
	uint32 transfered = codeNum - currentNum;
	assert(transfered == 0 || cl == wl);	//The value above is only valid for specific combinations of cl and wl

	nDstAddr += transfered;
	nDstAddr *= 0x10;

	uint128* dst = reinterpret_cast<uint128*>(&m_vuMem[nDstAddr]);

	while((currentNum != 0) && stream.GetAvailableReadBytes())
	{
		bool mustWrite = false;
		uint128 writeValue;
		memset(&writeValue, 0, sizeof(writeValue));

		if(cl >= wl)
		{
			if(m_readTick < wl || wl == 0)
			{
				bool success = Unpack_ReadValue(nCommand, stream, writeValue, usn);
				if(!success) break;
				mustWrite = true;
			}
		}
		else
		{
			if(m_writeTick < cl)
			{
				bool success = Unpack_ReadValue(nCommand, stream, writeValue, usn);
				if(!success) break;
			}

			mustWrite = true;
		}

		if(mustWrite)
		{
			for(unsigned int i = 0; i < 4; i++)
			{
				uint32 maskOp = useMask ? GetMaskOp(i, m_writeTick) : MASK_DATA;

				if(maskOp == MASK_DATA)
				{
					if(m_MODE == MODE_OFFSET)
					{
						writeValue.nV[i] += m_R[i];
					}
					else if(m_MODE == MODE_DIFFERENCE)
					{
						assert(0);
					}

					dst->nV[i] = writeValue.nV[i];
				}
				else if(maskOp == MASK_ROW)
				{
					dst->nV[i] = m_R[i];
				}
				else if(maskOp == MASK_COL)
				{
					int index = (m_writeTick > 3) ? 3 : m_writeTick;
					dst->nV[i] = m_C[index];
				}
				else if(maskOp == MASK_MASK)
				{
					//Don't write anything
				}
				else
				{
					assert(0);
				}
			}
			
			currentNum--;
		}

		if(cl >= wl)
		{
			m_writeTick = std::min<uint32>(m_writeTick + 1, wl);
			m_readTick = std::min<uint32>(m_readTick + 1, cl);

			if(m_readTick == cl)
			{
				m_writeTick = 0;
//.........这里部分代码省略.........
开发者ID:cmexp,项目名称:Play-,代码行数:101,代码来源:VPU.cpp

示例15: makeDir

void DBController::initialize(std::string dataDir) {
	if (_logger->isInfo()) _logger->info("DBController initializing. Data dir: %s", dataDir.c_str());

	_dataDir = dataDir;

	if (_logger->isDebug()) _logger->debug(0, "data dir = %s", _dataDir.c_str());

	if (!existDir(_dataDir.c_str())) {
		makeDir(_dataDir.c_str());
	}

	if (!checkFileCreation(_dataDir.c_str())) {
		_logger->error("An error ocurred using the data folder: %s. Please check that the user has permissions for writing over that directory. Error: %s", _dataDir.c_str(), lastErrorDescription()); 
		exit(1);
	}

	StreamManager::getStreamManager()->setDataDir(_dataDir);
	StreamManager::getStreamManager()->setInitializing(true);

	std::auto_ptr<FileInputStream> fis(new FileInputStream((_dataDir + "djondb.dat").c_str(), "rb"));
	while (!fis->eof()) {
		std::string* db = fis->readString();
		std::string* ns = fis->readString();
		int streams = fis->readInt();
		for (int x = 0; x < streams; x++) {
			FILE_TYPE type = static_cast<FILE_TYPE>(fis->readInt());
			StreamType* stream = StreamManager::getStreamManager()->open(db->c_str(), ns->c_str(), type);

			if (type == INDEX_FTYPE) {
				StreamType* dbstream = StreamManager::getStreamManager()->open(db->c_str(), ns->c_str(), DATA_FTYPE);
				std::set<std::string> skeys;
				skeys.insert("_id");

				IndexAlgorithm* impl = IndexFactory::indexFactory.index(db->c_str(), ns->c_str(), skeys);
				// If the database is version lesser than 0.3 then the indexes should
				// be migrated to the new format
				Version vindex("0.300000000");
				if (*dbstream->version() < vindex) {
					migrateIndex0_3(db->c_str(), ns->c_str(), stream, impl);
					removeFile(stream->fileName().c_str());
					((DBFileStream*)dbstream)->updateVersion(&vindex);
				}
				/* 
					long currentPos = stream->currentPos();
					stream->seek(0);

					int records = 0;
					while (!stream->eof()) {
					BSONObj* obj = readBSON(stream);

					if (!impl) {
					std::set<std::string> skeys;
					for (BSONObj::const_iterator i = obj->begin(); i != obj->end(); i++) {
					std::string key = i->first;
					skeys.insert(key);
					}
					}
					long indexPos = stream->readLong();
					long posData = stream->readLong();
					if (obj->has("_id")) {
					impl->add(*obj, obj->getDJString("_id"), posData, indexPos);
					records++;
					}
					delete obj;
					}
					stream->seek(currentPos);

					if (_logger->isInfo()) _logger->info("db: %s, ns: %s, Index initialized. Records: %d", db->c_str(), ns->c_str(), records);
					*/
			}
		}
	}
	fis->close();
	StreamManager::getStreamManager()->setInitializing(false);
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:75,代码来源:dbcontroller.cpp


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