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


C++ Value::getObject方法代码示例

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


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

示例1: load

void Weapon::load(const JsonBox::Value& v, EntityManager* mgr)
{
	JsonBox::Object o = v.getObject();
	this->damage = o["damage"].getInteger();

	return;
}
开发者ID:Piepenguin1995,项目名称:retro-rpg,代码行数:7,代码来源:weapon.cpp

示例2: load

void Armor::load(JsonBox::Value& v, EntityManager* mgr)
{
	JsonBox::Object o = v.getObject();
	this->defense = o["defense"].getInteger();

	return;
}
开发者ID:shanadeshana,项目名称:cpp-rpg-tutorial,代码行数:7,代码来源:armor.cpp

示例3:

Inventory::Inventory(JsonBox::Value& v, EntityManager* mgr)
{
	JsonBox::Object o = v.getObject();
	load<Item>(o["items"], mgr);
	load<Weapon>(o["weapons"], mgr);
	load<Armor>(o["armor"], mgr);
}
开发者ID:shanadeshana,项目名称:cpp-rpg-tutorial,代码行数:7,代码来源:inventory.cpp

示例4: LoadNode

		ZD_STATUS Language::LoadNode(JsonBox::Value &node, const std::string &prefix)
		{
			if (node.isObject())
			{
				JsonBox::Object obj = node.getObject();

				for (auto &i : obj)
				{
					std::stringstream new_prefix;

					if (prefix.length() > 0)
					{
						new_prefix << prefix << m_delimiter;						
					}

					new_prefix << i.first;

					LoadNode(i.second, new_prefix.str());
				}
			}
			else if (node.isString())
			{
				m_words[prefix] = node.getString();
			}
			else if (node.isInteger())
			{
				m_words[prefix] = Helpers::String::To(node.getInt());
			}
			return ZD_NOERROR;
		}
开发者ID:NeonMercury,项目名称:zen-diary,代码行数:30,代码来源:Language.cpp

示例5: loadEffectiveItems

