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


C++ DataNode::Size方法代码示例

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


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

示例1: Change

// Apply the given change to the universe.
void GameData::Change(const DataNode &node)
{
	if(node.Token(0) == "fleet" && node.Size() >= 2)
		fleets.Get(node.Token(1))->Load(node);
	else if(node.Token(0) == "galaxy" && node.Size() >= 2)
		galaxies.Get(node.Token(1))->Load(node);
	else if(node.Token(0) == "government" && node.Size() >= 2)
		governments.Get(node.Token(1))->Load(node);
	else if(node.Token(0) == "outfitter" && node.Size() >= 2)
		outfitSales.Get(node.Token(1))->Load(node, outfits);
	else if(node.Token(0) == "planet" && node.Size() >= 2)
		planets.Get(node.Token(1))->Load(node, shipSales, outfitSales);
	else if(node.Token(0) == "shipyard" && node.Size() >= 2)
		shipSales.Get(node.Token(1))->Load(node, ships);
	else if(node.Token(0) == "system" && node.Size() >= 2)
		systems.Get(node.Token(1))->Load(node, planets);
	else if(node.Token(0) == "news" && node.Size() >= 2)
		news.Get(node.Token(1))->Load(node);
	else if(node.Token(0) == "link" && node.Size() >= 3)
		systems.Get(node.Token(1))->Link(systems.Get(node.Token(2)));
	else if(node.Token(0) == "unlink" && node.Size() >= 3)
		systems.Get(node.Token(1))->Unlink(systems.Get(node.Token(2)));
	else
		node.PrintTrace("Invalid \"event\" data:");
}
开发者ID:Disiuze,项目名称:endless-sky,代码行数:26,代码来源:GameData.cpp

示例2: Load

void MissionAction::Load(const DataNode &node, const string &missionName)
{
	if(node.Size() >= 2)
		trigger = node.Token(1);
	if(node.Size() >= 3)
		system = node.Token(2);
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "dialog")
		{
			for(int i = 1; i < child.Size(); ++i)
			{
				if(!dialogText.empty())
					dialogText += "\n\t";
				dialogText += child.Token(i);
			}
			for(const DataNode &grand : child)
				for(int i = 0; i < grand.Size(); ++i)
				{
					if(!dialogText.empty())
						dialogText += "\n\t";
					dialogText += grand.Token(i);
				}
		}
		else if(child.Token(0) == "conversation" && child.HasChildren())
			conversation.Load(child);
		else if(child.Token(0) == "conversation" && child.Size() > 1)
			stockConversation = GameData::Conversations().Get(child.Token(1));
		else if(child.Token(0) == "outfit" && child.Size() >= 2)
		{
			int count = (child.Size() < 3 ? 1 : static_cast<int>(child.Value(2)));
			gifts[GameData::Outfits().Get(child.Token(1))] = count;
		}
		else if(child.Token(0) == "require" && child.Size() >= 2)
			gifts[GameData::Outfits().Get(child.Token(1))] = 0;
		else if(child.Token(0) == "payment")
		{
			if(child.Size() == 1)
				paymentMultiplier += 150;
			if(child.Size() >= 2)
				payment += child.Value(1);
			if(child.Size() >= 3)
				paymentMultiplier += child.Value(2);
		}
		else if(child.Token(0) == "event" && child.Size() >= 2)
		{
			int days = (child.Size() >= 3 ? child.Value(2) : 0);
			events[child.Token(1)] = days;
		}
		else if(child.Token(0) == "fail")
			fail.insert(child.Size() >= 2 ? child.Token(1) : missionName);
		else
			conditions.Add(child);
	}
}
开发者ID:Arnogax,项目名称:endless-sky,代码行数:56,代码来源:MissionAction.cpp

示例3: Add

void ConditionSet::Add(const DataNode &node)
{
	if(node.Size() == 2)
		Add(node.Token(0), node.Token(1));
	else if(node.Size() == 3)
		Add(node.Token(0), node.Token(1), node.Value(2));
	else if(node.Size() == 1 && node.Token(0) == "never")
		entries.emplace_back("", "!=", 0);
	else if(node.Size() == 1 && (node.Token(0) == "and" || node.Token(0) == "or"))
	{
		children.emplace_back();
		children.back().Load(node);
	}
}
开发者ID:Expack3,项目名称:endless-sky,代码行数:14,代码来源:ConditionSet.cpp

