• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ readU16函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: is

bool DecoSchematic::loadSchematicFile() {
	std::ifstream is(filename.c_str(), std::ios_base::binary);

	u32 signature = readU32(is);
	if (signature != MTSCHEM_FILE_SIGNATURE) {
		errorstream << "loadSchematicFile: invalid schematic "
			"file" << std::endl;
		return false;
	}
	
	u16 version = readU16(is);
	if (version != 1) {
		errorstream << "loadSchematicFile: unsupported schematic "
			"file version" << std::endl;
		return false;
	}

	size = readV3S16(is);
	int nodecount = size.X * size.Y * size.Z;
	
	u16 nidmapcount = readU16(is);
	
	node_names = new std::vector<std::string>;
	for (int i = 0; i != nidmapcount; i++) {
		std::string name = deSerializeString(is);
		node_names->push_back(name);
	}

	delete schematic;
	schematic = new MapNode[nodecount];
	MapNode::deSerializeBulk(is, SER_FMT_VER_HIGHEST, schematic,
				nodecount, 2, 2, true);
				
	return true;
}
开发者ID:MasterCrank,项目名称:minetest,代码行数:35,代码来源:mapgen.cpp


示例2: readU16

WideString TankFile::readWNString()
{
	auto lenInChars = readU16();
	if (lenInChars == 0)
	{
		readU16(); // Waste another word to make this a dword
		return WideString();
	}

	// NSTRINGs are stored aligned at dword boundary:
	lenInChars = alignToDword(lenInChars + 2) - 2; // 2 for the word we've just read
	assert(((lenInChars + 2) % sizeof(uint32_t)) == 0);

	if (lenInChars >= utils::MaxTempStringLen)
	{
		SiegeThrow(TankFile::Error, "String overflow in TankFile::readWNString()! "
				<< lenInChars << " >= " << utils::MaxTempStringLen);
	}

	WideChar buffer[utils::MaxTempStringLen];
	readBytes(buffer, lenInChars * sizeof(WideChar));
	buffer[lenInChars] = 0;

	return buffer;
}
开发者ID:glampert,项目名称:reverse-engineering-dungeon-siege,代码行数:25,代码来源:tank_file.cpp


示例3: deSerialize

	void deSerialize(std::istream &is)
	{
		clear();
		int version = readU8(is);
		if(version != 1)
			throw SerializationError("unsupported NodeDefinitionManager version");
		u16 count = readU16(is);
		std::istringstream is2(deSerializeLongString(is), std::ios::binary);
		for(u16 n=0; n<count; n++){
			u16 i = readU16(is2);
			if(i > MAX_CONTENT){
				errorstream<<"ContentFeatures::deSerialize(): "
						<<"Too large content id: "<<i<<std::endl;
				continue;
			}
			/*// Do not deserialize special types
			if(i == CONTENT_IGNORE || i == CONTENT_AIR)
				continue;*/
			ContentFeatures *f = &m_content_features[i];
			// Read it from the string wrapper
			std::string wrapper = deSerializeString(is2);
			std::istringstream wrapper_is(wrapper, std::ios::binary);
			f->deSerialize(wrapper_is);
			verbosestream<<"deserialized "<<f->name<<std::endl;
			if(f->name != "")
				addNameIdMapping(i, f->name);
		}
	}
开发者ID:ajbetteridge,项目名称:minetest,代码行数:28,代码来源:nodedef.cpp


示例4: readU32

bool WPGHeader::load(WPXInputStream *input)
{
	input->seek(0, WPX_SEEK_SET);
	
	size_t n = 0;
	unsigned char * prefix = (unsigned char *) input->read(26, n);
	if(n < 26)
        return false;
	
	m_identifier[0] = prefix[0];  
	m_identifier[1] = prefix[1];  
	m_identifier[2] = prefix[2];  
	m_identifier[3] = prefix[3];  
	m_startOfDocument = readU32(prefix+4);
	m_productType = prefix[8];
	m_fileType = prefix[9];
	m_majorVersion = prefix[10];
	m_minorVersion = prefix[11];
	m_encryptionKey = readU16(prefix+12);
	m_startOfPacketData = readU16(prefix+14);
	
	WPG_DEBUG_MSG(("Header Identifier  = %c%c%c\n", m_identifier[1], 
	m_identifier[2], m_identifier[3]));
	WPG_DEBUG_MSG(("Product type       = 0x%x\n",  m_productType));
	WPG_DEBUG_MSG(("File type          = 0x%x\n",  m_fileType));
	WPG_DEBUG_MSG(("Major version      = 0x%x\n",  m_majorVersion));
	WPG_DEBUG_MSG(("Minor version      = 0x%x\n",  m_minorVersion));
	WPG_DEBUG_MSG(("Encryption key     = 0x%x\n",  m_encryptionKey));
	
	return true;
}
开发者ID:JLuc,项目名称:scribus,代码行数:31,代码来源:WPGHeader.cpp