void
MCBackpack::loadData()
{
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    
    loadEffectiveItems();
    
    if (! __icon_loaded) {
        loadIcons();
    }
    
    if (MCGameState::sharedGameState()->isSaveFileExists()) {
        string data = userDefault->getStringForKey(kMCBackpackKey, kMCZero);
        if (data.size() > 0) {
#if MC_DEBUG_SAVEDATA == 1
            const char *output = data.c_str();
#else
            const char *input = data.c_str();
            char *output;
            mc_size_t len = strlen(input);
            MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
            JsonBox::Value v;
            v.loadFromString(output);
            
            JsonBox::Object backpack = v.getObject();
            /* 加载金钱 */
            money_ = backpack[kMCMoneyKey].getInt();
        }
    } else {
        money_ = 0;
    }
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:33,代码来源:MCBackpack.cpp

示例6: load

void Creature::load(const JsonBox::Value& v, EntityManager* mgr)
{
	JsonBox::Object o = v.getObject();
	this->name = o["name"].getString();
	this->hp = o["hp"].getInteger();
	if(o.find("hp_max") != o.end())
	{
		this->maxHp = o["hp_max"].getInteger();
	}
	else
	{
		this->maxHp = hp;
	}
	this->strength = o["strength"].getInteger();
	this->agility = o["agility"].getInteger();
	this->evasion = o["evasion"].getDouble();
	this->xp = o["xp"].getInteger();

	if(o.find("inventory") != o.end())
	{
		this->inventory = Inventory(o["inventory"], mgr);
	}
	if(o.find("equipped_weapon") != o.end())
	{
		std::string equippedWeaponName = o["equipped_weapon"].getString();
		this->equippedWeapon = equippedWeaponName == "nullptr" ? nullptr : mgr->getEntity<Weapon>(equippedWeaponName);
	}
	if(o.find("equipped_armor") != o.end())
	{
		std::string equippedArmorName = o["equipped_armor"].getString();
		this->equippedArmor = equippedArmorName == "nullptr" ? nullptr : mgr->getEntity<Armor>(equippedArmorName);
	}

	return;
}
开发者ID:Piepenguin1995,项目名称:retro-rpg,代码行数:35,代码来源:creature.cpp

示例7: Load

void Item::Load(JsonBox::Value& v, EntityManager* manager)
{
	JsonBox::Object obj = v.getObject();
	
	name = obj["name"].getString();
	description = obj["description"].getString();
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:7,代码来源:Item.cpp

示例8: Load

void Player::Load(JsonBox::Value& saveData, EntityManager* manager)
{
	Creature::Load(saveData, manager);
	JsonBox::Object obj = saveData.getObject();

	className = obj["CclassName"].getString();
	level = obj["level"].getInteger();
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:8,代码来源:Player.cpp

示例9: LoadArea

void Player::LoadArea(JsonBox::Value& areaData, EntityManager* manager)
{
	JsonBox::Object obj = areaData.getObject();
	for (auto area : obj)
	{
		std::string key = area.first;
		manager->GetEntity<Area>(key)->Load(area.second, manager);
		visitedAreas.insert(key);
	}
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:10,代码来源:Player.cpp

示例10: loadJson

void EntityManager::loadJson(const std::string& filename)
{
	JsonBox::Value v;
	v.loadFromFile(filename);

	JsonBox::Object o = v.getObject();
	for(auto entity : o)
	{
		std::string key = entity.first;
		this->data[key] = dynamic_cast<Entity*>(new T(key, entity.second, this));
	}
}
开发者ID:Piepenguin1995,项目名称:retro-rpg,代码行数:12,代码来源:entity_manager.cpp

示例11: MCObjectIdToDickKey

/**
 * 从数据包加载任务
 */
bool
MCTaskAccessor::loadTasks(const char *aFilePath)
{
    bool result = false;
    
    do {
        JsonBox::Value in;
        JsonBox::Object o;
        JsonBox::Object tasksDict;
        JsonBox::Object::iterator oIter;
        
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        CCString* pstrFileContent = CCString::createWithContentsOfFile(aFilePath);
        if (pstrFileContent) {
            in.loadFromString(pstrFileContent->getCString());
        }
#else
        in.loadFromFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(aFilePath).c_str());
#endif
        
        CC_BREAK_IF(! in.isObject());
        
        tasksDict = in.getObject();
        for (oIter = tasksDict.begin(); oIter != tasksDict.end(); ++oIter) {
            std::string t_id = oIter->first;
            const char *s_t_id = t_id.c_str();
            mc_object_id_t o_id = {
                s_t_id[0],
                s_t_id[1],
                s_t_id[2],
                s_t_id[3]
            };
            MCTask *task = new MCTask;
            task->autorelease();
            if (task) {
                task->setID(o_id);
                o = oIter->second.getObject();
                task->loadTaskContent(o);
                /* 默认为未完成状态,然后会在加载存档数据的时候更新为正确状态 */
                task->setTaskStatus(MCTaskUncompleted);
                task->proto_ = NULL;
                tasks_->setObject(task, MCObjectIdToDickKey(o_id));
            }
        }
        
        result = true;
    } while (0);
    
    return result;
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:53,代码来源:MCTaskAccessor.cpp

示例12: parse

bool Camera::parse(const JsonBox::Value &cameraVal, Camera &camera)
{
	JsonBox::Object cameraObj;

	if (!cameraVal.isObject())
	{
		cerr << "Error: Camera must be an Object." << endl;
		return false;
	}

	cameraObj = cameraVal.getObject();

	if
	(
		!cameraObj["origin"].isArray() || !cameraObj["direction"].isArray() || !cameraObj["top"].isArray()
		||
		!cameraObj["origin"].getArray()[0].isNumber()	|| !cameraObj["origin"].getArray()[1].isNumber() || !cameraObj["origin"].getArray()[2].isNumber()
		||
		!cameraObj["direction"].getArray()[0].isNumber() || !cameraObj["direction"].getArray()[1].isNumber() || !cameraObj["direction"].getArray()[2].isNumber()
		||
		!cameraObj["top"].getArray()[0].isNumber() || !cameraObj["top"].getArray()[1].isNumber() || !cameraObj["top"].getArray()[2].isNumber()
	)
	{
		cerr << "Error: invalid Camera vectors (origin, direction and top)." << endl;
		return false;
	}

	if (!cameraObj["fovy"].isNumber() || !cameraObj["width"].isInteger() || !cameraObj["height"].isInteger() || !cameraObj["filename"].isString())
	{
		cerr << "Error: invalid Camera parameters (fovy, width, height and filename)." << endl;
		return false;
	}

	Point origin = Point(cameraObj["origin"].getArray()[0].getNumber(), cameraObj["origin"].getArray()[1].getNumber(), cameraObj["origin"].getArray()[2].getNumber());
	Vector direction = Point(cameraObj["direction"].getArray()[0].getNumber(), cameraObj["direction"].getArray()[1].getNumber(), cameraObj["direction"].getArray()[2].getNumber());
	Vector top = Point(cameraObj["top"].getArray()[0].getNumber(), cameraObj["top"].getArray()[1].getNumber(), cameraObj["top"].getArray()[2].getNumber());

	camera = Camera(origin, direction, top, cameraObj["fovy"].getNumber() * (2 * M_PI) / 360.0, cameraObj["width"].getInt(), cameraObj["height"].getInt(), cameraObj["filename"].getString());

	return true;
}
开发者ID:Rafael-Ribeiro,项目名称:photonmapper,代码行数:41,代码来源:Camera.cpp

示例13: if

void
MCMercenaryManager::loadMercenaries()
{
    JsonBox::Value v;
    JsonBox::Object mercenaries;
    JsonBox::Object::iterator mercenariesIterator;
    MCDiceMaker *diceMaker = MCDiceMaker::sharedDiceMaker();
    CCString *ccstring;
    MCEffectManager *effectManager = MCEffectManager::sharedEffectManager();
    MCSkillManager *skillManager = MCSkillManager::sharedSkillManager();
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCString* pstrFileContent = CCString::createWithContentsOfFile(kMCMercenariesFilepath);
    if (pstrFileContent) {
        v.loadFromString(pstrFileContent->getCString());
    }
#else
    v.loadFromFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(kMCMercenariesFilepath).c_str());
#endif

    mercenaries = v.getObject();

    for (mercenariesIterator = mercenaries.begin();
         mercenariesIterator != mercenaries.end();
         ++mercenariesIterator) {
        const char *c_str_o_id = mercenariesIterator->first.c_str();
        mc_object_id_t m_id = {
            c_str_o_id[0],
            c_str_o_id[1],
            c_str_o_id[2],
            c_str_o_id[3]
        };
        JsonBox::Object mercenaryObject = mercenariesIterator->second.getObject();
        MCMercenary *mercenary;
        
        if (m_id.sub_class_ == '9') {
            mercenary = new MCMercenary;
        } else if (m_id.sub_class_ == '8') {
            mercenary = new MCNervousMercenary;
        } else {
            CCAssert(false, "数据错误!");
            continue;
        }
        
        mercenary->init();
        mercenary->autorelease();
        mercenary->setID(m_id);
        /* name String */
        ccstring = CCString::create(mercenaryObject["name"].getString().c_str());
        mercenary->setName(ccstring);
        ccstring->retain();
        /* face String */
        ccstring = CCString::create(mercenaryObject["face"].getString().c_str());
        mercenary->setFace(ccstring);
        ccstring->retain();
        /* build sprite sheet file path */
        ccstring = CCString::createWithFormat("%s/%c-%s",
                                              kMCSpriteSheetBaseDirectory,
                                              c_str_o_id[0] | 32,
                                              c_str_o_id + 1);
        mercenary->setSpriteSheet(ccstring);
        ccstring->retain();
        /* effect-id */
        c_str_o_id = mercenaryObject["effect-id"].getString().c_str();
        mc_object_id_t e_id = {
            c_str_o_id[0],
            c_str_o_id[1],
            c_str_o_id[2],
            c_str_o_id[3]
        };
        MCEffect *effect = effectManager->effectForObjectId(e_id);
        mercenary->setAttackEffect(effect);
        effect->retain();
        /* cost Integer */
        mercenary->cost_ = mercenaryObject["cost"].getInt();
        /* HP Integer */
        mercenary->setHP(mercenaryObject["HP"].getInt());
        mercenary->setMaxHP(mercenary->getHP());
        /* dying Integer 胆怯佣兵独有 */
        if (mercenary->mercenaryType_ == MCMercenary::MCNervousMercenary) {
            dynamic_cast<MCNervousMercenary *>(mercenary)->setDying(mercenaryObject["dying"].getInt());
        }
        /* PP Integer */
        mercenary->setPP(mercenaryObject["PP"].getInt());
        mercenary->setMaxPP(mercenary->getPP());
        /* consume Double */
        mercenary->setConsume(mercenaryObject["consume"].isDouble()
                              ? (float) mercenaryObject["consume"].getDouble()
                              : (float) mercenaryObject["consume"].getInt());
        /* exhaustion Integer */
        mercenary->setExhaustion(mercenaryObject["exhaustion"].getInt());
        /* tired Integer */
        mercenary->setTired(mercenaryObject["tired"].getInt());
        /* dexterity Integer */
        mercenary->setDexterity(mercenaryObject["dexterity"].getInt());
        /* AC Integer */
        mercenary->setAC(mercenaryObject["AC"].getInt());
        /* armor-check-penalty Integer */
        mercenary->setArmorCheckPenalty(mercenaryObject["armor-check-penalty"].getInt());
        /* damage Object */
//.........这里部分代码省略.........
开发者ID:edison9888,项目名称:__graduation_project,代码行数:101,代码来源:MCMercenaryManager.cpp

示例14: Load

void Weapon::Load(JsonBox::Value& v, EntityManager* manager)
{
	JsonBox::Object obj = v.getObject();

	damage = obj["damage"].getInteger();
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:6,代码来源:Weapon.cpp

示例15: parse

bool Material::parse(const JsonBox::Value &materialVal, Material &material)
{
	JsonBox::Object materialObj;

	double infinity = numeric_limits<double>::infinity();


	if (!materialVal.isObject())
	{
		cerr << "Error: material is not an Object." << endl;
		return false;
	}

	materialObj = materialVal.getObject();

	if (!materialObj["name"].isString())
	{
		cerr << "Error: material's name is not a string." << endl;
		return false;
	}

	material.name = materialObj["name"].getString();

	if
	(
		!materialObj["color"].isArray()
		||
		(!materialObj["color"].getArray()[0].isInteger() && !materialObj["color"].getArray()[0].isDouble())
		||
		(!materialObj["color"].getArray()[1].isInteger() && !materialObj["color"].getArray()[1].isDouble())
		||
		(!materialObj["color"].getArray()[2].isInteger() && !materialObj["color"].getArray()[2].isDouble())
	)
	{
		/* color is not an array or one of the components is neither an integer nor a double */
		cerr << "Error: material's color is not an (valid) array." << endl;
		return false;
	}

	material.color.r = (materialObj["color"].getArray()[0].isInteger() ? materialObj["color"].getArray()[0].getInt() : materialObj["color"].getArray()[0].getDouble());
	material.color.g = (materialObj["color"].getArray()[1].isInteger() ? materialObj["color"].getArray()[1].getInt() : materialObj["color"].getArray()[1].getDouble());
	material.color.b = (materialObj["color"].getArray()[2].isInteger() ? materialObj["color"].getArray()[2].getInt() : materialObj["color"].getArray()[2].getDouble());

	if
	(
		(!materialObj["roughness"].isInteger() && !materialObj["roughness"].isDouble())
		||
		(!materialObj["absorvance"].isInteger() && !materialObj["absorvance"].isDouble())
		||
		(!materialObj["emittance"].isInteger() && !materialObj["emittance"].isDouble())
		||
		(!materialObj["n"].isInteger() && !materialObj["n"].isDouble() && (!materialObj["n"].isString() || materialObj["n"].getString().compare("infinity") != 0))
	)
	{
		cerr << "Error: at least one of the material's parameters (roughness, absorvance, emittance or n) is invalid." << endl;
		return false;
	}

	material.roughness = (materialObj["roughness"].isInteger() ? materialObj["roughness"].getInt() : materialObj["roughness"].getDouble());
	material.absorvance = (materialObj["absorvance"].isInteger() ? materialObj["absorvance"].getInt() : materialObj["absorvance"].getDouble());
	material.emittance = (materialObj["emittance"].isInteger() ? materialObj["emittance"].getInt() : materialObj["emittance"].getDouble());
	material.n = (materialObj["n"].isInteger() ? materialObj["n"].getInt() : (materialObj["n"].isDouble() ? materialObj["n"].getDouble() : infinity));

	return true;
}
开发者ID:Rafael-Ribeiro,项目名称:photonmapper,代码行数:65,代码来源:Material.cpp


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