示例4: ReadEconomy

void GameData::ReadEconomy(const DataNode &node)
{
	if(!node.Size() || node.Token(0) != "economy")
		return;
	
	vector<string> headings;
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "purchases")
		{
			for(const DataNode &grand : child)
				if(grand.Size() >= 3 && grand.Value(2))
					purchases[systems.Get(grand.Token(0))][grand.Token(1)] += grand.Value(2);
		}
		else if(child.Token(0) == "system")
		{
			headings.clear();
			for(int index = 1; index < child.Size(); ++index)
				headings.push_back(child.Token(index));
		}
		else
		{
			System &system = *systems.Get(child.Token(0));
			
			int index = 0;
			for(const string &commodity : headings)
				system.SetSupply(commodity, child.Value(++index));
		}
	}
}
开发者ID:BaalEvan,项目名称:endless-sky,代码行数:30,代码来源:GameData.cpp

示例5: Load

void Outfit::Load(const DataNode &node)
{
	if(node.Size() >= 2)
		name = node.Token(1);
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "category" && child.Size() >= 2)
			category = child.Token(1);
		else if(child.Token(0) == "flare sprite" && child.Size() >= 2)
		{
			flareSprites.emplace_back(Animation(), 1);
			flareSprites.back().first.Load(child);
		}
		else if(child.Token(0) == "flare sound" && child.Size() >= 2)
			++flareSounds[Audio::Get(child.Token(1))];
		else if(child.Token(0) == "afterburner effect" && child.Size() >= 2)
			++afterburnerEffects[GameData::Effects().Get(child.Token(1))];
		else if(child.Token(0) == "thumbnail" && child.Size() >= 2)
			thumbnail = SpriteSet::Get(child.Token(1));
		else if(child.Token(0) == "weapon")
			LoadWeapon(child);
		else if(child.Token(0) == "description" && child.Size() >= 2)
		{
			description += child.Token(1);
			description += '\n';
		}
		else if(child.Size() >= 2)
			attributes[child.Token(0)] = child.Value(1);
		else
			child.PrintTrace("Skipping unrecognized attribute:");
	}
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:33,代码来源:Outfit.cpp

示例6: Load

// Load a government's definition from a file.
void Government::Load(const DataNode &node)
{
	if(node.Size() >= 2)
		name = node.Token(1);
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "swizzle" && child.Size() >= 2)
			swizzle = child.Value(1);
		else if(child.Token(0) == "color" && child.Size() >= 4)
			color = Color(child.Value(1), child.Value(2), child.Value(3));
		else if(child.Token(0) == "player reputation" && child.Size() >= 2)
			initialPlayerReputation = child.Value(1);
		else if(child.Token(0) == "attitude toward")
		{
			for(const DataNode &grand : child)
				if(grand.Size() >= 2)
				{
					const Government *gov = GameData::Governments().Get(grand.Token(0));
					attitudeToward.resize(nextID, 0.);
					attitudeToward[gov->id] = grand.Value(1);
				}
		}
		else if(child.Token(0) == "penalty for")
		{
			for(const DataNode &grand : child)
				if(grand.Size() >= 2)
				{
					if(grand.Token(0) == "assist")
						penaltyFor[ShipEvent::ASSIST] = grand.Value(1);
					if(grand.Token(0) == "disable")
						penaltyFor[ShipEvent::DISABLE] = grand.Value(1);
					if(grand.Token(0) == "board")
						penaltyFor[ShipEvent::BOARD] = grand.Value(1);
					if(grand.Token(0) == "capture")
						penaltyFor[ShipEvent::CAPTURE] = grand.Value(1);
					if(grand.Token(0) == "destroy")
						penaltyFor[ShipEvent::DESTROY] = grand.Value(1);
					if(grand.Token(0) == "atrocity")
						penaltyFor[ShipEvent::ATROCITY] = grand.Value(1);
				}
		}
		else if(child.Token(0) == "bribe" && child.Size() >= 2)
			bribe = child.Value(1);
		else if(child.Token(0) == "fine" && child.Size() >= 2)
			fine = child.Value(1);
		else if(child.Token(0) == "death sentence" && child.Size() >= 2)
			deathSentence = GameData::Conversations().Get(child.Token(1));
		else if(child.Token(0) == "friendly hail" && child.Size() >= 2)
			friendlyHail = GameData::Phrases().Get(child.Token(1));
		else if(child.Token(0) == "hostile hail" && child.Size() >= 2)
			hostileHail = GameData::Phrases().Get(child.Token(1));
	}
}
开发者ID:rlane,项目名称:endless-sky,代码行数:55,代码来源:Government.cpp

