Beispiel #1
0
void main() {
	struct Person nathan;
	struct Person *nathan_pt;
	nathan_pt = &nathan;
	nathan = setMember("Nathan Cho", 17);
	printPerson(nathan_pt);
}
Beispiel #2
0
void ArrayVariant::Value::setValue(const Variant::Value& value) {
    const Value& arrayValue = dynamic_cast<const Value&>(value);

    resize(arrayValue.getNumMembers());

    for (size_t i = 0; i < getNumMembers(); ++i)
        setMember(i, arrayValue.getMember(i));
}
Beispiel #3
0
bool isMember(const _enum_name& e, const StringVector& strValues) {
  for (const std::string& str : strValues) {
    try {
      _enum_name setMember(str);
      if (e == setMember) { return true; }
    }
    catch (...) {}
  }
  return false;
}
Beispiel #4
0
void ArrayVariant::Value::setMember(const std::string& name, const Variant&
                                    member) {
    int index;

    try {
        index = boost::lexical_cast<int>(name);
    }
    catch (...) {
        throw NoSuchMemberException(name);
    }

    return setMember(index, member);
}
Beispiel #5
0
	langObject Class::setMember(std::string& name, langObject obj, lang::scope *access)
	{
		return setMember(name.c_str(), obj, access);
	}
Beispiel #6
0
void PackageManager::parseUserInfo(HaypiJsonPtr data)
{
    auto bag = getCurrBag();
    auto player = getCurrPlayer();
    
    int event = 0;
    
    Json::Value mem = (*data)["Member"];
    if (!mem.isNull()) {
        Member* member = Member::create();
        player->setMember(member);
        
        member->setBanTalk(mem["BanTalk"].asInt());
        member->setDeviceID(mem["DeviceID"].asString());
        member->setEMail(mem["EMail"].asString());
        member->setGCName(mem["GCName"].asString());
        member->setGCType(mem["GCType"].asInt());
        member->setInviteBy(mem["InvitedBy"].asString());
        member->setLoginTime(mem["LoginTime"].asDouble());
        member->setMemberID(mem["MemberID"].asInt());
        member->setName(mem["Name"].asString());
        member->setRegionID(mem["RegionID"].asString());
        member->setRegisterTime(mem["RegisterTime"].asDouble());
        member->setStatus(mem["Status"].asInt());
        
        player->setUserID(member->getMemberID());
        player->setUserName(member->getName());
    }
    
    Json::Value& stime = (*data)["STime"];
    if (stime != nullptr) {
        GameTime::setServerTime(stime.asInt());
    }
    
    Json::Value& wareall = data->at("WareHouse");
    if(wareall != nullptr)
    {
        bag->updateWareByJsonValue(wareall);
        event |= (int)PackageEvent::WareHouse;
    }
    
    Json::Value& userData = (*data)["UserData"];
    if (userData != Json::Value::null) {
        getCurrMap()->setMaxMap(userData["MaxMap"].asInt());
        GameTime::setServerTime(userData["STime"].asInt());
        event |= (int)PackageEvent::Map;
    }
    
    Json::Value& pets = (*data)["PetList"];
    if (pets != Json::Value::null) {
        bag->updateAllPetsByJsonValue(pets);
        event |= (int)PackageEvent::PetInfo;
    }
    
    Json::Value& teams = (*data)["Teams"];
    if (teams != Json::Value::null) {
        bag->updateAllTeamsByJsonValue(teams);
        event |= (int)PackageEvent::TeamInfo;
    }
    
    Json::Value& city = data->at("City");
    if (city != nullptr) {
        bag->updateTechInfoByJsonValue(city);
        event |= (int)PackageEvent::TechInfo;
    }
    
    Json::Value& queue = data->at("Queue");
    if (queue != nullptr) {
        bag->updateTechQueueByJsonValue(queue);
        event |= (int)PackageEvent::TechInfo;
    }
    
    Json::Value& petChange = data->at("PetChange");
    if (petChange != nullptr) {
        bag->updatePetByJsonValue(petChange);
        event |= (int)PackageEvent::PetInfo;
    }
    
    Json::Value& petDel = data->at("Pet_Dels");
    if (petDel != nullptr) {
        bag->updatePetDelByJsonValue(petDel);
        event |= (int)PackageEvent::PetInfo;
    }
    
    Json::Value& teamChange = data->at("TeamChange");
    if (teamChange != nullptr) {
        bag->updateTeamByJsonValue(teamChange);
        event |= (int)PackageEvent::TeamInfo;
    }
    
    Json::Value& itemadd = data->at("Item_Add");
    if(itemadd != nullptr)
    {
        bag->updateItemAddByJsonValue(itemadd);
        event |= (int)PackageEvent::WareHouse;
    }
    
    Json::Value& itemdel = data->at("Item_Del");
    if(itemdel != nullptr)
    {
        bag->updateItemDelByJsonValue(itemdel);
        event |= (int)PackageEvent::WareHouse;
    }
    
    Json::Value& res = data->at("Res");
    if (res != nullptr) {
        bag->updateTimerInfoByJsonValue(res);
        event |= (int)PackageEvent::ResTimer;
        event |= (int)PackageEvent::WareHouse;
    }
    
    if (event != 0) {
        event |= (int)PackageEvent::UserInfo;
        NetManager::getInstance()->dispatcherCustomEvent((PackageEvent)event, data);
    }
}
Beispiel #7
0
Array::Array(const std::list<Variable> &values) : _values(values) {
	setMember("push", new NativeFunction(boost::bind(as_push, _1), true, false, false));
	setMember("pop", new NativeFunction(boost::bind(as_pop, _1), true, false, false));
}