Пример #1
0
SnapshotPtr UniformSample::getSnapshot() const {
    boost::lock_guard<boost::mutex> lock(mutex_);
    Int64Vector::const_iterator begin_itr(values_.begin());
    Int64Vector::const_iterator end_itr(values_.begin());
    std::advance(end_itr, size());
    return SnapshotPtr(new Snapshot(ValueVector(begin_itr, end_itr)));
}
Пример #2
0
AnimateByGID* AnimateByGID::clone() const
{
	// no copy constructor
	auto a = new AnimateByGID();
	a->initWithGids(ValueVector(_gids),_layer,_site,_duration);
	a->autorelease();
	return a;
}
Пример #3
0
AnimateByGID::AnimateByGID()
: _splitTimes(new std::vector<float>)
, _nextFrame(0)
, _origFrame(nullptr)
, _executedLoops(0)
, _gids(ValueVector())
, _frameDisplayedEvent(nullptr)
{

}
Пример #4
0
ReplSetTag ReplSetTagConfig::makeTag(StringData key, StringData value) {
    int32_t keyIndex = _findKeyIndex(key);
    if (size_t(keyIndex) == _tagData.size()) {
        _tagData.push_back(make_pair(key.toString(), ValueVector()));
    }
    ValueVector& values = _tagData[keyIndex].second;
    for (size_t valueIndex = 0; valueIndex < values.size(); ++valueIndex) {
        if (values[valueIndex] != value)
            continue;
        return ReplSetTag(keyIndex, int32_t(valueIndex));
    }
    values.push_back(value.toString());
    return ReplSetTag(keyIndex, int32_t(values.size()) - 1);
}
Пример #5
0
bool GameSettings::updateSettings()
{
	settings["curr"] = Value(getCurrRickshaw());

	auto temp = ValueVector();
	for (unsigned int i = 0; i < getRickshawUnlocks().size(); i++) {
		temp.push_back(Value(getRickshawUnlocks()[i]));
	}

	settings["unlock"] = temp;

	FileUtils::getInstance()->writeToFile(settings, configFile);
	// TODO implement failed write error return value
	return true;
}
Пример #6
0
//itemをVectorで受け取り、縦に自動で並べる(n型配置)
Menu* createMenuWithArrayColAlign(Node* parent, const Vector<MenuItem*>& arrayOfItems, int col, int zOrder, Vec2 pos){
    Menu* menu = Menu::createWithArray(arrayOfItems);
    menu->setPosition(pos);
    
    ValueVector cols = ValueVector();
    int itemCount = (int)arrayOfItems.size();
    while (itemCount > 0) {
        int thisCol = std::min(col, itemCount);
        cols.push_back(Value(thisCol));
        itemCount -= thisCol;
    }
    menu->alignItemsInRowsWithArray(cols);
    menu->setName(std::string("menu") + arrayOfItems.at(0)->getName());
    
    if (parent) {
        parent->addChild(menu, zOrder);
    }
    return menu;
}
Пример #7
0
//itemをVectorで受け取り、横に自動で並べる(Z型配置)
Menu* createMenuWithArrayRowAlign(Node* parent, const Vector<MenuItem*>& arrayOfItems, int row, int zOrder, Vec2 pos){
    Menu* menu = Menu::createWithArray(arrayOfItems);
    menu->setPosition(pos);
    
    ValueVector rows = ValueVector();
    int itemCount = (int)arrayOfItems.size();
    while (itemCount > 0) {
        int thisRow = std::min(row, itemCount);
        rows.push_back(Value(thisRow));
        itemCount -= thisRow;
    }
    /*
     int col = ((int)arrayOfItems.size() + row - 1) / row;
     for (int i = 0; i < col; ++i) {
     rows.push_back(Value(row));
     }*/
    menu->alignItemsInColumnsWithArray(rows);
    menu->setName(std::string("menu") + arrayOfItems.at(0)->getName());
    
    if (parent) {
        parent->addChild(menu, zOrder);
    }
    return menu;
}
ValueVector FileUtils::getValueVectorFromFile(const std::string& filename) {
    return ValueVector();
}
    void startElement(void *ctx, const char *name, const char **atts)
    {
        CC_UNUSED_PARAM(ctx);
        CC_UNUSED_PARAM(atts);
        const std::string sName(name);
        if( sName == "dict" )
        {
            if(_resultType == SAX_RESULT_DICT && _rootDict.empty())
            {
                _curDict = &_rootDict;
            }

            _state = SAX_DICT;

            SAXState preState = SAX_NONE;
            if (! _stateStack.empty())
            {
                preState = _stateStack.top();
            }

            if (SAX_ARRAY == preState)
            {
                // add a new dictionary into the array
                _curArray->push_back(Value(ValueMap()));
                _curDict = &(_curArray->rbegin())->asValueMap();
            }
            else if (SAX_DICT == preState)
            {
                // add a new dictionary into the pre dictionary
                CCASSERT(! _dictStack.empty(), "The state is wrong!");
                ValueMap* preDict = _dictStack.top();
                (*preDict)[_curKey] = Value(ValueMap());
                _curDict = &(*preDict)[_curKey].asValueMap();
            }

            // record the dict state
            _stateStack.push(_state);
            _dictStack.push(_curDict);
        }
        else if(sName == "key")
        {
            _state = SAX_KEY;
        }
        else if(sName == "integer")
        {
            _state = SAX_INT;
        }
        else if(sName == "real")
        {
            _state = SAX_REAL;
        }
        else if(sName == "string")
        {
            _state = SAX_STRING;
        }
        else if (sName == "array")
        {
            _state = SAX_ARRAY;

            if (_resultType == SAX_RESULT_ARRAY && _rootArray.empty())
            {
                _curArray = &_rootArray;
            }
            SAXState preState = SAX_NONE;
            if (! _stateStack.empty())
            {
                preState = _stateStack.top();
            }

            if (preState == SAX_DICT)
            {
                (*_curDict)[_curKey] = Value(ValueVector());
                _curArray = &(*_curDict)[_curKey].asValueVector();
            }
            else if (preState == SAX_ARRAY)
            {
                CCASSERT(! _arrayStack.empty(), "The state is wrong!");
                ValueVector* preArray = _arrayStack.top();
                preArray->push_back(Value(ValueVector()));
                _curArray = &(_curArray->rbegin())->asValueVector();
            }
            // record the array state
            _stateStack.push(_state);
            _arrayStack.push(_curArray);
        }
        else
        {
            _state = SAX_NONE;
        }
    }