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


C++ Datum::GetScope方法代码示例

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


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

示例1: exception

Scope& Scope::AppendScope(const std::string& key)
{
	Datum* datum = Find(key);
	//TODO: Push Back when removing from Vector
	//Found key, check if type is table
	if (datum)
	{
		if (datum->IsExternal() || (datum->GetType() != Datum::DatumType::Table))
		{
			throw std::exception("This Datum is not of the right type");
		}
		Scope* newScope = new Scope();
		newScope->mParent = this;
		datum->Set(newScope, datum->Size());
		return *datum->GetScope(datum->Size() - 1);
	}
	else
	{
		//key not found
		Datum& d = Append(key, Datum::DatumType::Table);
		Scope* newScope = new Scope();
		newScope->mParent = this;
		d.Set(newScope, 0);
		return *d.GetScope(0);
	}
}
开发者ID:sakuradavik,项目名称:GameEngine,代码行数:26,代码来源:Scope.cpp

示例2: Adopt

void Scope::Adopt(Scope& childToAdopt, const std::string& key, const std::uint32_t index)
{
	if (childToAdopt.GetParent())
		childToAdopt.Orphan();

	Datum * foundDatum = Find(key);
	if (foundDatum)
	{
		if ((foundDatum->GetType() != Datum::DatumType::Table) || foundDatum->IsExternal())
			throw std::exception("You are trying to adopt into a invalid scope");

		if ((foundDatum->GetType() == Datum::DatumType::Table))
		{
			if (index >= foundDatum->Size())
			{
				foundDatum->Set(&childToAdopt, index);
				foundDatum->GetScope(index)->mParent = this;
			}
			else
			{
				Scope* temp = foundDatum->GetScope(index);
				foundDatum->Set(&childToAdopt, index);
				foundDatum->GetScope(index)->mParent = this;
				for (std::uint32_t i = index + 1; i < foundDatum->Size(); ++i)
				{
					Scope* temp2 = foundDatum->GetScope(i);
					foundDatum->Set(temp, i);
					temp = temp2;
				}
				foundDatum->Set(temp, foundDatum->Size());
			}
		}
	}
	else
	{
		Datum& d = Append(key, Datum::DatumType::Table);
		d.Set(&childToAdopt);
		d.GetScope()->mParent = this;
	}
}
开发者ID:sakuradavik,项目名称:GameEngine,代码行数:40,代码来源:Scope.cpp


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