issue #2790: Vector<T> replaces Array* finished.

This commit is contained in:
James Chen 2013-11-29 11:36:42 +08:00
parent 0d581a15d8
commit cb215bc931
11 changed files with 129 additions and 163 deletions

View File

@ -2129,7 +2129,7 @@ Animate* Animate::reverse() const
if (oldArray.count() > 0)
{
for (auto iter = oldArray.rcbegin(); iter != oldArray.rcend(); ++iter)
for (auto iter = oldArray.crbegin(); iter != oldArray.crend(); ++iter)
{
AnimationFrame* animFrame = *iter;
if (!animFrame)

View File

@ -916,19 +916,14 @@ void LayerGradient::setCompressedInterpolation(bool compress)
LayerMultiplex::LayerMultiplex()
: _enabledLayer(0)
, _layers(NULL)
{
}
LayerMultiplex::~LayerMultiplex()
{
if (_layers)
{
for (auto& item : *_layers)
{
static_cast<Layer*>(item)->cleanup();
}
_layers->release();
}
_layers.forEach([](Layer* layer){
layer->cleanup();
});
}
LayerMultiplex * LayerMultiplex::create(Layer * layer, ...)
@ -967,7 +962,7 @@ LayerMultiplex* LayerMultiplex::create()
return pRet;
}
LayerMultiplex* LayerMultiplex::createWithArray(Array* arrayOfLayers)
LayerMultiplex* LayerMultiplex::createWithArray(const Vector<Layer*>& arrayOfLayers)
{
LayerMultiplex* pRet = new LayerMultiplex();
if (pRet && pRet->initWithArray(arrayOfLayers))
@ -983,17 +978,13 @@ LayerMultiplex* LayerMultiplex::createWithArray(Array* arrayOfLayers)
void LayerMultiplex::addLayer(Layer* layer)
{
CCASSERT(_layers, "");
_layers->addObject(layer);
_layers.addObject(layer);
}
bool LayerMultiplex::init()
{
if (Layer::init())
{
_layers = Array::create();
_layers->retain();
_enabledLayer = 0;
return true;
}
@ -1004,34 +995,32 @@ bool LayerMultiplex::initWithLayers(Layer *layer, va_list params)
{
if (Layer::init())
{
_layers = Array::createWithCapacity(5);
_layers->retain();
_layers->addObject(layer);
_layers.setCapacity(5);
_layers.addObject(layer);
Layer *l = va_arg(params,Layer*);
while( l ) {
_layers->addObject(l);
_layers.addObject(l);
l = va_arg(params,Layer*);
}
_enabledLayer = 0;
this->addChild((Node*)_layers->getObjectAtIndex(_enabledLayer));
this->addChild(_layers[_enabledLayer]);
return true;
}
return false;
}
bool LayerMultiplex::initWithArray(Array* arrayOfLayers)
bool LayerMultiplex::initWithArray(const Vector<Layer*>& arrayOfLayers)
{
if (Layer::init())
{
_layers = Array::createWithCapacity(arrayOfLayers->count());
_layers->addObjectsFromArray(arrayOfLayers);
_layers->retain();
_layers.setCapacity(arrayOfLayers.count());
_layers.addObjectsFromArray(arrayOfLayers);
_enabledLayer = 0;
this->addChild((Node*)_layers->getObjectAtIndex(_enabledLayer));
this->addChild(_layers[_enabledLayer]);
return true;
}
return false;
@ -1039,27 +1028,26 @@ bool LayerMultiplex::initWithArray(Array* arrayOfLayers)
void LayerMultiplex::switchTo(int n)
{
CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" );
CCASSERT( n < _layers.count(), "Invalid index in MultiplexLayer switchTo message" );
this->removeChild((Node*)_layers->getObjectAtIndex(_enabledLayer), true);
this->removeChild(_layers[_enabledLayer], true);
_enabledLayer = n;
this->addChild((Node*)_layers->getObjectAtIndex(n));
this->addChild(_layers[n]);
}
void LayerMultiplex::switchToAndReleaseMe(int n)
{
CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" );
CCASSERT( n < _layers.count(), "Invalid index in MultiplexLayer switchTo message" );
this->removeChild((Node*)_layers->getObjectAtIndex(_enabledLayer), true);
this->removeChild(_layers[_enabledLayer], true);
//[layers replaceObjectAtIndex:enabledLayer withObject:[NSNull null]];
_layers->replaceObjectAtIndex(_enabledLayer, NULL);
_layers.replaceObjectAtIndex(_enabledLayer, nullptr);
_enabledLayer = n;
this->addChild((Node*)_layers->getObjectAtIndex(n));
this->addChild(_layers[n]);
}
NS_CC_END

View File

@ -412,7 +412,7 @@ public:
@since v2.1
* @js NA
*/
static LayerMultiplex* createWithArray(Array* arrayOfLayers);
static LayerMultiplex* createWithArray(const Vector<Layer*>& arrayOfLayers);
/** creates a LayerMultiplex with one or more layers using a variable argument list.
* @code
@ -430,6 +430,21 @@ public:
* @lua NA
*/
static LayerMultiplex * createWithLayer(Layer* layer);
void addLayer(Layer* layer);
/** switches to a certain layer indexed by n.
The current (old) layer will be removed from it's parent with 'cleanup=true'.
*/
void switchTo(int n);
/** release the current layer and switches to another layer indexed by n.
The current (old) layer will be removed from it's parent with 'cleanup=true'.
*/
void switchToAndReleaseMe(int n);
protected:
/**
* @js ctor
*/
@ -450,22 +465,13 @@ public:
/** initializes a MultiplexLayer with an array of layers
@since v2.1
*/
bool initWithArray(Array* arrayOfLayers);
bool initWithArray(const Vector<Layer*>& arrayOfLayers);
void addLayer(Layer* layer);
/** switches to a certain layer indexed by n.
The current (old) layer will be removed from it's parent with 'cleanup=true'.
*/
void switchTo(int n);
/** release the current layer and switches to another layer indexed by n.
The current (old) layer will be removed from it's parent with 'cleanup=true'.
*/
void switchToAndReleaseMe(int n);
protected:
unsigned int _enabledLayer;
Array* _layers;
Vector<Layer*> _layers;
private:
CC_DISALLOW_COPY_AND_ASSIGN(LayerMultiplex);
};

View File

@ -564,7 +564,7 @@ MenuItem* Menu::itemForTouch(Touch *touch)
if (!_children.empty())
{
for (auto iter = _children.rcbegin(); iter != _children.rcend(); ++iter)
for (auto iter = _children.crbegin(); iter != _children.crend(); ++iter)
{
MenuItem* child = dynamic_cast<MenuItem*>(*iter);
if (child && child->isVisible() && child->isEnabled())

View File

@ -42,7 +42,7 @@ TMXTiledMap * TMXTiledMap::create(const std::string& tmxFile)
return ret;
}
CC_SAFE_DELETE(ret);
return NULL;
return nullptr;
}
TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std::string& resourcePath)
@ -54,7 +54,7 @@ TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std:
return ret;
}
CC_SAFE_DELETE(ret);
return NULL;
return nullptr;
}
bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
@ -69,7 +69,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
{
return false;
}
CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
CCASSERT( !mapInfo->getTilesets().empty(), "TMXTiledMap: Map not found. Please check the filename.");
buildWithMapInfo(mapInfo);
return true;
@ -81,7 +81,7 @@ bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& r
TMXMapInfo *mapInfo = TMXMapInfo::createWithXML(tmxString, resourcePath);
CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
CCASSERT( !mapInfo->getTilesets().empty(), "TMXTiledMap: Map not found. Please check the filename.");
buildWithMapInfo(mapInfo);
return true;
@ -90,15 +90,13 @@ bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& r
TMXTiledMap::TMXTiledMap()
:_mapSize(Size::ZERO)
,_tileSize(Size::ZERO)
,_objectGroups(NULL)
,_properties(NULL)
,_tileProperties(NULL)
,_properties(nullptr)
,_tileProperties(nullptr)
{
}
TMXTiledMap::~TMXTiledMap()
{
CC_SAFE_RELEASE(_properties);
CC_SAFE_RELEASE(_objectGroups);
CC_SAFE_RELEASE(_tileProperties);
}
@ -118,14 +116,13 @@ TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
Size size = layerInfo->_layerSize;
Array* tilesets = mapInfo->getTilesets();
if (tilesets && tilesets->count()>0)
auto& tilesets = mapInfo->getTilesets();
if (tilesets.count()>0)
{
TMXTilesetInfo* tileset = NULL;
Object* pObj = NULL;
CCARRAY_FOREACH_REVERSE(tilesets, pObj)
TMXTilesetInfo* tileset = nullptr;
for (auto iter = tilesets.crbegin(); iter != tilesets.crend(); ++iter)
{
tileset = static_cast<TMXTilesetInfo*>(pObj);
tileset = *iter;
if (tileset)
{
for( unsigned int y=0; y < size.height; y++ )
@ -157,7 +154,7 @@ TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInf
// If all the tiles are 0, return empty tileset
CCLOG("cocos2d: Warning: TMX Layer '%s' has no tiles", layerInfo->_name.c_str());
return NULL;
return nullptr;
}
void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
@ -166,9 +163,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
_tileSize = mapInfo->getTileSize();
_mapOrientation = mapInfo->getOrientation();
CC_SAFE_RELEASE(_objectGroups);
_objectGroups = mapInfo->getObjectGroups();
CC_SAFE_RETAIN(_objectGroups);
CC_SAFE_RELEASE(_properties);
_properties = mapInfo->getProperties();
@ -180,14 +175,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
int idx=0;
Array* layers = mapInfo->getLayers();
if (layers && layers->count()>0)
{
TMXLayerInfo* layerInfo = NULL;
Object* pObj = NULL;
CCARRAY_FOREACH(layers, pObj)
{
layerInfo = static_cast<TMXLayerInfo*>(pObj);
mapInfo->getLayers().forEach([&idx, this, &mapInfo](TMXLayerInfo* layerInfo){
if (layerInfo && layerInfo->_visible)
{
TMXLayer *child = parseLayer(layerInfo, mapInfo);
@ -202,8 +190,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
idx++;
}
}
}
});
}
// public
@ -231,13 +218,12 @@ TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const
{
CCASSERT(groupName.size() > 0, "Invalid group name!");
if (_objectGroups && _objectGroups->count()>0)
if (_objectGroups.count()>0)
{
TMXObjectGroup* objectGroup = NULL;
Object* pObj = NULL;
CCARRAY_FOREACH(_objectGroups, pObj)
TMXObjectGroup* objectGroup = nullptr;
for (auto iter = _objectGroups.cbegin(); iter != _objectGroups.cend(); ++iter)
{
objectGroup = static_cast<TMXObjectGroup*>(pObj);
objectGroup = *iter;
if (objectGroup && objectGroup->getGroupName() == groupName)
{
return objectGroup;
@ -246,7 +232,7 @@ TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const
}
// objectGroup not found
return NULL;
return nullptr;
}
String* TMXTiledMap::getProperty(const std::string& propertyName) const

View File

@ -156,10 +156,9 @@ public:
inline void setMapOrientation(int mapOrientation) { _mapOrientation = mapOrientation; };
/** object groups */
inline Array* getObjectGroups() const { return _objectGroups; };
inline void setObjectGroups(Array* groups) {
CC_SAFE_RETAIN(groups);
CC_SAFE_RELEASE(_objectGroups);
inline const Vector<TMXObjectGroup*>& getObjectGroups() const { return _objectGroups; };
inline Vector<TMXObjectGroup*>& getObjectGroups() { return _objectGroups; };
inline void setObjectGroups(const Vector<TMXObjectGroup*>& groups) {
_objectGroups = groups;
};
@ -199,7 +198,7 @@ protected:
/** map orientation */
int _mapOrientation;
/** object groups */
Array* _objectGroups;
Vector<TMXObjectGroup*> _objectGroups;
/** properties */
Dictionary* _properties;

View File

@ -50,7 +50,7 @@ static const char* valueForKey(const char *key, std::unordered_map<std::string,
// implementation TMXLayerInfo
TMXLayerInfo::TMXLayerInfo()
: _name("")
, _tiles(NULL)
, _tiles(nullptr)
, _ownTiles(true)
, _minGID(100000)
, _maxGID(0)
@ -67,7 +67,7 @@ TMXLayerInfo::~TMXLayerInfo()
if( _ownTiles && _tiles )
{
free(_tiles);
_tiles = NULL;
_tiles = nullptr;
}
}
@ -121,7 +121,7 @@ TMXMapInfo * TMXMapInfo::create(const std::string& tmxFile)
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
return nullptr;
}
TMXMapInfo * TMXMapInfo::createWithXML(const std::string& tmxString, const std::string& resourcePath)
@ -133,17 +133,11 @@ TMXMapInfo * TMXMapInfo::createWithXML(const std::string& tmxString, const std::
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
return nullptr;
}
void TMXMapInfo::internalInit(const std::string& tmxFileName, const std::string& resourcePath)
{
_tilesets = Array::create();
_tilesets->retain();
_layers = Array::create();
_layers->retain();
if (tmxFileName.size() > 0)
{
_TMXFileName = FileUtils::getInstance()->fullPathForFilename(tmxFileName);
@ -154,8 +148,7 @@ void TMXMapInfo::internalInit(const std::string& tmxFileName, const std::string&
_resources = resourcePath;
}
_objectGroups = Array::createWithCapacity(4);
_objectGroups->retain();
_objectGroups.setCapacity(4);
_properties = new Dictionary();
_properties->init();
@ -184,13 +177,10 @@ bool TMXMapInfo::initWithTMXFile(const std::string& tmxFile)
TMXMapInfo::TMXMapInfo()
: _mapSize(Size::ZERO)
, _tileSize(Size::ZERO)
, _layers(NULL)
, _tilesets(NULL)
, _objectGroups(NULL)
, _layerAttribs(0)
, _storingCharacters(false)
, _properties(NULL)
, _tileProperties(NULL)
, _properties(nullptr)
, _tileProperties(nullptr)
, _currentFirstGID(0)
{
}
@ -198,16 +188,13 @@ TMXMapInfo::TMXMapInfo()
TMXMapInfo::~TMXMapInfo()
{
CCLOGINFO("deallocing TMXMapInfo: %p", this);
CC_SAFE_RELEASE(_tilesets);
CC_SAFE_RELEASE(_layers);
CC_SAFE_RELEASE(_properties);
CC_SAFE_RELEASE(_tileProperties);
CC_SAFE_RELEASE(_objectGroups);
}
bool TMXMapInfo::parseXMLString(const std::string& xmlString)
{
int len = xmlString.size();
size_t len = xmlString.size();
if (len <= 0)
return false;
@ -325,7 +312,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
s.height = (float)atof(valueForKey("tileheight", attributeDict));
tileset->_tileSize = s;
pTMXMapInfo->getTilesets()->addObject(tileset);
pTMXMapInfo->getTilesets().addObject(tileset);
tileset->release();
}
}
@ -333,7 +320,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
{
if (pTMXMapInfo->getParentElement() == TMXPropertyLayer)
{
TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject();
TMXLayerInfo* layer = pTMXMapInfo->getLayers().getLastObject();
Size layerSize = layer->_layerSize;
unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict));
int tilesAmount = layerSize.width*layerSize.height;
@ -367,7 +354,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
}
else
{
TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject();
TMXTilesetInfo* info = pTMXMapInfo->getTilesets().getLastObject();
Dictionary *dict = new Dictionary();
dict->init();
pTMXMapInfo->setParentGID(info->_firstGid + atoi(valueForKey("id", attributeDict)));
@ -404,7 +391,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
float y = (float)atof(valueForKey("y", attributeDict));
layer->_offset = Point(x,y);
pTMXMapInfo->getLayers()->addObject(layer);
pTMXMapInfo->getLayers().addObject(layer);
layer->release();
// The parent element is now "layer"
@ -420,7 +407,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
positionOffset.y = (float)atof(valueForKey("y", attributeDict)) * pTMXMapInfo->getTileSize().height;
objectGroup->setPositionOffset(positionOffset);
pTMXMapInfo->getObjectGroups()->addObject(objectGroup);
pTMXMapInfo->getObjectGroups().addObject(objectGroup);
objectGroup->release();
// The parent element is now "objectgroup"
@ -429,7 +416,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
}
else if (elementName == "image")
{
TMXTilesetInfo* tileset = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject();
TMXTilesetInfo* tileset = pTMXMapInfo->getTilesets().getLastObject();
// build full path
std::string imagename = valueForKey("source", attributeDict);
@ -453,7 +440,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
{
pTMXMapInfo->setLayerAttribs(pTMXMapInfo->getLayerAttribs() | TMXLayerAttribNone);
TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject();
TMXLayerInfo* layer = pTMXMapInfo->getLayers().getLastObject();
Size layerSize = layer->_layerSize;
int tilesAmount = layerSize.width*layerSize.height;
@ -499,7 +486,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
else if (elementName == "object")
{
char buffer[32] = {0};
TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject();
TMXObjectGroup* objectGroup = pTMXMapInfo->getObjectGroups().getLastObject();
// The value for "type" was blank or not a valid class name
// Create an instance of TMXObjectInfo to store the object and its properties
@ -572,7 +559,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
else if ( pTMXMapInfo->getParentElement() == TMXPropertyLayer )
{
// The parent element is the last layer
TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject();
TMXLayerInfo* layer = pTMXMapInfo->getLayers().getLastObject();
String *value = new String(valueForKey("value", attributeDict));
std::string key = valueForKey("name", attributeDict);
// Add the property to the layer
@ -583,7 +570,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
else if ( pTMXMapInfo->getParentElement() == TMXPropertyObjectGroup )
{
// The parent element is the last object group
TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject();
TMXObjectGroup* objectGroup = pTMXMapInfo->getObjectGroups().getLastObject();
String *value = new String(valueForKey("value", attributeDict));
const char* key = valueForKey("name", attributeDict);
objectGroup->getProperties()->setObject(value, key);
@ -593,7 +580,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
else if ( pTMXMapInfo->getParentElement() == TMXPropertyObject )
{
// The parent element is the last object
TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject();
TMXObjectGroup* objectGroup = pTMXMapInfo->getObjectGroups().getLastObject();
Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject();
const char* propertyName = valueForKey("name", attributeDict);
@ -614,7 +601,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
else if (elementName == "polygon")
{
// find parent object's dict and add polygon-points to it
TMXObjectGroup* objectGroup = (TMXObjectGroup*)_objectGroups->getLastObject();
TMXObjectGroup* objectGroup = _objectGroups.getLastObject();
Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject();
// get points value string
@ -667,7 +654,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
else if (elementName == "polyline")
{
// find parent object's dict and add polyline-points to it
TMXObjectGroup* objectGroup = (TMXObjectGroup*)_objectGroups->getLastObject();
TMXObjectGroup* objectGroup = _objectGroups.getLastObject();
Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject();
// get points value string
@ -739,7 +726,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name)
{
pTMXMapInfo->setStoringCharacters(false);
TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject();
TMXLayerInfo* layer = pTMXMapInfo->getLayers().getLastObject();
std::string currentString = pTMXMapInfo->getCurrentString();
unsigned char *buffer;
@ -763,7 +750,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name)
inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warnings in compiler
free(buffer);
buffer = NULL;
buffer = nullptr;
if( ! deflated )
{
@ -782,7 +769,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name)
}
else if (pTMXMapInfo->getLayerAttribs() & TMXLayerAttribNone)
{
TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject();
TMXLayerInfo* layer = pTMXMapInfo->getLayers().getLastObject();
Size layerSize = layer->_layerSize;
int tilesAmount = layerSize.width * layerSize.height;

View File

@ -32,12 +32,15 @@ THE SOFTWARE.
#include "CCDictionary.h"
#include "CCGeometry.h"
#include "platform/CCSAXParser.h"
#include "CCVector.h"
#include <string>
NS_CC_BEGIN
class TMXLayerInfo;
class TMXObjectGroup;
class TMXTilesetInfo;
/** @file
* Internal TMX parser
@ -213,26 +216,23 @@ public:
inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; };
/// Layers
inline Array* getLayers() const { return _layers; };
inline void setLayers(Array* layers) {
CC_SAFE_RETAIN(layers);
CC_SAFE_RELEASE(_layers);
inline const Vector<TMXLayerInfo*>& getLayers() const { return _layers; };
inline Vector<TMXLayerInfo*>& getLayers() { return _layers; };
inline void setLayers(const Vector<TMXLayerInfo*>& layers) {
_layers = layers;
};
/// tilesets
inline Array* getTilesets() const { return _tilesets; };
inline void setTilesets(Array* tilesets) {
CC_SAFE_RETAIN(tilesets);
CC_SAFE_RELEASE(_tilesets);
inline const Vector<TMXTilesetInfo*>& getTilesets() const { return _tilesets; };
inline Vector<TMXTilesetInfo*>& getTilesets() { return _tilesets; };
inline void setTilesets(const Vector<TMXTilesetInfo*>& tilesets) {
_tilesets = tilesets;
};
/// ObjectGroups
inline Array* getObjectGroups() const { return _objectGroups; };
inline void setObjectGroups(Array* groups) {
CC_SAFE_RETAIN(groups);
CC_SAFE_RELEASE(_objectGroups);
inline const Vector<TMXObjectGroup*>& getObjectGroups() const { return _objectGroups; };
inline Vector<TMXObjectGroup*>& getObjectGroups() { return _objectGroups; };
inline void setObjectGroups(const Vector<TMXObjectGroup*>& groups) {
_objectGroups = groups;
};
@ -293,11 +293,11 @@ protected:
/// tiles width & height
Size _tileSize;
/// Layers
Array* _layers;
Vector<TMXLayerInfo*> _layers;
/// tilesets
Array* _tilesets;
Vector<TMXTilesetInfo*> _tilesets;
/// ObjectGroups
Array* _objectGroups;
Vector<TMXObjectGroup*> _objectGroups;
/// parent element
int _parentElement;
/// parent GID

View File

@ -102,7 +102,7 @@ bool SAXParser::init(const char *pszEncoding)
return true;
}
bool SAXParser::parse(const char* pXMLData, unsigned int uDataLength)
bool SAXParser::parse(const char* pXMLData, size_t uDataLength)
{
tinyxml2::XMLDocument tinyDoc;
tinyDoc.Parse(pXMLData, uDataLength);

View File

@ -81,7 +81,7 @@ public:
* @js NA
* @lua NA
*/
bool parse(const char* pXMLData, unsigned int uDataLength);
bool parse(const char* pXMLData, size_t uDataLength);
/**
* @js NA
* @lua NA

View File

@ -346,8 +346,8 @@ public:
reverse_iterator rend() { return _data.rend(); }
const_reverse_iterator rend() const { return _data.rend(); }
const_reverse_iterator rcbegin() const { return _data.crbegin(); }
const_reverse_iterator rcend() const { return _data.crend(); }
const_reverse_iterator crbegin() const { return _data.crbegin(); }
const_reverse_iterator crend() const { return _data.crend(); }
protected:
std::vector<T> _data;