示例7:

Fleet::Variant::Variant(const DataNode &node)
{
	weight = (node.Size() < 2) ? 1 : static_cast<int>(node.Value(1));
	
	for(const DataNode &child : node)
	{
		int n = 1;
		if(child.Size() > 1 && child.Value(1) >= 1.)
			n = static_cast<int>(child.Value(1));
		ships.insert(ships.end(), n, GameData::Ships().Get(child.Token(0)));
	}
}
开发者ID:rlane,项目名称:endless-sky,代码行数:12,代码来源:Fleet.cpp

示例8: Add

void ConditionSet::Add(const DataNode &node)
{
	if(node.Size() == 2)
	{
		if(!Add(node.Token(0), node.Token(1)))
			node.PrintTrace("Unrecognized condition expression:");
	}
	else if(node.Size() == 3)
	{
		if(!Add(node.Token(0), node.Token(1), node.Value(2)))
			node.PrintTrace("Unrecognized condition expression:");
	}
	else if(node.Size() == 1 && node.Token(0) == "never")
		entries.emplace_back("", "!=", 0);
	else if(node.Size() == 1 && (node.Token(0) == "and" || node.Token(0) == "or"))
	{
		children.emplace_back();
		children.back().Load(node);
	}
	else
		node.PrintTrace("Unrecognized condition expression:");
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:22,代码来源:ConditionSet.cpp

示例9: Load

void Galaxy::Load(const DataNode &node)
{
    if(node.Size() >= 2)
        name = node.Token(1);

    for(const DataNode &child : node)
    {
        if(child.Token(0) == "pos" && child.Size() >= 3)
            position = QVector2D(child.Value(1), child.Value(2));
        else if(child.Token(0) == "sprite" && child.Size() >= 2)
            sprite = child.Token(1);
        else
            unparsed.push_back(child);
    }
}
开发者ID:BaalEvan,项目名称:endless-sky-editor,代码行数:15,代码来源:Galaxy.cpp

示例10: ParseTextNode

// Format and add the text from the given node to the given string.
void Dialog::ParseTextNode(const DataNode &node, size_t startingIndex, string &text)
{
	for(int i = startingIndex; i < node.Size(); ++i)
	{
		if(!text.empty())
			text += "\n\t";
		text += node.Token(i);
	}
	for(const DataNode &child : node)
		for(int i = 0; i < child.Size(); ++i)
		{
			if(!text.empty())
				text += "\n\t";
			text += child.Token(i);
		}
}
开发者ID:Amazinite,项目名称:endless-sky,代码行数:17,代码来源:Dialog.cpp

示例11: Write

void DataWriter::Write(const DataNode &node)
{
    for(int i = 0; i < node.Size(); ++i)
        WriteToken(node.Token(i));
    Write();

    if(node.begin() != node.end())
    {
        BeginChild();
        {
            for(const DataNode &child : node)
                Write(child);
        }
        EndChild();
    }
}
开发者ID:endless-sky,项目名称:endless-sky-editor,代码行数:16,代码来源:DataWriter.cpp

示例12: Load

void Personality::Load(const DataNode &node)
{
	flags = 0;
	for(int i = 1; i < node.Size(); ++i)
		Parse(node.Token(i));
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "confusion" && child.Size() >= 2)
			confusionMultiplier = child.Value(1);
		else
		{
			for(int i = 0; i < child.Size(); ++i)
				Parse(child.Token(i));
		}
	}
}
开发者ID:kikotheexile,项目名称:endless-sky,代码行数:17,代码来源:Personality.cpp

示例13: Change