示例5: deSerialize

	void deSerialize(std::istream &is)
	{
		// Clear everything
		clear();
		// Deserialize
		int version = readU8(is);
		if(version != 0)
			throw SerializationError("unsupported ItemDefManager version");
		u16 count = readU16(is);
		for(u16 i=0; i<count; i++)
		{
			// Deserialize a string and grab an ItemDefinition from it
			std::istringstream tmp_is(deSerializeString(is), std::ios::binary);
			ItemDefinition def;
			def.deSerialize(tmp_is);
			// Register
			registerItem(def);
		}
		u16 num_aliases = readU16(is);
		for(u16 i=0; i<num_aliases; i++)
		{
			std::string name = deSerializeString(is);
			std::string convert_to = deSerializeString(is);
			registerAlias(name, convert_to);
		}
	}
开发者ID:EXio4,项目名称:minetest,代码行数:26,代码来源:itemdef.cpp


示例6: readU32

void libvisio::VSDMetaData::readPropertySetStream(librevenge::RVNGInputStream *input)
{
  // ByteOrder
  input->seek(2, librevenge::RVNG_SEEK_CUR);
  // Version
  input->seek(2, librevenge::RVNG_SEEK_CUR);
  // SystemIdentifier
  input->seek(4, librevenge::RVNG_SEEK_CUR);
  // CLSID
  input->seek(16, librevenge::RVNG_SEEK_CUR);
  // NumPropertySets
  input->seek(4, librevenge::RVNG_SEEK_CUR);
  // FMTID0
  //input->seek(16, librevenge::RVNG_SEEK_CUR);
  uint32_t data1 = readU32(input);
  uint16_t data2 = readU16(input);
  uint16_t data3 = readU16(input);
  uint8_t data4[8];
  for (int i = 0; i < 8; i++)
  {
    data4[i] = readU8(input);
  }
  char FMTID0[36];
  sprintf(FMTID0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", data1, data2, data3,
          data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7]);

  uint32_t offset0 = readU32(input);
  readPropertySet(input, offset0, FMTID0);
}
开发者ID:androidfan0,项目名称:libvisio,代码行数:29,代码来源:VSDMetaData.cpp


示例7: readU8

void ObjectProperties::deSerialize(std::istream &is)
{
	int version = readU8(is);
	if(version != 1) throw SerializationError(
			"unsupported ObjectProperties version");
	hp_max = readS16(is);
	physical = readU8(is);
	weight = readF1000(is);
	collisionbox.MinEdge = readV3F1000(is);
	collisionbox.MaxEdge = readV3F1000(is);
	visual = deSerializeString(is);
	meshfile = deSerializeString(is);
	visual_size = readV2F1000(is);
	textures.clear();
	u32 texture_count = readU16(is);
	for(u32 i=0; i<texture_count; i++){
		textures.push_back(deSerializeString(is));
	}
	textures_3d.clear();
	u32 texture_3d_count = readU16(is);
	for(u32 i=0; i<texture_3d_count; i++){
		textures_3d.push_back(deSerializeString(is));
	}
	spritediv = readV2S16(is);
	initial_sprite_basepos = readV2S16(is);
	is_visible = readU8(is);
	makes_footstep_sound = readU8(is);
	try{
		automatic_rotate = readF1000(is);
	}catch(SerializationError &e){}
}
开发者ID:Jeija,项目名称:BlockPlanet,代码行数:31,代码来源:object_properties.cpp


示例8: readU32

void libvisio::VSDMetaData::readPropertySetStream(librevenge::RVNGInputStream *input)
{
  // ByteOrder
  input->seek(2, librevenge::RVNG_SEEK_CUR);
  // Version
  input->seek(2, librevenge::RVNG_SEEK_CUR);
  // SystemIdentifier
  input->seek(4, librevenge::RVNG_SEEK_CUR);
  // CLSID
  input->seek(16, librevenge::RVNG_SEEK_CUR);
  // NumPropertySets
  input->seek(4, librevenge::RVNG_SEEK_CUR);
  // FMTID0
  //input->seek(16, librevenge::RVNG_SEEK_CUR);
  uint32_t data1 = readU32(input);
  uint16_t data2 = readU16(input);
  uint16_t data3 = readU16(input);
  uint8_t data4[8];
  for (unsigned char &i : data4)
  {
    i = readU8(input);
  }
  // Pretty-printed GUID is 36 bytes + the terminating null-character.
  char FMTID0[37];
  sprintf(FMTID0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", data1, data2, data3,
          data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7]);

  uint32_t offset0 = readU32(input);
  readPropertySet(input, offset0, FMTID0);
}
开发者ID:LibreOffice,项目名称:libvisio,代码行数:30,代码来源:VSDMetaData.cpp


