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


C++ date::diffInYears方法代码示例

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


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

示例1: if

CK2Character::CK2Character(Object* obj, const map<int, CK2Dynasty*>& dynasties, const map<int, CK2Trait*>& traitTypes, date theDate)
{
	num			= atoi( obj->getKey().c_str() );
	name			= obj->getLeaf("birth_name");
	religion		= CK2Religion::getReligion(obj->getLeaf("religion"));
	culture		= obj->getLeaf("culture");

	vector<Object*> pobjs = obj->getValue("prestige");
	if (pobjs.size() > 0)
		prestige = atof(pobjs[0]->getLeaf().c_str());
	else
		prestige = 0.0;

	pobjs = obj->getValue("piety");
	if (pobjs.size() > 0)
		piety = atof(pobjs[0]->getLeaf().c_str());
	else
		piety = 0.0;

	pobjs = obj->getValue("score");
	if (pobjs.size() > 0)
		score = atof(pobjs[0]->getLeaf().c_str());
	else
		score = 0.0;

	dynasty		= NULL;
	map<int, CK2Dynasty*>::const_iterator dynItr	= dynasties.find(  atoi( obj->getLeaf("dynasty").c_str() )  );
	if (dynItr != dynasties.end())
	{
		dynasty = dynItr->second;
		dynasty->addMember(this);
	}
	else
	{
		log("\t\tError: no dynasty for character %d (%s).\n", num, name.c_str());
	}
	birthDate	= obj->getLeaf("birth_date");
	age			= theDate.diffInYears(birthDate);
	vector<Object*> deathObj = obj->getValue("death_date");
	if (deathObj.size() > 0)
	{
		dead			= true;
		deathDate	= deathObj[0]->getLeaf();
	}
	else
	{
		dead			= false;
		deathDate	= (string)"1.1.1";
	}
	vector<Object*> femaleObj = obj->getValue("female");
	if (femaleObj.size() > 0)
	{
		female = ( femaleObj[0]->getLeaf() == "yes" );
	}
	else
	{
		female = false;
	}
	vector<Object*> bastardObj = obj->getValue("is_bastard");
	if (bastardObj.size() > 0)
	{
		bastard = ( bastardObj[0]->getLeaf() == "yes" );
	}
	else
	{
		bastard = false;
	}
	titles.clear();

	vector<Object*> fatherObj = obj->getValue("father");
	if (fatherObj.size() > 0)
	{
		fatherNum = atoi( fatherObj[0]->getLeaf().c_str() );
	}
	else
	{
		fatherNum = -1;
	}
	father = NULL;
	vector<Object*> motherObj = obj->getValue("mother");
	if (motherObj.size() > 0)
	{
		motherNum = atoi( motherObj[0]->getLeaf().c_str() );
	}
	else
	{
		motherNum = -1;
	}
	mother = NULL;

	vector<Object*> spouseObj = obj->getValue("spouse");
	for (vector<Object*>::iterator itr = spouseObj.begin(); itr != spouseObj.end(); ++itr)
	{
		spouseNums.push_back(atoi((*itr)->getLeaf().c_str()));
	}

	children.clear();
	vector<Object*> guardianObj = obj->getValue("guardian");
	if (guardianObj.size() > 0)
	{
//.........这里部分代码省略.........
开发者ID:gthx2,项目名称:paradoxGameConverters,代码行数:101,代码来源:CK2Character.cpp


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