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


C++ readU8函数代码示例

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


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

示例1: readU8

void StaticObjectList::deSerialize(std::istream &is)
{
	// version
	u8 version = readU8(is);
	// count
	u16 count = readU16(is);
	for(u16 i=0; i<count; i++)
	{
		StaticObject s_obj;
		s_obj.deSerialize(is, version);
		m_stored.push_back(s_obj);
	}
}
开发者ID:1CoreyDev1,项目名称:minetest,代码行数:13,代码来源:staticobject.cpp

示例2: readU8

void TileDef::deSerialize(std::istream &is, const u8 contenfeatures_version, const NodeDrawType drawtype)
{
	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);
	if (version >= 2) {
		tileable_horizontal = readU8(is);
		tileable_vertical = readU8(is);
	}

	if ((contenfeatures_version < 8) &&
		((drawtype == NDT_MESH) ||
		 (drawtype == NDT_FIRELIKE) ||
		 (drawtype == NDT_LIQUID) ||
		 (drawtype == NDT_PLANTLIKE)))
		backface_culling = false;
}
开发者ID:4aiman,项目名称:minetest,代码行数:22,代码来源:nodedef.cpp

示例3: reset

void ItemDefinition::deSerialize(std::istream &is)
{
	// Reset everything
	reset();

	// Deserialize
	int version = readU8(is);
	if(version != 1)
		throw SerializationError("unsupported ItemDefinition version");
	type = (enum ItemType)readU8(is);
	name = deSerializeString(is);
	description = deSerializeString(is);
	inventory_image = deSerializeString(is);
	wield_image = deSerializeString(is);
	wield_scale = readV3F1000(is);
	stack_max = readS16(is);
	usable = readU8(is);
	liquids_pointable = readU8(is);
	std::string tool_capabilities_s = deSerializeString(is);
	if(!tool_capabilities_s.empty())
	{
		std::istringstream tmp_is(tool_capabilities_s, std::ios::binary);
		tool_capabilities = new ToolCapabilities;
		tool_capabilities->deSerialize(tmp_is);
	}
	groups.clear();
	u32 groups_size = readU16(is);
	for(u32 i=0; i<groups_size; i++){
		std::string name = deSerializeString(is);
		int value = readS16(is);
		groups[name] = value;
	}
	// If you add anything here, insert it primarily inside the try-catch
	// block to not need to increase the version.
	try{
		node_placement_prediction = deSerializeString(is);
	}catch(SerializationError &e) {};
}
开发者ID:AMDmi3,项目名称:minetest,代码行数:38,代码来源:itemdef.cpp

示例4: readU32

status SampleVisionFile::parseLoops()
{
	for (int i=0; i<8; i++)
	{
		uint32_t startFrame, endFrame;
		uint8_t type;
		uint16_t count;
		readU32(&startFrame);
		readU32(&endFrame);
		readU8(&type);
		readU16(&count);
	}
	return AF_SUCCEED;
}
开发者ID:RedDwarf69,项目名称:audiofile,代码行数:14,代码来源:SampleVision.cpp

示例5: readU32

librevenge::RVNGString libvisio::VSDMetaData::readCodePageString(librevenge::RVNGInputStream *input)
{
  uint32_t size = readU32(input);

  std::vector<unsigned char> characters;
  for (uint32_t i = 0; i < size; ++i)
    characters.push_back(readU8(input));

  uint32_t codepage = getCodePage();
  librevenge::RVNGString string;

  if (codepage == 65001)
  {
    // http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130%28v=vs.85%29.aspx
    // says this is UTF-8.
    for (std::vector<unsigned char>::const_iterator i = characters.begin(); i != characters.end(); ++i)
      string.append((const char)*i);
  }
  else
  {
    UErrorCode status = U_ZERO_ERROR;
    UConverter *conv = 0;

    switch (codepage)
    {
    case 1252:
      // http://msdn.microsoft.com/en-us/goglobal/bb964654
      conv = ucnv_open("windows-1252", &status);
      break;
    }

    if (U_SUCCESS(status) && conv)
    {
      const char *src = (const char *)&characters[0];
      const char *srcLimit = (const char *)src + characters.size();
      while (src < srcLimit)
      {
        UChar32 ucs4Character = ucnv_getNextUChar(conv, &src, srcLimit, &status);
        if (U_SUCCESS(status) && U_IS_UNICODE_CHAR(ucs4Character))
          appendUCS4(string, ucs4Character);
      }
    }

    if (conv)
      ucnv_close(conv);
  }

  return string;
}
开发者ID:androidfan0,项目名称:libvisio,代码行数:49,代码来源:VSDMetaData.cpp

示例6: create

	static NodeMetadata* create(std::istream &is, IGameDef *gamedef)
	{
		GenericNodeMetadata *d = new GenericNodeMetadata(gamedef);
		
		d->m_inventory = new Inventory(gamedef->idef());
		d->m_inventory->deSerialize(is);
		d->m_text = deSerializeLongString(is);
		d->m_owner = deSerializeString(is);
		
		d->m_infotext = deSerializeString(is);
		d->m_inventorydrawspec = deSerializeString(is);
		d->m_allow_text_input = readU8(is);
		d->m_removal_disabled = readU8(is);
		d->m_enforce_owner = readU8(is);

		int num_vars = readU32(is);
		for(int i=0; i<num_vars; i++){
			std::string name = deSerializeString(is);
			std::string var = deSerializeLongString(is);
			d->m_stringvars[name] = var;
		}

		return d;
	}
开发者ID:Anchakor,项目名称:minetest,代码行数:24,代码来源:content_nodemeta.cpp

示例7: switch

void WP42DefineColumnsGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
{
	unsigned char maxNumColumns = 0;
	switch (m_groupId)
	{
	case WP42_DEFINE_COLUMNS_OLD_GROUP:
		input->seek(11, librevenge::RVNG_SEEK_CUR);
		maxNumColumns = 5;
		break;
	case WP42_DEFINE_COLUMNS_NEW_GROUP:
		input->seek(49, librevenge::RVNG_SEEK_CUR);
		maxNumColumns = 24;
		break;
	default:
		return;
	}
	unsigned char tmpNumColumns = readU8(input, encryption);
	m_numColumns = tmpNumColumns & 0x7F;
	if (m_numColumns > maxNumColumns)
		m_numColumns = maxNumColumns;
	m_isParallel = ((tmpNumColumns & 0x80) != 0);
	for (unsigned char i = 0; i<2*m_numColumns; i++)
		m_columnsDefinition.push_back(readU8(input, encryption));
}
开发者ID:Distrotech,项目名称:libpwd,代码行数:24,代码来源:WP42DefineColumnsGroup.cpp

示例8: 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

示例9: 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

示例10: m_data

IWORKMemoryStream::IWORKMemoryStream(const RVNGInputStreamPtr_t &input)
  : m_data()
  , m_length(0)
  , m_pos(0)
{
  const auto begin = (unsigned long) input->tell();
  if (input->seek(0, librevenge::RVNG_SEEK_END))
  {
    while (!input->isEnd())
      readU8(input);
  }
  const auto end = (unsigned long) input->tell();
  input->seek((long) begin, librevenge::RVNG_SEEK_SET);

  read(input, static_cast<unsigned>(end - begin));
}
开发者ID:LibreOffice,项目名称:libetonyek,代码行数:16,代码来源:IWORKMemoryStream.cpp

示例11: readU8

void NodeTimerList::deSerialize(std::istream &is)
{
	m_data.clear();

	u8 version = readU8(is);
	if(version == 0)
		return;
	if(version != 1)
		throw SerializationError("unsupported NodeTimerList version");

	u16 count = readU16(is);

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

		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;

		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:wowiamdiamonds,项目名称:minetest,代码行数:47,代码来源:nodetimer.cpp

示例12: deSerialize

	virtual void deSerialize(std::istream &is)
	{
		// Clear everything
		clear();
		// Deserialize
		int version = readU8(is);
		if(version != 0) throw SerializationError(
				"unsupported CraftDefManager version");
		u16 count = readU16(is);
		for(u16 i=0; i<count; i++){
			// Deserialize a string and grab a CraftDefinition from it
			std::istringstream tmp_is(deSerializeString(is), std::ios::binary);
			CraftDefinition *def = CraftDefinition::deSerialize(tmp_is);
			// Register
			registerCraft(def);
		}
	}
开发者ID:AMDmi3,项目名称:minetest,代码行数:17,代码来源:craftdef.cpp

示例13: is

ServerActiveObject* LuaEntitySAO::create(ServerEnvironment *env, v3f pos,
		const std::string &data)
{
	std::istringstream is(data, std::ios::binary);
	// read version
	u8 version = readU8(is);
	// check if version is supported
	if(version != 0)
		return NULL;
	// read name
	std::string name = deSerializeString(is);
	// read state
	std::string state = deSerializeLongString(is);
	// create object
	infostream<<"LuaEntitySAO::create(name=\""<<name<<"\" state=\""
			<<state<<"\")"<<std::endl;
	return new LuaEntitySAO(env, pos, name, state);
}
开发者ID:basicinside,项目名称:minetest,代码行数:18,代码来源:content_sao.cpp

示例14: readU32

/************************************************************************************
 *
* ***********************************************************************************/
bool ScopeDome::SetupParms()
{
    targetAz = 0;

    readU32(GetImpPerTurn, stepsPerTurn);
    LOGF_INFO("Steps per turn read as %d", stepsPerTurn);

    readS32(GetHomeSensorPosition, homePosition);
    LOGF_INFO("Home position read as %d", homePosition);

    if (UpdatePosition())
        IDSetNumber(&DomeAbsPosNP, nullptr);

    if (UpdateShutterStatus())
        IDSetSwitch(&DomeShutterSP, nullptr);

    UpdateSensorStatus();
    UpdateRelayStatus();

    if (InitPark())
    {
        // If loading parking data is successful, we just set the default parking
        // values.
        SetAxis1ParkDefault(0);
    }
    else
    {
        // Otherwise, we set all parking data to default in case no parking data is
        // found.
        SetAxis1Park(0);
        SetAxis1ParkDefault(0);
    }

    uint16_t fwVersion;
    readU16(GetVersionFirmware, fwVersion);
    FirmwareVersionsN[0].value = fwVersion / 100.0;

    uint8_t fwVersionRotary;
    readU8(GetVersionFirmwareRotary, fwVersionRotary);
    FirmwareVersionsN[1].value = (fwVersionRotary + 9) / 10.0;
    FirmwareVersionsNP.s       = IPS_OK;
    IDSetNumber(&FirmwareVersionsNP, nullptr);
    return true;
}
开发者ID:azwing,项目名称:indi,代码行数:47,代码来源:scopedome_dome.cpp

示例15: readU8

void NodeMetadataList::deSerialize(std::istream &is, IGameDef *gamedef)
{
	m_data.clear();

	u8 version = readU8(is);
	
	if(version == 0){
		// Nothing
		return;
	}

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

	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;

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

		NodeMetadata *data = new NodeMetadata(gamedef);
		data->deSerialize(is);
		m_data[p] = data;
	}
}
开发者ID:FunKetApp,项目名称:minetest,代码行数:44,代码来源:nodemetadata.cpp


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