VariantList GoodStock::save() const { VariantList stream; stream.push_back( (int)_type ); stream.push_back( _maxQty ); stream.push_back( _currentQty ); return stream; }
VariantList save() const { VariantList ret; for( auto& mapItem : *this ) { ret.push_back( Variant( (int)mapItem.first ) ); ret.push_back( Variant( mapItem.second->value() ) ); } return ret; }
void TileOverlay::save( VariantMap& stream ) const { VariantList config; config.push_back( (int)_d->overlayType ); config.push_back( Variant( MetaDataHolder::instance().getData( _d->overlayType ).getName() ) ); config.push_back( getTile().getIJ() ); stream[ "config" ] = config; stream[ "picture" ] = Variant( _d->picture.getName() ); stream[ "pictureOffset" ] = _d->picture.getOffset(); stream[ "size" ] = _d->size; stream[ "isDeleted" ] = _d->isDeleted; stream[ "name" ] = Variant( _d->name ); }
VariantList proxyProcessList( const VariantList &args, const JSAPIImplPtr& self, const JSAPIImplPtr& proxy ) { VariantList newArgs; for (VariantList::const_iterator it = args.begin(); it != args.end(); ++it) { if (it->is_of_type<JSAPIPtr>() && it->convert_cast<JSAPIPtr>() == self) { newArgs.push_back(proxy); } else if (it->is_of_type<VariantList>()) { newArgs.push_back(proxyProcessList(it->convert_cast<VariantList>(), self, proxy)); } else if (it->is_of_type<VariantMap>()) { newArgs.push_back(proxyProcessMap(it->convert_cast<VariantMap>(), self, proxy)); } else { newArgs.push_back(*it); } } return newArgs; }
virtual VariantList save() const { VariantList ret; for (const auto& item : *this) { ret.push_back(VariantList(item.first, item.second)); } return ret; }
void JSAPIImpl::FireJSEvent( const std::string& eventName, const VariantMap &members, const VariantList &arguments ) { if (!m_valid) // When invalidated, do nothing more return; { JSAPIImplPtr self(shared_from_this()); boost::recursive_mutex::scoped_lock _l(m_proxyMutex); ProxyList::iterator proxyIt = m_proxies.begin(); while (proxyIt != m_proxies.end()) { JSAPIImplPtr proxy(proxyIt->lock()); if (!proxy) { // Since you can't use a shared_ptr in a destructor, there // is no way for the proxy object to let us know when it goes // away; thus when we find them, we remove them for efficiency proxyIt = m_proxies.erase(proxyIt); continue; } VariantList newArgs = proxyProcessList(arguments, self, proxy); VariantMap newMap = proxyProcessMap(members, self, proxy); proxy->FireJSEvent(eventName, newMap, newArgs); proxyIt++; } } VariantList args; args.push_back(CreateEvent(shared_from_this(), eventName, members, arguments)); { boost::recursive_mutex::scoped_lock _l(m_eventMutex); EventContextMap::iterator it(m_eventMap.begin()); while (it != m_eventMap.end()) { std::pair<EventMultiMap::iterator, EventMultiMap::iterator> range = it->second.equal_range(eventName); for (EventMultiMap::const_iterator eventIt = range.first; eventIt != range.second; eventIt++) { eventIt->second->InvokeAsync("", args); } ++it; } } // Some events are registered as a jsapi object with a method of the same name as the event { boost::recursive_mutex::scoped_lock _l(m_eventMutex); EventIfaceContextMap::iterator it(m_evtIfaces.begin()); while (it != m_evtIfaces.end()) { for (EventIFaceMap::const_iterator ifaceIt = it->second.begin(); ifaceIt != it->second.end(); ifaceIt++) { ifaceIt->second->InvokeAsync(eventName, args); } } } }
VariantList save() { VariantList ret; ret.push_back( sellPrice ); ret.push_back( buyPrice ); ret.push_back( exportLimit ); ret.push_back( importLimit ); ret.push_back( soldGoods ); ret.push_back( bougthGoods ); ret.push_back( stacking ); ret.push_back( order ); ret.push_back( vendor ); return ret; }
VariantMap Storage::save() const { VariantMap stream = good::Store::save(); stream[ "max" ] = _gsd->capacity; VariantList stockSave; for( auto& stockInfo : _gsd->stocks ) stockSave.push_back( stockInfo->save() ); stream[ "stock" ] = stockSave; return stream; }
VariantMap SimpleGoodStore::save() const { VariantMap stream = GoodStore::save(); stream[ "max" ] = _maxQty; VariantList stockSave; for( std::vector<GoodStock>::const_iterator itStock = _goodStockList.begin(); itStock != _goodStockList.end(); itStock++) { stockSave.push_back( (*itStock).save() ); } stream[ "stock" ] = stockSave; return stream; }
const VariantList Database::getValueForItemNameAsVector( const std::string &item) const { VariantList list; std::istringstream f( getValueForItemName( item )->getString() ); std::string s; while (getline(f, s, ' ')) { if ( !s.empty() ) list.push_back( s ); } return list; }
/** * parseArray */ Variant Json::parseArray(const std::string &json, int &index, bool &success) { VariantList list; Json::nextToken(json, index); bool done = false; while(!done) { int token = Json::lookAhead(json, index); if(token == JsonTokenNone) { success = false; return VariantList(); } else if(token == JsonTokenComma) { Json::nextToken(json, index); } else if(token == JsonTokenSquaredClose) { Json::nextToken(json, index); break; } else { Variant value = Json::parseValue(json, index, success); if(!success) { return VariantList(); } list.push_back(value); } } return Variant(list); }