示例9: readU16

void WP6GraphicsFilenamePacket::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
{
	if ((m_flags & 0x01) == 0x00)
		return;
	unsigned short tmpNumChildIds = readU16(input, encryption);
	for (unsigned short i = 0; i < tmpNumChildIds; i++)
		m_childIds.push_back(readU16(input, encryption));
}
开发者ID:Distrotech,项目名称:libpwd,代码行数:8,代码来源:WP6GraphicsFilenamePacket.cpp


示例10: while

void FlcPlayer::decodeVideo(bool skipLastFrame)
{
	bool videoFrameFound = false;
	
	while (!videoFrameFound)
	{
		if (!isValidFrame(_videoFrameData, _videoFrameSize, _videoFrameType))
		{
			_playingState = FINISHED;
			break;
		}

		switch (_videoFrameType)
		{
		case FRAME_TYPE:

			Uint32 delay;

			readU16(_frameChunks, _videoFrameData + 6);
			readU16(_delayOverride, _videoFrameData + 8);

			if (_headerType == FLI_TYPE)
			{
				delay = _delayOverride > 0 ? _delayOverride : _headerSpeed * (1000.0 / 70.0);
			}
			else
			{
				delay = _videoDelay;
			}

			waitForNextFrame(delay);

			// Skip the frame header, we are not interested in the rest
			_chunkData = _videoFrameData + 16;

			_videoFrameData += _videoFrameSize;
			// If this frame is the last one, don't play it
			if(isEndOfFile(_videoFrameData))
				_playingState = FINISHED;

			if(!shouldQuit() || !skipLastFrame)
				playVideoFrame();

			videoFrameFound = true;

			break;
		case AUDIO_CHUNK:
			_videoFrameData += _videoFrameSize + 16;
			break;
		case PREFIX_CHUNK:
			// Just skip it
			_videoFrameData += _videoFrameSize;

			break;
		}
	}
}
开发者ID:JonnyH,项目名称:shoes-diary,代码行数:57,代码来源:FlcPlayer.cpp


示例11: readU8

void NodeTimerList::deSerialize(std::istream &is, u8 map_format_version)
{
	m_data.clear();
	
	if(map_format_version == 24){
		u8 timer_version = readU8(is);
		if(timer_version == 0)
			return;
		if(timer_version != 1)
			throw SerializationError("unsupported NodeTimerList version");
	}

	if(map_format_version >= 25){
		u8 timer_data_len = readU8(is);
		if(timer_data_len != 2+4+4)
			throw SerializationError("unsupported NodeTimer data length");
	}

	u16 count = readU16(is);

	for(u16 i=0; i<count; i++)
	{
		u16 p16 = readU16(is);

		v3s16 p;
		p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
		p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
		p.Y = p16 / MAP_BLOCKSIZE;
		p16 &= MAP_BLOCKSIZE - 1;
		p.X = p16;

		NodeTimer t;
		t.deSerialize(is);

		if(t.timeout <= 0)
		{
			infostream<<"WARNING: NodeTimerList::deSerialize(): "
					<<"invalid data at position"
					<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
					<<std::endl;
			continue;
		}

		if(m_data.find(p) != m_data.end())
		{
			infostream<<"WARNING: NodeTimerList::deSerialize(): "
					<<"already set data at position"
					<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
					<<std::endl;
			continue;
		}

		m_data.insert(std::make_pair(p, t));
	}
}
开发者ID:Falcon-peregrinus,项目名称:freeminer,代码行数:55,代码来源:nodetimer.cpp


示例12: readU8

void TileDef::deSerialize(std::istream &is)
{
	int version = readU8(is);
	name = deSerializeString(is);
	animation.type = (TileAnimationType)readU8(is);
	animation.aspect_w = readU16(is);
	animation.aspect_h = readU16(is);
	animation.length = readF1000(is);
	if(version >= 1)
		backface_culling = readU8(is);
}
开发者ID:BobMikfillin,项目名称:minetest,代码行数:11,代码来源:nodedef.cpp