// Apply the given change to the universe.
void GameData::Change(const DataNode &node)
{
	if(node.Token(0) == "fleet" && node.Size() >= 2)
		fleets.Get(node.Token(1))->Load(node);
	else if(node.Token(0) == "government" && node.Size() >= 2)
		governments.Get(node.Token(1))->Load(node);
	else if(node.Token(0) == "outfitter" && node.Size() >= 2)
		outfitSales.Get(node.Token(1))->Load(node, outfits);
	else if(node.Token(0) == "planet" && node.Size() >= 2)
		planets.Get(node.Token(1))->Load(node, shipSales, outfitSales);
	else if(node.Token(0) == "shipyard" && node.Size() >= 2)
		shipSales.Get(node.Token(1))->Load(node, ships);
	else if(node.Token(0) == "system" && node.Size() >= 2)
		systems.Get(node.Token(1))->Load(node, planets);
	else if(node.Token(0) == "link" && node.Size() >= 3)
		systems.Get(node.Token(1))->Link(systems.Get(node.Token(2)));
	else if(node.Token(0) == "unlink" && node.Size() >= 3)
		systems.Get(node.Token(1))->Unlink(systems.Get(node.Token(2)));
}
开发者ID:BaalEvan,项目名称:endless-sky,代码行数:20,代码来源:GameData.cpp

示例14: Load

// Load a planet's description from a file.
void Planet::Load(const DataNode &node)
{
    if(node.Size() < 2)
        return;
    name = node.Token(1);

    for(const DataNode &child : node)
    {
        if(child.Token(0) == "landscape" && child.Size() >= 2)
            landscape = child.Token(1);
        else if(child.Token(0) == "attributes")
        {
            for(int i = 1; i < child.Size(); ++i)
                attributes.push_back(child.Token(i));
        }
        else if(child.Token(0) == "description" && child.Size() >= 2)
        {
            if(!description.isEmpty() && !child.Token(1).isEmpty() && child.Token(1)[0] > ' ')
                description += '\t';
            description += child.Token(1);
            description += '\n';
        }
        else if(child.Token(0) == "spaceport" && child.Size() >= 2)
        {
            if(!spaceport.isEmpty() && !child.Token(1).isEmpty() && child.Token(1)[0] > ' ')
                spaceport += '\t';
            spaceport += child.Token(1);
            spaceport += '\n';
        }
        else if(child.Token(0) == "shipyard" && child.Size() >= 2)
            shipyard.push_back(child.Token(1));
        else if(child.Token(0) == "outfitter" && child.Size() >= 2)
            outfitter.push_back(child.Token(1));
        else if(child.Token(0) == "required reputation" && child.Size() >= 2)
            requiredReputation = child.Value(1);
        else if(child.Token(0) == "bribe" && child.Size() >= 2)
            bribe = child.Value(1);
        else if(child.Token(0) == "security" && child.Size() >= 2)
            security = child.Value(1);
        else
            unparsed.push_back(child);
    }
}
开发者ID:BaalEvan,项目名称:endless-sky-editor,代码行数:44,代码来源:Planet.cpp

示例15: Load

void Fleet::Load(const DataNode &node)
{
	if(node.Size() >= 2)
		fleetName = node.Token(1);
	
	// If Load() has already been called once on this fleet, any subsequent
	// calls will replace the variants instead of adding to them.
	bool resetVariants = !variants.empty();
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "government" && child.Size() >= 2)
			government = GameData::Governments().Get(child.Token(1));
		else if(child.Token(0) == "names" && child.Size() >= 2)
			names = GameData::Phrases().Get(child.Token(1));
		else if(child.Token(0) == "fighters" && child.Size() >= 2)
			fighterNames = GameData::Phrases().Get(child.Token(1));
		else if(child.Token(0) == "cargo" && child.Size() >= 2)
			cargo = static_cast<int>(child.Value(1));
		else if(child.Token(0) == "commodities" && child.Size() >= 2)
		{
			commodities.clear();
			for(int i = 1; i < child.Size(); ++i)
				commodities.push_back(child.Token(i));
		}
		else if(child.Token(0) == "personality")
			personality.Load(child);
		else if(child.Token(0) == "variant")
		{
			if(resetVariants)
			{
				resetVariants = false;
				variants.clear();
				total = 0;
			}
			variants.emplace_back(child);
			total += variants.back().weight;
		}
		else
			child.PrintTrace("Skipping unrecognized attribute:");
	}
}
开发者ID:kikotheexile,项目名称:endless-sky,代码行数:42,代码来源:Fleet.cpp


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