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


C++ String8::data方法代码示例

本文整理汇总了C++中String8::data方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::data方法的具体用法?C++ String8::data怎么用?C++ String8::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String8的用法示例。


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

示例1: ReadFrom

void Room::ReadFrom(
	_In_ String8 file // xml
	)
{
	using namespace std;
	using namespace rapidxml;

	xml_document<> xmlDocument;
	xml_node<> *xmlRootNode;

	// Read the xml file into a vector
	ifstream reader(file);
	vector<char> buffer(
		(istreambuf_iterator<char>(reader)), 
		(istreambuf_iterator<char>())
		);

	buffer.push_back('\0');

	xmlDocument.parse<0>(&buffer[0]);
	xmlRootNode = xmlDocument.first_node(RoomSpec_RootNode);

	auto terrain = xmlRootNode->first_node(RoomSpec_TerrainNode);
	{
		auto terrainDimension = terrain->first_node(RoomSpec_DimensionsNode);
		m_terrain.u16XDim = atoi(terrainDimension->first_attribute(RoomSpec_XAttribute)->value());
		m_terrain.u16YDim = atoi(terrainDimension->first_attribute(RoomSpec_YAttribute)->value());
	}

	{
		auto npcId = 0;
		auto npc = terrain->first_node(RoomSpec_NPCNode);
		auto npcNode = npc->first_node(RoomSpec_PlayerNode);
		for ( /*npcNode*/; npcNode; npcNode = npcNode->next_sibling(RoomSpec_PlayerNode), npcId++)
		{
			NPC npcInfo;
			npcInfo.Id = atoi(npcNode->first_attribute(RoomSpec_IdAttribute)->value());
			npcInfo.u16XStart = _To_single atof(npcNode->first_node(RoomSpec_StartNode)->first_attribute(RoomSpec_XAttribute)->value());
			npcInfo.u16YStart = _To_single atof(npcNode->first_node(RoomSpec_StartNode)->first_attribute(RoomSpec_YAttribute)->value());
			npcInfo.u16XFinish = _To_single atof(npcNode->first_node(RoomSpec_FinishNode)->first_attribute(RoomSpec_XAttribute)->value());
			npcInfo.u16YFinish = _To_single atof(npcNode->first_node(RoomSpec_FinishNode)->first_attribute(RoomSpec_YAttribute)->value());
			m_terrain.vnPlayers.push_back(npcInfo);
		}
	}

	{
		auto slicesNode = terrain->first_node(RoomSpec_SlicesNode);
		m_terrain.fTileRadii = _To_single atof(slicesNode->first_attribute(RoomSpec_TileRadiiNode)->value());
		auto sliceNode = slicesNode->first_node(RoomSpec_SliceNode);
		for ( /*sliceNode*/; sliceNode; sliceNode = sliceNode->next_sibling(RoomSpec_SliceNode))
		{
			String8 sliceSeq = sliceNode->value();

			PrintToDebugWindowOnly8(sliceSeq.data());

			for ( auto seqElement : sliceSeq ) m_terrain.vnRoom.push_back(seqElement);
		}
	}

	PrintToDebugWindowOnly8("");

	{
		auto textures = xmlRootNode->first_node(RoomSpec_TexturesNode);
		while (textures != nullptr)
		{
			auto clientMatches = strcmp(
				textures->first_attribute(RoomSpec_ClientAttribute)->value(), 
				RoomSpec_Client
				) == 0;

			if (clientMatches)
			{
				auto path = textures->first_node(RoomSpec_PathAttribute);
				for ( /*sliceNode*/; path; path = path->next_sibling(RoomSpec_PathAttribute))
				{
					std::string id = path->first_attribute(RoomSpec_IdAttribute)->value();
					std::string file = path->value();
					m_paths[id] = file;
				}

				break;
			}
			else
			{
				textures = xmlRootNode->next_sibling(RoomSpec_TexturesNode);
			}
		}
	}

	// tiles

	for ( auto y = 0; y < m_terrain.u16YDim; y++) // loop though 
	for ( auto x = 0; x < m_terrain.u16XDim; x++) // all tiles
	{
		Tile tile;
		ZeroTile(&tile);
		tile.X = ( _To_single x - _To_single m_terrain.u16YDim * 0.5f - 0.5f); // * TileRadii;
		tile.Y = -( _To_single m_terrain.u16XDim * 0.5f - _To_single y + 0.5f); // * TileRadii;

		//tile.World = Reign::Matrix::CreateScale(TileRadii);
//.........这里部分代码省略.........
开发者ID:VladSerhiienko,项目名称:Nena.v.1,代码行数:101,代码来源:Room.cpp


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