示例13: readU8

void TileDef::deSerialize(std::istream &is)
{
	int version = readU8(is);
	if(version != 0)
		throw SerializationError("unsupported TileDef version");
	name = deSerializeString(is);
	animation.type = (TileAnimationType)readU8(is);
	animation.aspect_w = readU16(is);
	animation.aspect_h = readU16(is);
	animation.length = readF1000(is);
}
开发者ID:ajbetteridge,项目名称:minetest,代码行数:11,代码来源:nodedef.cpp


示例14: readU16

    void STTBF::init( U16 lid, OLEStreamReader* reader, const U8* ptr )
    {
        bool extended = false;
        U16 count = readU16( reader, &ptr );
        // "extended" characters?
        if ( count == 0xffff ) {
            extended = true;
            // read the real size
            count = readU16( reader, &ptr );
        }
        m_extraDataLength = readU16( reader, &ptr );

        // If we don't read unicode strings we have to set up a text converter
        TextConverter* textconverter = 0;
        if ( !extended )
            textconverter = new TextConverter( lid );

        // read one string after the other
        for ( U16 i = 0; i < count; ++i ) {
            U16 len = 0;
            if ( extended ) // double byte count!
                len = readU16( reader, &ptr );
            else
                len = readU8( reader, &ptr );

            if ( len != 0 ) {
                if ( extended ) {
                    XCHAR* string = new XCHAR[ len ];
                    for ( U16 j = 0; j < len; ++j )
                        string[ j ] = readU16( reader, &ptr );
                    UString ustring( reinterpret_cast<const wvWare::UChar *>( string ), len );
                    delete [] string;
                    m_strings.push_back( ustring );
                }
                else {
                    U8* string = new U8[ len ];
                    read( reader, &ptr, string, len );
                    UString ustring( textconverter->convert( reinterpret_cast<char*>( string ),
                                                             static_cast<unsigned int>( len ) ) );
                    delete [] string;
                    m_strings.push_back( ustring );
                }
            }
            else
                m_strings.push_back( UString("") );
            if ( m_extraDataLength != 0 ) {
                U8* extra = new U8[ m_extraDataLength ];
                read( reader, &ptr, extra, m_extraDataLength );
                m_extraData.push_back( extra );
            }
        }
        delete textconverter;
    }
开发者ID:FranciscoJavierPRamos,项目名称:wv2qt,代码行数:53,代码来源:word_helper.cpp


示例15: deSerializeString

void CraftDefinitionShaped::deSerializeBody(std::istream &is, int version)
{
	if(version != 1) throw SerializationError(
			"unsupported CraftDefinitionShaped version");
	output = deSerializeString(is);
	width = readU16(is);
	recipe.clear();
	u32 count = readU16(is);
	for(u32 i=0; i<count; i++)
		recipe.push_back(deSerializeString(is));
	replacements.deSerialize(is);
}
开发者ID:AMDmi3,项目名称:minetest,代码行数:12,代码来源:craftdef.cpp


示例16: readU16

void FlcPlayer::fliLC()
{
	Uint8 *pSrc, *pDst, *pTmpDst;
	Sint8 countData;
	Uint8 countSkip;
	Uint8 fill;
	Uint16 lines, tmp;
	int packetsCount;

	pSrc = _chunkData + 6;
	pDst = (Uint8*)_mainScreen->pixels + _offset;

	readU16(tmp, pSrc);
	pSrc += 2;
	pDst += tmp*_mainScreen->pitch;
	readU16(lines, pSrc);
	pSrc += 2;

	while (lines--) 
	{
		pTmpDst = pDst;
		packetsCount = *(pSrc++);

		while (packetsCount--) 
		{
			countSkip = *(pSrc++);
			pTmpDst += countSkip;
			countData = *(pSrc++);
			if (countData > 0) 
			{
				while (countData--) 
				{
					*(pTmpDst++) = *(pSrc++);
				}
			}
			else 
			{
				if (countData < 0) 
				{
					countData = -countData;

					fill = *(pSrc++);
					while (countData--) 
					{
						*(pTmpDst++) = fill;
					}
				}
			}
		}
		pDst += _mainScreen->pitch;
	}
}
开发者ID:JonnyH,项目名称:shoes-diary,代码行数:52,代码来源:FlcPlayer.cpp


示例17: analyzeStyle

