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


C++ DataWriter::Write方法代码示例

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


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

示例1: WriteEconomy

void GameData::WriteEconomy(DataWriter &out)
{
	out.Write("economy");
	out.BeginChild();
	{
		if(!purchases.empty())
		{
			out.Write("purchases");
			out.BeginChild();
			for(const auto &pit : purchases)
				for(const auto &cit : pit.second)
					out.Write(pit.first->Name(), cit.first, cit.second);
			out.EndChild();
		}
		out.WriteToken("system");
		for(const auto &cit : GameData::Commodities())
			out.WriteToken(cit.name);
		out.Write();
		
		for(const auto &sit : GameData::Systems())
		{
			out.WriteToken(sit.second.Name());
			for(const auto &cit : GameData::Commodities())
				out.WriteToken(static_cast<int>(sit.second.Supply(cit.name)));
			out.Write();
		}
	}
	out.EndChild();
}
开发者ID:BaalEvan,项目名称:endless-sky,代码行数:29,代码来源:GameData.cpp

示例2: Save

// Save depreciation records.
void Depreciation::Save(DataWriter &out, int day) const
{
	out.Write(NAME[isStock]);
	out.BeginChild();
	{
		for(const auto &sit : ships)
		{
			out.Write("ship", sit.first->ModelName());
			out.BeginChild();
			{
				// If this is a planet's stock, remember how many outfits in
				// stock are fully depreciated. If it's the player's stock,
				// anything not recorded is considered fully depreciated, so
				// there is no reason to save records for those items.
				for(const auto &it : sit.second)
					if(isStock || (it.second && it.first > day - MAX_AGE))
						out.Write(it.first, it.second);
			}
			out.EndChild();
		}
		for(const auto &oit : outfits)
		{
			out.Write("outfit", oit.first->Name());
			out.BeginChild();
			{
				for(const auto &it : oit.second)
					if(isStock || (it.second && it.first > day - MAX_AGE))
						out.Write(it.first, it.second);
			}
			out.EndChild();
		}
	}
	out.EndChild();
}
开发者ID:Amazinite,项目名称:endless-sky,代码行数:35,代码来源:Depreciation.cpp

示例3: Save

void Personality::Save(DataWriter &out) const
{
	out.Write("personality");
	out.BeginChild();
	{
		out.Write("confusion", confusionMultiplier);
		for(const auto &it : TOKEN)
			if(flags & it.second)
				out.Write(it.first);
	}
	out.EndChild();
}
开发者ID:kikotheexile,项目名称:endless-sky,代码行数:12,代码来源:Personality.cpp

示例4: Save

void Conversation::Save(DataWriter &out) const
{
	if(!identifier.empty())
		out.Write("conversation", identifier);
	else
		out.Write("conversation");
	out.BeginChild();
	{
		for(unsigned i = 0; i < nodes.size(); ++i)
		{
			out.Write("label", i);
			const Node &node = nodes[i];
			
			if(node.scene)
				out.Write("scene", node.sceneName);	
			if(!node.conditions.IsEmpty())
			{
				if(node.data.size() > 1)
					out.Write("branch", TokenName(node.data[0].second), TokenName(node.data[1].second));
				else
					out.Write("apply", TokenName(node.data[0].second));
				
				out.BeginChild();
				{
					node.conditions.Save(out);
				}
				out.EndChild();
				continue;
			}
			if(node.isChoice)
			{
				out.Write(node.data.empty() ? "name" : "choice");
				out.BeginChild();
			}
			for(const auto &it : node.data)
			{
				// Break the text up into paragraphs.
				size_t begin = 0;
				while(begin != it.first.length())
				{
					size_t pos = it.first.find('\n', begin);
					if(pos == string::npos)
						pos = it.first.length();
					out.Write(it.first.substr(begin, pos - begin));
					if(pos == it.first.length())
						break;
					begin = pos + 1;
				}
				int index = it.second;
				if(index > 0 && static_cast<unsigned>(index) >= nodes.size())
					index = -1;
				
				WriteToken(index, out);
			}
			if(node.isChoice)
				out.EndChild();
		}
	}
	out.EndChild();
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:60,代码来源:Conversation.cpp

示例5: Save

void ConditionSet::Save(DataWriter &out) const
{
	for(const Entry &entry : entries)
		out.Write(entry.name, entry.op, entry.value);
	for(const ConditionSet &child : children)
	{
		out.Write(child.isOr ? "or" : "and");
		out.BeginChild();
		{
			child.Save(out);
		}
		out.EndChild();
	}
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:14,代码来源:ConditionSet.cpp

示例6: Save

void Galaxy::Save(DataWriter &file) const
{
    if(name.isEmpty())
        file.Write("galaxy");
    else
        file.Write("galaxy", name);
    file.BeginChild();
    {
        file.Write("pos", position.x(), position.y());
        file.Write("sprite", sprite);
        for(const DataNode &node : unparsed)
            file.Write(node);
    }
    file.EndChild();
}
开发者ID:BaalEvan,项目名称:endless-sky-editor,代码行数:15,代码来源:Galaxy.cpp

示例7: Save

void GameEvent::Save(DataWriter &out) const
{
	out.Write("event");
	out.BeginChild();
	{
		if(date)
			out.Write("date", date.Day(), date.Month(), date.Year());
		conditionsToApply.Save(out);
		
		for(const System *system : systemsToUnvisit)
			if(system && !system->Name().empty())
				out.Write("unvisit", system->Name());
		for(const Planet *planet : planetsToUnvisit)
			if(planet && !planet->Name().empty())
				out.Write("unvisit planet", planet->Name());
		
		for(const System *system : systemsToVisit)
			if(system && !system->Name().empty())
				out.Write("visit", system->Name());
		for(const Planet *planet : planetsToVisit)
			if(planet && !planet->Name().empty())
				out.Write("visit planet", planet->Name());
		
		for(const DataNode &change : changes)
			out.Write(change);
	}
	out.EndChild();
}
开发者ID:Disiuze,项目名称:endless-sky,代码行数:28,代码来源:GameEvent.cpp

示例8: Pos_ReadDirect

void LOADERDECL Pos_ReadDirect()
{
	static_assert(N <= 3, "N > 3 is not sane!");
	auto const scale = posScale;
	DataWriter dst;
	DataReader src;

	for (int i = 0; i < 3; ++i)
		dst.Write(i<N ? PosScale(src.Read<T>(), scale) : 0.f);

	LOG_VTX();
}
开发者ID:Puniasterus,项目名称:dolphin,代码行数:12,代码来源:VertexLoader_Position.cpp

示例9: TexCoord_ReadDirect

void LOADERDECL TexCoord_ReadDirect()
{
	auto const scale = tcScale[tcIndex];
	DataWriter dst;
	DataReader src;

	for (int i = 0; i != N; ++i)
		dst.Write(TCScale(src.Read<T>(), scale));

	LOG_TEX<N>();

	++tcIndex;
}
开发者ID:Asmodean-,项目名称:dolphin,代码行数:13,代码来源:VertexLoader_TextCoord.cpp

示例10: Pos_ReadIndex

void LOADERDECL Pos_ReadIndex()
{
	static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");
	static_assert(N <= 3, "N > 3 is not sane!");

	auto const index = DataRead<I>();
	auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_POSITION] + (index * arraystrides[ARRAY_POSITION]));
	auto const scale = posScale;
	DataWriter dst;

	for (int i = 0; i < 3; ++i)
		dst.Write(i<N ? PosScale(Common::FromBigEndian(data[i]), scale) : 0.f);

	LOG_VTX();
}
开发者ID:Puniasterus,项目名称:dolphin,代码行数:15,代码来源:VertexLoader_Position.cpp

示例11: TexCoord_ReadIndex

void LOADERDECL TexCoord_ReadIndex()
{
	static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");

	auto const index = DataRead<I>();
	auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_TEXCOORD0 + tcIndex]
		+ (index * g_main_cp_state.array_strides[ARRAY_TEXCOORD0 + tcIndex]));
	auto const scale = tcScale[tcIndex];
	DataWriter dst;

	for (int i = 0; i != N; ++i)
		dst.Write(TCScale(Common::FromBigEndian(data[i]), scale));

	LOG_TEX<N>();
	++tcIndex;
}
开发者ID:Asmodean-,项目名称:dolphin,代码行数:16,代码来源:VertexLoader_TextCoord.cpp

示例12: Save

// Note: the Save() function can assume this is an instantiated mission, not
// a template, so it only has to save a subset of the data.
void MissionAction::Save(DataWriter &out) const
{
	if(system.empty())
		out.Write("on", trigger);
	else
		out.Write("on", trigger, system);
	out.BeginChild();
	{
		if(!dialogText.empty())
		{
			out.Write("dialog");
			out.BeginChild();
			{
				// Break the text up into paragraphs.
				size_t begin = 0;
				while(true)
				{
					size_t pos = dialogText.find("\n\t", begin);
					if(pos == string::npos)
						pos = dialogText.length();
					out.Write(dialogText.substr(begin, pos - begin));
					if(pos == dialogText.length())
						break;
					begin = pos + 2;
				}
			}
			out.EndChild();
		}
		if(!conversation.IsEmpty())
			conversation.Save(out);
		
		for(const auto &it : gifts)
			out.Write("outfit", it.first->Name(), it.second);
		if(payment)
			out.Write("payment", payment);
		for(const auto &it : events)
			out.Write("event", it.first, it.second);
		for(const auto &name : fail)
			out.Write("fail", name);
		
		conditions.Save(out);
	}
	out.EndChild();
}
开发者ID:Arnogax,项目名称:endless-sky,代码行数:46,代码来源:MissionAction.cpp

示例13: Save

// Save the cargo manifest to a file.
void CargoHold::Save(DataWriter &out) const
{
	bool first = true;
	for(const auto &it : commodities)
		if(it.second)
		{
			if(first)
			{
				out.Write("cargo");
				out.BeginChild();
				out.Write("commodities");
				out.BeginChild();
			}
			first = false;
			
			out.Write(it.first, it.second);
		}
	if(!first)
		out.EndChild();
	
	bool firstOutfit = true;
	for(const auto &it : outfits)
		if(it.second && !it.first->Name().empty())
		{
			// It is possible this cargo hold contained no commodities, meaning
			// we must print the opening tag now.
			if(first)
			{
				out.Write("cargo");
				out.BeginChild();
			}
			first = false;
			
			// If this is the first outfit to be written, print the opening tag.
			if(firstOutfit)
			{
				out.Write("outfits");
				out.BeginChild();
			}
			firstOutfit = false;
			
			out.Write(it.first->Name(), it.second);
		}
	if(!firstOutfit)
		out.EndChild();
	if(!first)
		out.EndChild();
	
	// Mission cargo is not saved because it is repopulated when the missions
	// are read rather than when the cargo is read.
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:52,代码来源:CargoHold.cpp

示例14: Save

// Write account information to a saved game file.
void Account::Save(DataWriter &out) const
{
	out.Write("account");
	out.BeginChild();
	{
		out.Write("credits", credits);
		if(salariesOwed)
			out.Write("salaries", salariesOwed);
		out.Write("score", creditScore);
		
		out.Write("history");
		out.BeginChild();
		{
			for(int64_t worth : history)
				out.Write(worth);
		}
		out.EndChild();
		
		for(const Mortgage &mortgage : mortgages)
			mortgage.Save(out);
	}
	out.EndChild();
}
开发者ID:LocalGod79,项目名称:endless-sky,代码行数:24,代码来源:Account.cpp

示例15: Save

// Save a mission. It is safe to assume that any mission that is being saved
// is already "instantiated," so only a subset of the data must be saved.
void Mission::Save(DataWriter &out, const string &tag) const
{
	out.Write(tag, name);
	out.BeginChild();
	{
		out.Write("name", displayName);
		if(!description.empty())
			out.Write("description", description);
		if(!blocked.empty())
			out.Write("blocked", blocked);
		if(hasDeadline)
			out.Write("deadline", deadline.Day(), deadline.Month(), deadline.Year());
		if(cargoSize)
		{
			out.Write("cargo", cargo, cargoSize);
			if(illegalCargoFine)
			{
				out.BeginChild();
				{
					out.Write("illegal", illegalCargoFine);
				}
				out.EndChild();
			}
		}
		if(passengers)
			out.Write("passengers", passengers);
		if(!isVisible)
			out.Write("invisible");
		if(hasPriority)
			out.Write("priority");
		if(isMinor)
			out.Write("minor");
		if(autosave)
			out.Write("autosave");
		if(location == LANDING)
			out.Write("landing");
		if(location == ASSISTING)
			out.Write("assisting");
		if(location == BOARDING)
			out.Write("boarding");
		if(location == JOB)
			out.Write("job");
		if(!clearance.empty())
		{
			out.Write("clearance", clearance);
			clearanceFilter.Save(out);
		}
		if(!hasFullClearance)
			out.Write("infiltrating");
		if(repeat != 1)
			out.Write("repeat", repeat);
		
		if(!toComplete.IsEmpty())
		{
			out.Write("to", "complete");
			out.BeginChild();
			{
				toComplete.Save(out);
			}
			out.EndChild();
		}
		if(!toFail.IsEmpty())
		{
			out.Write("to", "fail");
			out.BeginChild();
			{
				toFail.Save(out);
			}
			out.EndChild();
		}
		if(destination)
			out.Write("destination", destination->Name());
		for(const System *system : waypoints)
			out.Write("waypoint", system->Name());
		
		for(const NPC &npc : npcs)
			npc.Save(out);
		
		// Save all the actions, because this might be an "available mission" that
		// has not been received yet but must still be included in the saved game.
		for(const auto &it : actions)
			it.second.Save(out);
		for(const auto &it : onEnter)
			it.second.Save(out);
	}
	out.EndChild();
}
开发者ID:rlane,项目名称:endless-sky,代码行数:89,代码来源:Mission.cpp


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