bool analyzeStyle(const uint8_t* os2_data, size_t os2_size, int* weight, bool* italic) {
    const size_t kUsWeightClassOffset = 4;
    const size_t kFsSelectionOffset = 62;
    const uint16_t kItalicFlag = (1 << 0);
    if (os2_size < kFsSelectionOffset + 2) {
        return false;
    }
    uint16_t weightClass = readU16(os2_data, kUsWeightClassOffset);
    *weight = weightClass / 100;
    uint16_t fsSelection = readU16(os2_data, kFsSelectionOffset);
    *italic = (fsSelection & kItalicFlag) != 0;
    return true;
}
开发者ID:NuclearAndroidProject1,项目名称:android_frameworks_minikin,代码行数:13,代码来源:AnalyzeStyle.cpp


示例18: lock

void NodeMetadataList::deSerialize(std::istream &is)
{
	{
		JMutexAutoLock lock(m_mutex);
		m_data.clear();
	}

	u8 buf[6];

	is.read((char*)buf, 2);
	u16 version = readU16(buf);

	if (version > 1) {
		infostream<<__FUNCTION_NAME<<": version "<<version<<" not supported"
				<<std::endl;
		throw SerializationError("NodeMetadataList::deSerialize");
	}

	is.read((char*)buf, 2);
	u16 count = readU16(buf);

	for (u16 i=0; i<count; i++) {
		is.read((char*)buf, 2);
		u16 p16 = readU16(buf);

		v3s16 p(0,0,0);
		p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
		p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
		p.Y += p16 / MAP_BLOCKSIZE;
		p16 -= p.Y * MAP_BLOCKSIZE;
		p.X += p16;

		NodeMetadata *data = NodeMetadata::deSerialize(is);

		if (data == NULL)
			continue;

		if (m_data.find(p)) {
			infostream<<"WARNING: NodeMetadataList::deSerialize(): "
					<<"already set data at position"
					<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
					<<std::endl;
			delete data;
			continue;
		}

		m_data.insert(p, data);
	}
}
开发者ID:Jobava,项目名称:Voxelands,代码行数:49,代码来源:nodemetadata.cpp


示例19: readU8

void NameIdMapping::deSerialize(std::istream &is)
{
	int version = readU8(is);
	if(version != 0)
		throw SerializationError("unsupported NameIdMapping version");
	u32 count = readU16(is);
	m_id_to_name.clear();
	m_name_to_id.clear();
	for(u32 i=0; i<count; i++){
		u16 id = readU16(is);
		std::string name = deSerializeString(is);
		m_id_to_name[id] = name;
		m_name_to_id[name] = id;
	}
}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:15,代码来源:nameidmapping.cpp


示例20: clear

void CNodeDefManager::deSerialize(std::istream &is)
{
	clear();
	int version = readU8(is);
	if (version != 1)
		throw SerializationError("unsupported NodeDefinitionManager version");
	u16 count = readU16(is);
	std::istringstream is2(deSerializeLongString(is), std::ios::binary);
	ContentFeatures f;
	for (u16 n = 0; n < count; n++) {
		u16 i = readU16(is2);

		// Read it from the string wrapper
		std::string wrapper = deSerializeString(is2);
		std::istringstream wrapper_is(wrapper, std::ios::binary);
		f.deSerialize(wrapper_is);

		// Check error conditions
		if (i == CONTENT_IGNORE || i == CONTENT_AIR || i == CONTENT_UNKNOWN) {
			warningstream << "NodeDefManager::deSerialize(): "
				"not changing builtin node " << i << std::endl;
			continue;
		}
		if (f.name.empty()) {
			warningstream << "NodeDefManager::deSerialize(): "
				"received empty name" << std::endl;
			continue;
		}

		// Ignore aliases
		u16 existing_id;
		if (m_name_id_mapping.getId(f.name, existing_id) && i != existing_id) {
			warningstream << "NodeDefManager::deSerialize(): "
				"already defined with different ID: " << f.name << std::endl;
			continue;
		}

		// All is ok, add node definition with the requested ID
		if (i >= m_content_features.size())
			m_content_features.resize((u32)(i) + 1);
		m_content_features[i] = f;
		addNameIdMapping(i, f.name);
		verbosestream << "deserialized " << f.name << std::endl;

		getNodeBoxUnion(f.selection_box, f, &m_selection_box_union);
		fixSelectionBoxIntUnion();
	}
}
开发者ID:EXio4,项目名称:minetest,代码行数:48,代码来源:nodedef.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ readU32函数代码示例发布时间:2022-05-30
下一篇:
C++ readToken函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap