diff --git a/spine-cpp/README.md b/spine-cpp/README.md index 51d1ed5a0..498677724 100644 --- a/spine-cpp/README.md +++ b/spine-cpp/README.md @@ -29,7 +29,7 @@ Spine::SpineExtension::setInstance(Spine::DefaultSpineExtension::getInstance()); class MyTextureLoader : public TextureLoader { - virtual void load(AtlasPage& page, std::string path) { // TODO } + virtual void load(AtlasPage& page, const String& path) { // TODO } virtual void unload(void* texture) { // TODO } }; diff --git a/spine-cpp/spine-cpp-unit-tests/src/main.cpp b/spine-cpp/spine-cpp-unit-tests/src/main.cpp index d2d44b9fc..41d8585c2 100644 --- a/spine-cpp/spine-cpp-unit-tests/src/main.cpp +++ b/spine-cpp/spine-cpp-unit-tests/src/main.cpp @@ -98,8 +98,8 @@ void reproduceIssue_776() { loadJson(R_JSON, R_ATLAS, atlas, skeletonData, stateData, skeleton, state); dispose(atlas, skeletonData, stateData, skeleton, state); - loadBinary(R_BINARY, R_ATLAS, atlas, skeletonData, stateData, skeleton, state); - dispose(atlas, skeletonData, stateData, skeleton, state); + // loadBinary(R_BINARY, R_ATLAS, atlas, skeletonData, stateData, skeleton, state); + // dispose(atlas, skeletonData, stateData, skeleton, state); } int main (int argc, char** argv) { diff --git a/spine-cpp/spine-cpp/include/spine/Animation.h b/spine-cpp/spine-cpp/include/spine/Animation.h index 1f430a0fe..54398a851 100644 --- a/spine-cpp/spine-cpp/include/spine/Animation.h +++ b/spine-cpp/spine-cpp/include/spine/Animation.h @@ -35,8 +35,7 @@ #include #include #include - -#include +#include namespace Spine { class Timeline; @@ -65,7 +64,7 @@ namespace Spine { friend class TwoColorTimeline; public: - Animation(std::string name, Vector& timelines, float duration); + Animation(const String& name, Vector& timelines, float duration); ~Animation(); @@ -73,7 +72,7 @@ namespace Spine { /// See also Timeline::apply(Skeleton&, float, float, Vector, float, MixPose, MixDirection) void apply(Skeleton& skeleton, float lastTime, float time, bool loop, Vector* pEvents, float alpha, MixPose pose, MixDirection direction); - std::string getName(); + const String& getName(); Vector getTimelines(); @@ -86,7 +85,7 @@ namespace Spine { private: Vector _timelines; float _duration; - std::string _name; + String _name; /// @param target After the first and before the last entry. static int binarySearch(Vector& values, float target, int step); diff --git a/spine-cpp/spine-cpp/include/spine/AnimationState.h b/spine-cpp/spine-cpp/include/spine/AnimationState.h index 5b91238b1..483b6f2fb 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationState.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationState.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace Spine { enum EventType { @@ -315,7 +316,7 @@ namespace Spine { void clearTrack(int trackIndex); /// Sets an animation by name. setAnimation(int, Animation, bool) - TrackEntry* setAnimation(int trackIndex, std::string animationName, bool loop); + TrackEntry* setAnimation(int trackIndex, const String& animationName, bool loop); /// Sets the current animation for a track, discarding any queued animations. /// @param loop If true, the animation will repeat. @@ -328,7 +329,7 @@ namespace Spine { /// Queues an animation by name. /// addAnimation(int, Animation, bool, float) - TrackEntry* addAnimation(int trackIndex, std::string animationName, bool loop, float delay); + TrackEntry* addAnimation(int trackIndex, const String& animationName, bool loop, float delay); /// Adds an animation to be played delay seconds after the current or last queued animation /// for a track. If the track is empty, it is equivalent to calling setAnimation. diff --git a/spine-cpp/spine-cpp/include/spine/AnimationStateData.h b/spine-cpp/spine-cpp/include/spine/AnimationStateData.h index 89ded3a43..419d286ff 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationStateData.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationStateData.h @@ -33,9 +33,9 @@ #include #include +#include #include -#include namespace Spine { class SkeletonData; @@ -56,7 +56,7 @@ namespace Spine { AnimationStateData(SkeletonData* skeletonData); /// Sets a mix duration by animation names. - void setMix(std::string fromName, std::string toName, float duration); + void setMix(const String& fromName, const String& toName, float duration); /// Sets a mix duration when changing from the specified animation to the other. /// See TrackEntry.MixDuration. diff --git a/spine-cpp/spine-cpp/include/spine/Atlas.h b/spine-cpp/spine-cpp/include/spine/Atlas.h index 3a425df9c..38c9c6c00 100644 --- a/spine-cpp/spine-cpp/include/spine/Atlas.h +++ b/spine-cpp/spine-cpp/include/spine/Atlas.h @@ -34,8 +34,7 @@ #include #include #include - -#include +#include namespace Spine { enum Format { @@ -66,7 +65,7 @@ namespace Spine { class AtlasPage : public SpineObject { public: - std::string name; + String name; Format format; TextureFilter minFilter; TextureFilter magFilter; @@ -75,13 +74,13 @@ namespace Spine { void* rendererObject; int width, height; - AtlasPage(std::string inName) : name(inName) {} + AtlasPage(const String& inName) : name(inName) {} }; class AtlasRegion : public SpineObject { public: AtlasPage* page; - std::string name; + String name; int x, y, width, height; float u, v, u2, v2; float offsetX, offsetY; @@ -104,10 +103,10 @@ namespace Spine { void flipV(); - /// Returns the first region found with the specified name. This method uses std::string comparison to find the region, so the result + /// Returns the first region found with the specified name. This method uses String comparison to find the region, so the result /// should be cached rather than calling this method multiple times. /// @return The region, or NULL. - AtlasRegion* findRegion(std::string name); + AtlasRegion* findRegion(const String& name); void dispose(); diff --git a/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h b/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h index d2f0d615a..79ef9441f 100644 --- a/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h +++ b/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h @@ -33,6 +33,7 @@ #include #include +#include namespace Spine { @@ -49,19 +50,19 @@ namespace Spine { public: AtlasAttachmentLoader(Atlas* atlas); - virtual RegionAttachment* newRegionAttachment(Skin& skin, std::string name, std::string path); + virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path); - virtual MeshAttachment* newMeshAttachment(Skin& skin, std::string name, std::string path); + virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path); - virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, std::string name); + virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name); - virtual PathAttachment* newPathAttachment(Skin& skin, std::string name); + virtual PathAttachment* newPathAttachment(Skin& skin, const String& name); - virtual PointAttachment* newPointAttachment(Skin& skin, std::string name); + virtual PointAttachment* newPointAttachment(Skin& skin, const String& name); - virtual ClippingAttachment* newClippingAttachment(Skin& skin, std::string name); + virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name); - AtlasRegion* findRegion(std::string name); + AtlasRegion* findRegion(const String& name); private: Atlas* _atlas; diff --git a/spine-cpp/spine-cpp/include/spine/Attachment.h b/spine-cpp/spine-cpp/include/spine/Attachment.h index f8484fa25..0f4057579 100644 --- a/spine-cpp/spine-cpp/include/spine/Attachment.h +++ b/spine-cpp/spine-cpp/include/spine/Attachment.h @@ -33,20 +33,20 @@ #include #include -#include +#include namespace Spine { class Attachment : public SpineObject { RTTI_DECL public: - Attachment(std::string name); + Attachment(const String& name); virtual ~Attachment(); - - const std::string& getName(); + + const String& getName(); private: - const std::string _name; + const String _name; }; } diff --git a/spine-cpp/spine-cpp/include/spine/AttachmentLoader.h b/spine-cpp/spine-cpp/include/spine/AttachmentLoader.h index 82b297ce4..42408209b 100644 --- a/spine-cpp/spine-cpp/include/spine/AttachmentLoader.h +++ b/spine-cpp/spine-cpp/include/spine/AttachmentLoader.h @@ -33,7 +33,7 @@ #include #include -#include +#include namespace Spine { class Skin; @@ -52,20 +52,20 @@ namespace Spine { virtual ~AttachmentLoader(); /// @return May be NULL to not load any attachment. - virtual RegionAttachment* newRegionAttachment(Skin& skin, std::string name, std::string path) = 0; + virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path) = 0; /// @return May be NULL to not load any attachment. - virtual MeshAttachment* newMeshAttachment(Skin& skin, std::string name, std::string path) = 0; + virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path) = 0; /// @return May be NULL to not load any attachment. - virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, std::string name) = 0; + virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name) = 0; /// @return May be NULL to not load any attachment - virtual PathAttachment* newPathAttachment(Skin& skin, std::string name) = 0; + virtual PathAttachment* newPathAttachment(Skin& skin, const String& name) = 0; - virtual PointAttachment* newPointAttachment(Skin& skin, std::string name) = 0; + virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0; - virtual ClippingAttachment* newClippingAttachment(Skin& skin, std::string name) = 0; + virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0; }; } diff --git a/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h b/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h index c7c067c28..81c9d264c 100644 --- a/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h @@ -36,8 +36,8 @@ #include #include #include +#include -#include namespace Spine { class Skeleton; @@ -57,20 +57,20 @@ namespace Spine { virtual int getPropertyId(); /// Sets the time and value of the specified keyframe. - void setFrame(int frameIndex, float time, std::string attachmentName); + void setFrame(int frameIndex, float time, const String& attachmentName); int getSlotIndex(); void setSlotIndex(int inValue); - Vector& getFrames(); + const Vector& getFrames(); void setFrames(Vector& inValue); // time, ... - Vector getAttachmentNames(); - void setAttachmentNames(Vector& inValue); + const Vector& getAttachmentNames(); + void setAttachmentNames(Vector& inValue); int getFrameCount(); private: int _slotIndex; Vector _frames; - Vector _attachmentNames; + Vector _attachmentNames; }; } diff --git a/spine-cpp/spine-cpp/include/spine/BoneData.h b/spine-cpp/spine-cpp/include/spine/BoneData.h index 34ebeabef..3e1a26c01 100644 --- a/spine-cpp/spine-cpp/include/spine/BoneData.h +++ b/spine-cpp/spine-cpp/include/spine/BoneData.h @@ -33,7 +33,7 @@ #include #include -#include +#include namespace Spine { class BoneData : public SpineObject { @@ -48,13 +48,13 @@ namespace Spine { friend class TranslateTimeline; public: - BoneData(int index, std::string name, BoneData* parent = NULL); + BoneData(int index, const String& name, BoneData* parent = NULL); /// The index of the bone in Skeleton.Bones - const int getIndex(); + int getIndex(); /// The name of the bone, which is unique within the skeleton. - const std::string& getName(); + const String& getName(); /// May be NULL. BoneData* getParent(); @@ -96,7 +96,7 @@ namespace Spine { private: const int _index; - const std::string _name; + const String _name; BoneData* _parent; float _length; float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY; diff --git a/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h b/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h index ee48fd8ff..21a552b31 100644 --- a/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h @@ -39,7 +39,7 @@ namespace Spine { class BoundingBoxAttachment : public VertexAttachment { RTTI_DECL - BoundingBoxAttachment(std::string name); + BoundingBoxAttachment(const String& name); }; } diff --git a/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h b/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h index 8767b8862..1ca58d54a 100644 --- a/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h @@ -45,7 +45,7 @@ namespace Spine { RTTI_DECL public: - ClippingAttachment(std::string name); + ClippingAttachment(const String& name); SlotData* getEndSlot(); void setEndSlot(SlotData* inValue); diff --git a/spine-cpp/spine-cpp/include/spine/ContainerUtil.h b/spine-cpp/spine-cpp/include/spine/ContainerUtil.h index 862f2fd0a..6d2fcdf85 100644 --- a/spine-cpp/spine-cpp/include/spine/ContainerUtil.h +++ b/spine-cpp/spine-cpp/include/spine/ContainerUtil.h @@ -35,8 +35,8 @@ #include #include #include +#include -#include #include namespace Spine { @@ -46,7 +46,7 @@ namespace Spine { /// It is more efficient to cache the results of this method than to call it multiple times. /// @return May be NULL. template - static T* findWithName(Vector& items, std::string name) { + static T* findWithName(Vector& items, const String& name) { assert(name.length() > 0); for (T** i = items.begin(); i != items.end(); ++i) { @@ -61,7 +61,7 @@ namespace Spine { /// @return -1 if the item was not found. template - static int findIndexWithName(Vector& items, std::string name) { + static int findIndexWithName(Vector& items, const String& name) { assert(name.length() > 0); for (size_t i = 0, len = items.size(); i < len; ++i) { @@ -78,7 +78,7 @@ namespace Spine { /// It is more efficient to cache the results of this method than to call it multiple times. /// @return May be NULL. template - static T* findWithDataName(Vector& items, std::string name) { + static T* findWithDataName(Vector& items, const String& name) { assert(name.length() > 0); for (T** i = items.begin(); i != items.end(); ++i) { @@ -93,7 +93,7 @@ namespace Spine { /// @return -1 if the item was not found. template - static int findIndexWithDataName(Vector& items, std::string name) { + static int findIndexWithDataName(Vector& items, const String& name) { assert(name.length() > 0); for (size_t i = 0, len = items.size(); i < len; ++i) { diff --git a/spine-cpp/spine-cpp/include/spine/Event.h b/spine-cpp/spine-cpp/include/spine/Event.h index 27aeba910..8bf460de5 100644 --- a/spine-cpp/spine-cpp/include/spine/Event.h +++ b/spine-cpp/spine-cpp/include/spine/Event.h @@ -32,8 +32,7 @@ #define Spine_Event_h #include - -#include +#include namespace Spine { class EventData; @@ -57,16 +56,16 @@ namespace Spine { float getFloatValue(); void setFloatValue(int inValue); - - std::string getStringValue(); - void setStringValue(std::string inValue); + + const String& getStringValue(); + void setStringValue(const String& inValue); private: const EventData& _data; const float _time; int _intValue; float _floatValue; - std::string _stringValue; + String _stringValue; }; } diff --git a/spine-cpp/spine-cpp/include/spine/EventData.h b/spine-cpp/spine-cpp/include/spine/EventData.h index 479dd1370..6ffa8a845 100644 --- a/spine-cpp/spine-cpp/include/spine/EventData.h +++ b/spine-cpp/spine-cpp/include/spine/EventData.h @@ -32,8 +32,7 @@ #define Spine_EventData_h #include - -#include +#include namespace Spine { /// Stores the setup pose values for an Event. @@ -43,10 +42,10 @@ namespace Spine { friend class Event; public: - EventData(std::string name); + EventData(const String& name); /// The name of the event, which is unique within the skeleton. - const std::string& getName(); + const String& getName(); int getIntValue(); void setIntValue(int inValue); @@ -54,14 +53,14 @@ namespace Spine { float getFloatValue(); void setFloatValue(float inValue); - std::string getStringValue(); - void setStringValue(std::string inValue); + const String& getStringValue(); + void setStringValue(const String& inValue); private: - const std::string _name; + const String _name; int _intValue; float _floatValue; - std::string _stringValue; + String _stringValue; }; } diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h index cd6f0fbbb..864d35df5 100644 --- a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h @@ -33,8 +33,7 @@ #include #include - -#include +#include namespace Spine { class BoneData; @@ -47,10 +46,10 @@ namespace Spine { friend class IkConstraintTimeline; public: - IkConstraintData(std::string name); + IkConstraintData(const String& name); /// The IK constraint's name, which is unique within the skeleton. - const std::string& getName(); + const String& getName(); int getOrder(); void setOrder(int inValue); @@ -70,7 +69,7 @@ namespace Spine { void setMix(float inValue); private: - const std::string _name; + const String _name; int _order; Vector _bones; BoneData* _target; diff --git a/spine-cpp/spine-cpp/include/spine/LinkedMesh.h b/spine-cpp/spine-cpp/include/spine/LinkedMesh.h index ef838aee8..6652468e1 100644 --- a/spine-cpp/spine-cpp/include/spine/LinkedMesh.h +++ b/spine-cpp/spine-cpp/include/spine/LinkedMesh.h @@ -32,8 +32,7 @@ #define Spine_LinkedMesh_h #include - -#include +#include namespace Spine { class MeshAttachment; @@ -43,13 +42,13 @@ namespace Spine { friend class SkeletonJson; public: - LinkedMesh(MeshAttachment* mesh, std::string skin, int slotIndex, std::string parent); + LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent); private: MeshAttachment* _mesh; - std::string _skin; + String _skin; int _slotIndex; - std::string _parent; + String _parent; }; } diff --git a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h index 6c89f5a30..8e23c971b 100644 --- a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h @@ -32,10 +32,8 @@ #define Spine_MeshAttachment_h #include - #include -#include namespace Spine { /// Attachment that displays a texture region using a mesh. @@ -47,7 +45,7 @@ namespace Spine { RTTI_DECL public: - MeshAttachment(std::string name); + MeshAttachment(const String& name); void updateUVs(); @@ -75,8 +73,8 @@ namespace Spine { float getA(); void setA(float inValue); - std::string getPath(); - void setPath(std::string inValue); + const String& getPath(); + void setPath(const String& inValue); void* getRendererObject(); void setRendererObject(void* inValue); @@ -138,7 +136,7 @@ namespace Spine { Vector _triangles; Vector _edges; void* _rendererObject; - std::string _path; + String _path; float _regionU; float _regionV; float _regionU2; diff --git a/spine-cpp/spine-cpp/include/spine/PathAttachment.h b/spine-cpp/spine-cpp/include/spine/PathAttachment.h index 5782e8bf3..228439fad 100644 --- a/spine-cpp/spine-cpp/include/spine/PathAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/PathAttachment.h @@ -41,7 +41,7 @@ namespace Spine { RTTI_DECL public: - PathAttachment(std::string name); + PathAttachment(const String& name); /// The length in the setup pose from the start of the path to the end of each curve. Vector& getLengths(); diff --git a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h index 01e3277e9..8505388b9 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h @@ -36,8 +36,7 @@ #include #include #include - -#include +#include namespace Spine { class BoneData; @@ -54,9 +53,9 @@ namespace Spine { friend class PathConstraintSpacingTimeline; public: - PathConstraintData(std::string name); - - const std::string& getName(); + PathConstraintData(const String& name); + + const String& getName(); int getOrder(); void setOrder(int inValue); @@ -91,7 +90,7 @@ namespace Spine { void setTranslateMix(float inValue); private: - const std::string _name; + const String _name; int _order; Vector _bones; SlotData* _target; diff --git a/spine-cpp/spine-cpp/include/spine/PointAttachment.h b/spine-cpp/spine-cpp/include/spine/PointAttachment.h index 0536d5eb2..efacbbe90 100644 --- a/spine-cpp/spine-cpp/include/spine/PointAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/PointAttachment.h @@ -50,7 +50,7 @@ namespace Spine { RTTI_DECL public: - PointAttachment(std::string name); + PointAttachment(const String& name); void computeWorldPosition(Bone& bone, float& ox, float& oy); diff --git a/spine-cpp/spine-cpp/include/spine/RTTI.h b/spine-cpp/spine-cpp/include/spine/RTTI.h index 3ec312b16..ab5095071 100644 --- a/spine-cpp/spine-cpp/include/spine/RTTI.h +++ b/spine-cpp/spine-cpp/include/spine/RTTI.h @@ -32,6 +32,7 @@ #define Spine_RTTI_h #include + #include namespace Spine { @@ -52,8 +53,8 @@ namespace Spine { RTTI(const RTTI& obj); RTTI& operator=(const RTTI& obj); - const std::string m_className; - const RTTI *m_pBaseRTTI; + const std::string& _className; + const RTTI *_pBaseRTTI; }; } diff --git a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h index 5dd0da008..bdda2e319 100644 --- a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h @@ -51,7 +51,7 @@ namespace Spine { RTTI_DECL public: - RegionAttachment(std::string name); + RegionAttachment(const String& name); void updateOffset(); @@ -87,9 +87,9 @@ namespace Spine { void setB(float inValue); float getA(); void setA(float inValue); - - std::string getPath(); - void setPath(std::string inValue); + + const String& getPath(); + void setPath(const String& inValue); void* getRendererObject(); void setRendererObject(void* inValue); float getRegionOffsetX(); @@ -129,7 +129,7 @@ namespace Spine { Vector _offset; Vector _uvs; void* _rendererObject; - std::string _path; + String _path; float _regionU; float _regionV; float _regionU2; diff --git a/spine-cpp/spine-cpp/include/spine/Skeleton.h b/spine-cpp/spine-cpp/include/spine/Skeleton.h index d0042aeba..2a0a55183 100644 --- a/spine-cpp/spine-cpp/include/spine/Skeleton.h +++ b/spine-cpp/spine-cpp/include/spine/Skeleton.h @@ -34,8 +34,8 @@ #include #include #include +#include -#include #include // std::numeric_limits namespace Spine { @@ -90,19 +90,19 @@ namespace Spine { void setSlotsToSetupPose(); /// @return May be NULL. - Bone* findBone(std::string boneName); + Bone* findBone(const String& boneName); /// @return -1 if the bone was not found. - int findBoneIndex(std::string boneName); + int findBoneIndex(const String& boneName); /// @return May be NULL. - Slot* findSlot(std::string slotName); + Slot* findSlot(const String& slotName); /// @return -1 if the bone was not found. - int findSlotIndex(std::string slotName); + int findSlotIndex(const String& slotName); /// Sets a skin by name (see setSkin). - void setSkin(std::string skinName); + void setSkin(const String& skinName); /// Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. /// If there was no old skin, each slot's setup mode attachment is attached from the new skin. @@ -115,22 +115,22 @@ namespace Spine { void setSkin(Skin* newSkin); /// @return May be NULL. - Attachment* getAttachment(std::string slotName, std::string attachmentName); + Attachment* getAttachment(const String& slotName, const String& attachmentName); /// @return May be NULL. - Attachment* getAttachment(int slotIndex, std::string attachmentName); + Attachment* getAttachment(int slotIndex, const String& attachmentName); /// @param attachmentName May be empty. - void setAttachment(std::string slotName, std::string attachmentName); + void setAttachment(const String& slotName, const String& attachmentName); /// @return May be NULL. - IkConstraint* findIkConstraint(std::string constraintName); + IkConstraint* findIkConstraint(const String& constraintName); /// @return May be NULL. - TransformConstraint* findTransformConstraint(std::string constraintName); + TransformConstraint* findTransformConstraint(const String& constraintName); /// @return May be NULL. - PathConstraint* findPathConstraint(std::string constraintName); + PathConstraint* findPathConstraint(const String& constraintName); void update(float delta); diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h b/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h index 53359f52a..f412efd67 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h @@ -34,8 +34,7 @@ #include #include #include - -#include +#include namespace Spine { class SkeletonData; @@ -87,7 +86,7 @@ namespace Spine { AttachmentLoader* _attachmentLoader; Vector _linkedMeshes; - std::string _error; + String _error; float _scale; const bool _ownsLoader; diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonData.h b/spine-cpp/spine-cpp/include/spine/SkeletonData.h index a6002da36..9318ab53e 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonData.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonData.h @@ -32,8 +32,7 @@ #define Spine_SkeletonData_h #include - -#include +#include namespace Spine { class BoneData; @@ -59,40 +58,40 @@ namespace Spine { /// Finds a bone by comparing each bone's name. /// It is more efficient to cache the results of this method than to call it multiple times. /// @return May be NULL. - BoneData* findBone(std::string boneName); + BoneData* findBone(const String& boneName); /// @return -1 if the bone was not found. - int findBoneIndex(std::string boneName); + int findBoneIndex(const String& boneName); /// @return May be NULL. - SlotData* findSlot(std::string slotName); + SlotData* findSlot(const String& slotName); /// @return -1 if the slot was not found. - int findSlotIndex(std::string slotName); + int findSlotIndex(const String& slotName); /// @return May be NULL. - Skin* findSkin(std::string skinName); + Skin* findSkin(const String& skinName); /// @return May be NULL. - EventData* findEvent(std::string eventDataName); + EventData* findEvent(const String& eventDataName); /// @return May be NULL. - Animation* findAnimation(std::string animationName); + Animation* findAnimation(const String& animationName); /// @return May be NULL. - IkConstraintData* findIkConstraint(std::string constraintName); + IkConstraintData* findIkConstraint(const String& constraintName); /// @return May be NULL. - TransformConstraintData* findTransformConstraint(std::string constraintName); + TransformConstraintData* findTransformConstraint(const String& constraintName); /// @return May be NULL. - PathConstraintData* findPathConstraint(std::string constraintName); + PathConstraintData* findPathConstraint(const String& constraintName); /// @return -1 if the path constraint was not found. - int findPathConstraintIndex(std::string pathConstraintName); - - std::string getName(); - void setName(std::string inValue); + int findPathConstraintIndex(const String& pathConstraintName); + + const String& getName(); + void setName(const String& inValue); /// The skeleton's bones, sorted parent first. The root bone is always the first bone. Vector& getBones(); @@ -112,12 +111,16 @@ namespace Spine { Vector& getEvents(); void setEvents(Vector& inValue); + Vector& getAnimations(); void setAnimations(Vector& inValue); + Vector& getIkConstraints(); void setIkConstraints(Vector& inValue); + Vector& getTransformConstraints(); void setTransformConstraints(Vector& inValue); + Vector& getPathConstraints(); void setPathConstraints(Vector& inValue); @@ -127,19 +130,19 @@ namespace Spine { void setHeight(float inValue); /// The Spine version used to export this data, or NULL. - std::string getVersion(); - void setVersion(std::string inValue); - std::string getHash(); - void setHash(std::string inValue); - std::string getImagesPath(); - void setImagesPath(std::string inValue); + const String& getVersion(); + void setVersion(const String& inValue); + const String& getHash(); + void setHash(const String& inValue); + const String& getImagesPath(); + void setImagesPath(const String& inValue); /// The dopesheet FPS in Spine. Available only when nonessential data was exported. float getFps(); void setFps(float inValue); private: - std::string _name; + String _name; Vector _bones; // Ordered parents first Vector _slots; // Setup pose draw order. Vector _skins; @@ -150,12 +153,12 @@ namespace Spine { Vector _transformConstraints; Vector _pathConstraints; float _width, _height; - std::string _version; - std::string _hash; + String _version; + String _hash; // Nonessential. float _fps; - std::string _imagesPath; + String _imagesPath; }; } diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonJson.h b/spine-cpp/spine-cpp/include/spine/SkeletonJson.h index c1c7db52b..d37f2272e 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonJson.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonJson.h @@ -33,8 +33,7 @@ #include #include - -#include +#include namespace Spine { class CurveTimeline; @@ -63,7 +62,7 @@ namespace Spine { Vector _linkedMeshes; float _scale; const bool _ownsLoader; - std::string _error; + String _error; static float toColor(const char* value, int index); diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index cdab8ab05..c768a564a 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -31,9 +31,9 @@ #ifndef Spine_Skin_h #define Spine_Skin_h -#include #include #include +#include namespace Spine { class Attachment; @@ -49,9 +49,9 @@ namespace Spine { class AttachmentKey { public: int _slotIndex; - std::string _name; + String _name; - AttachmentKey(int slotIndex = 0, std::string name = ""); + AttachmentKey(int slotIndex = 0, const String& name = ""); AttachmentKey(const AttachmentKey &other) { this->_slotIndex = other._slotIndex; @@ -65,31 +65,31 @@ namespace Spine { std::size_t operator()(const Spine::Skin::AttachmentKey& val) const; }; - Skin(std::string name); + Skin(const String& name); ~Skin(); /// Adds an attachment to the skin for the specified slot index and name. /// If the name already exists for the slot, the previous value is replaced. - void addAttachment(int slotIndex, std::string name, Attachment* attachment); + void addAttachment(int slotIndex, const String& name, Attachment* attachment); /// Returns the attachment for the specified slot index and name, or NULL. - Attachment* getAttachment(int slotIndex, std::string name); + Attachment* getAttachment(int slotIndex, const String& name); /// Finds the skin keys for a given slot. The results are added to the passed array of names. /// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex /// @param names Found skin key names will be added to this array. - void findNamesForSlot(int slotIndex, Vector& names); + void findNamesForSlot(int slotIndex, Vector& names); /// Finds the attachments for a given slot. The results are added to the passed array of Attachments. /// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex /// @param attachments Found Attachments will be added to this array. void findAttachmentsForSlot(int slotIndex, Vector& attachments); - - const std::string& getName(); + + const String& getName(); HashMap& getAttachments(); private: - const std::string _name; + const String _name; HashMap _attachments; /// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached. diff --git a/spine-cpp/spine-cpp/include/spine/SlotData.h b/spine-cpp/spine-cpp/include/spine/SlotData.h index 992b496e6..292b4ca0c 100644 --- a/spine-cpp/spine-cpp/include/spine/SlotData.h +++ b/spine-cpp/spine-cpp/include/spine/SlotData.h @@ -33,8 +33,7 @@ #include #include - -#include +#include namespace Spine { class BoneData; @@ -59,11 +58,11 @@ namespace Spine { friend class TwoColorTimeline; public: - SlotData(int index, std::string name, BoneData& boneData); + SlotData(int index, const String& name, BoneData& boneData); const int getIndex(); - const std::string& getName(); + const String& getName(); BoneData& getBoneData(); @@ -86,20 +85,20 @@ namespace Spine { void setHasSecondColor(bool inValue); /// May be empty. - std::string getAttachmentName(); - void setAttachmentName(std::string inValue); + const String& getAttachmentName(); + void setAttachmentName(const String& inValue); BlendMode getBlendMode(); void setBlendMode(BlendMode inValue); private: const int _index; - const std::string _name; + String _name; BoneData& _boneData; float _r, _g, _b, _a; float _r2, _g2, _b2, _a2; bool _hasSecondColor; - std::string _attachmentName; + String _attachmentName; BlendMode _blendMode; }; } diff --git a/spine-cpp/spine-cpp/include/spine/String.h b/spine-cpp/spine-cpp/include/spine/String.h new file mode 100644 index 000000000..27f2647b0 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/String.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * Spine Runtimes Software License v2.5 + * + * Copyright (c) 2013-2016, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable, and + * non-transferable license to use, install, execute, and perform the Spine + * Runtimes software and derivative works solely for personal or internal + * use. Without the written permission of Esoteric Software (see Section 2 of + * the Spine Software License Agreement), you may not (a) modify, translate, + * adapt, or develop new applications using the Spine Runtimes or otherwise + * create derivative works or improvements of the Spine Runtimes or (b) remove, + * delete, alter, or obscure any trademarks or any copyright, trademark, patent, + * or other intellectual property or proprietary rights notices on or in the + * Software, including any copy thereof. Redistributions in binary or source + * form must include this license and terms. + * + * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF + * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef SPINE_STRING_H +#define SPINE_STRING_H + +#include +#include + +#include + +namespace Spine { + class String : public SpineObject { + public: + String (): _length(0), _buffer(NULL) { + } + + String (const char* chars, bool own = false) { + if (!chars) { + _length = 0; + _buffer = NULL; + } else { + _length = strlen(chars); + if (!own) { + _buffer = SpineExtension::alloc(_length + 1, __FILE__, __LINE__); + memcpy((void *) _buffer, chars, _length + 1); + } else { + _buffer = chars; + } + } + } + + String (const String& other) { + if (!other._buffer) { + _length = 0; + _buffer = NULL; + } else { + _length = other._length; + _buffer = SpineExtension::alloc(other._length + 1, __FILE__, __LINE__); + memcpy((void*)_buffer, other._buffer, other._length + 1); + } + } + + size_t length () const { + return _length; + } + + const char* buffer () const { + return _buffer; + } + + void own (const String& other) { + if (this == &other) return; + if (_buffer) { + SpineExtension::free(_buffer, __FILE__, __LINE__); + } + _length = other._length; + _buffer = other._buffer; + other._length = 0; + other._buffer = NULL; + } + + void own (const char* chars) { + if (_buffer == chars) return; + if (_buffer) { + SpineExtension::free(_buffer, __FILE__, __LINE__); + } + + if (!chars) { + _length = 0; + _buffer = 0; + } else { + _length = strlen(chars); + _buffer = chars; + } + } + + String& operator= (const String& other) { + if (this == &other) return *this; + if (_buffer) { + SpineExtension::free(_buffer, __FILE__, __LINE__); + } + if (!other._buffer) { + _length = 0; + _buffer = NULL; + } else { + _length = other._length; + _buffer = SpineExtension::alloc(other._length + 1, __FILE__, __LINE__); + memcpy((void*)_buffer, other._buffer, other._length + 1); + } + return *this; + } + + String& operator= (const char* chars) { + if (_buffer == chars) return *this; + if (_buffer) { + SpineExtension::free(_buffer, __FILE__, __LINE__); + } + if (!chars) { + _length = 0; + _buffer = NULL; + } else { + _length = strlen(chars); + _buffer = SpineExtension::alloc(_length + 1, __FILE__, __LINE__); + memcpy((void*)_buffer, chars, _length + 1); + } + return *this; + } + + friend bool operator== (const String& a, const String& b) { + if (a._buffer == b._buffer) return true; + if (a._length != b._length) return false; + if (a._buffer && b._buffer) { + return strcmp(a._buffer, b._buffer) == 0; + } else { + return false; + } + } + + friend bool operator!= (const String& a, const String& b) { + return !(a == b); + } + + ~String () { + if (_buffer) { + SpineExtension::free(_buffer, __FILE__, __LINE__); + } + } + private: + mutable size_t _length; + mutable const char* _buffer; + }; +} + + +#endif //SPINE_STRING_H diff --git a/spine-cpp/spine-cpp/include/spine/TextureLoader.h b/spine-cpp/spine-cpp/include/spine/TextureLoader.h index 54c32889a..feb5fbbfc 100644 --- a/spine-cpp/spine-cpp/include/spine/TextureLoader.h +++ b/spine-cpp/spine-cpp/include/spine/TextureLoader.h @@ -32,8 +32,7 @@ #define Spine_TextureLoader_h #include - -#include +#include namespace Spine { class AtlasPage; @@ -44,7 +43,7 @@ namespace Spine { virtual ~TextureLoader(); - virtual void load(AtlasPage& page, std::string path) = 0; + virtual void load(AtlasPage& page, const String& path) = 0; virtual void unload(void* texture) = 0; }; diff --git a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h index 4e27659b4..d342e0c0c 100644 --- a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h @@ -33,8 +33,7 @@ #include #include - -#include +#include namespace Spine { class BoneData; @@ -48,9 +47,9 @@ namespace Spine { friend class TransformConstraintTimeline; public: - TransformConstraintData(std::string name); - - const std::string& getName(); + TransformConstraintData(const String& name); + + const String& getName(); int getOrder(); Vector& getBones(); BoneData* getTarget(); @@ -70,7 +69,7 @@ namespace Spine { bool isLocal(); private: - const std::string _name; + const String _name; int _order; Vector _bones; BoneData* _target; diff --git a/spine-cpp/spine-cpp/include/spine/VertexAttachment.h b/spine-cpp/spine-cpp/include/spine/VertexAttachment.h index 33aa2049a..71e244a91 100644 --- a/spine-cpp/spine-cpp/include/spine/VertexAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/VertexAttachment.h @@ -47,7 +47,7 @@ namespace Spine { RTTI_DECL public: - VertexAttachment(std::string name); + VertexAttachment(const String& name); virtual ~VertexAttachment(); diff --git a/spine-cpp/spine-cpp/include/spine/spine.h b/spine-cpp/spine-cpp/include/spine/spine.h index 7c3250e1e..6300b873d 100644 --- a/spine-cpp/spine-cpp/include/spine/spine.h +++ b/spine-cpp/spine-cpp/include/spine/spine.h @@ -88,6 +88,7 @@ #include #include #include +#include #include #include #include diff --git a/spine-cpp/spine-cpp/src/spine/Animation.cpp b/spine-cpp/spine-cpp/src/spine/Animation.cpp index 3b25f5b95..fabee44a1 100644 --- a/spine-cpp/spine-cpp/src/spine/Animation.cpp +++ b/spine-cpp/spine-cpp/src/spine/Animation.cpp @@ -40,7 +40,7 @@ #include /* fmod */ namespace Spine { - Animation::Animation(std::string name, Vector& timelines, float duration) : + Animation::Animation(const String& name, Vector& timelines, float duration) : _timelines(timelines), _duration(duration), _name(name) { @@ -64,7 +64,7 @@ namespace Spine { } } - std::string Animation::getName() { + const String& Animation::getName() { return _name; } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index 68adbec99..e4d0067d9 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -500,7 +500,7 @@ namespace Spine { _queue->drain(); } - TrackEntry* AnimationState::setAnimation(int trackIndex, std::string animationName, bool loop) { + TrackEntry* AnimationState::setAnimation(int trackIndex, const String& animationName, bool loop) { Animation* animation = _data->_skeletonData->findAnimation(animationName); assert(animation != NULL); @@ -534,7 +534,7 @@ namespace Spine { return entry; } - TrackEntry* AnimationState::addAnimation(int trackIndex, std::string animationName, bool loop, float delay) { + TrackEntry* AnimationState::addAnimation(int trackIndex, const String& animationName, bool loop, float delay) { Animation* animation = _data->_skeletonData->findAnimation(animationName); assert(animation != NULL); @@ -643,7 +643,7 @@ namespace Spine { Animation* AnimationState::getEmptyAnimation() { static Vector timelines; - static Animation ret(std::string(""), timelines, 0); + static Animation ret(String(""), timelines, 0); return &ret; } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp index c57451e19..6817dc38e 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp @@ -38,7 +38,7 @@ namespace Spine { // Empty } - void AnimationStateData::setMix(std::string fromName, std::string toName, float duration) { + void AnimationStateData::setMix(const String& fromName, const String& toName, float duration) { Animation* from = _skeletonData->findAnimation(fromName); Animation* to = _skeletonData->findAnimation(toName); @@ -94,13 +94,13 @@ namespace Spine { std::size_t h1 = 7; size_t strlen = val._a1->_name.length(); for (int i = 0; i < strlen; ++i) { - h1 = h1 * 31 + val._a1->_name.at(i); + h1 = h1 * 31 + val._a1->_name.buffer()[i]; } std::size_t h2 = 7; strlen = val._a2->_name.length(); for (int i = 0; i < strlen; ++i) { - h2 = h2 * 31 + val._a2->_name.at(i); + h2 = h2 * 31 + val._a2->_name.buffer()[i]; } return (((h1 << 5) + h1) ^ h2); diff --git a/spine-cpp/spine-cpp/src/spine/Atlas.cpp b/spine-cpp/spine-cpp/src/spine/Atlas.cpp index 8a8ca5006..2c15e91cb 100644 --- a/spine-cpp/spine-cpp/src/spine/Atlas.cpp +++ b/spine-cpp/spine-cpp/src/spine/Atlas.cpp @@ -80,7 +80,7 @@ namespace Spine { } } - AtlasRegion* Atlas::findRegion(std::string name) { + AtlasRegion* Atlas::findRegion(const String& name) { for (size_t i = 0, n = _regions.size(); i < n; ++i) { if (_regions[i]->name == name) { return _regions[i]; @@ -124,9 +124,7 @@ namespace Spine { } strcpy(path + dirLength + needsSlash, name); - page = new (__FILE__, __LINE__) AtlasPage(std::string(name)); - - SpineExtension::free(name, __FILE__, __LINE__); + page = new (__FILE__, __LINE__) AtlasPage(String(name, true)); int tupleVal = readTuple(&begin, end, tuple); assert(tupleVal == 2); @@ -161,7 +159,7 @@ namespace Spine { } } - if (_textureLoader) _textureLoader->load(*page, std::string(path)); + if (_textureLoader) _textureLoader->load(*page, String(path)); SpineExtension::free(path, __FILE__, __LINE__); @@ -171,10 +169,7 @@ namespace Spine { AtlasRegion* region = new (__FILE__, __LINE__) AtlasRegion(); region->page = page; - - char* name = mallocString(&str); - region->name = std::string(name); - SpineExtension::free(name, __FILE__, __LINE__); + region->name = String(mallocString(&str), true); assert(readValue(&begin, end, &str)); region->rotate = equals(&str, "true"); diff --git a/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp b/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp index 07c5edd91..86f7b6a86 100644 --- a/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp +++ b/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp @@ -47,7 +47,7 @@ namespace Spine { // Empty } - RegionAttachment* AtlasAttachmentLoader::newRegionAttachment(Skin& skin, std::string name, std::string path) { + RegionAttachment* AtlasAttachmentLoader::newRegionAttachment(Skin& skin, const String& name, const String& path) { AtlasRegion* regionP = findRegion(path); assert(regionP != NULL); @@ -67,7 +67,7 @@ namespace Spine { return attachmentP; } - MeshAttachment* AtlasAttachmentLoader::newMeshAttachment(Skin& skin, std::string name, std::string path) { + MeshAttachment* AtlasAttachmentLoader::newMeshAttachment(Skin& skin, const String& name, const String& path) { AtlasRegion* regionP = findRegion(path); assert(regionP != NULL); @@ -92,23 +92,23 @@ namespace Spine { return attachmentP; } - BoundingBoxAttachment* AtlasAttachmentLoader::newBoundingBoxAttachment(Skin& skin, std::string name) { + BoundingBoxAttachment* AtlasAttachmentLoader::newBoundingBoxAttachment(Skin& skin, const String& name) { return new (__FILE__, __LINE__) BoundingBoxAttachment(name); } - PathAttachment* AtlasAttachmentLoader::newPathAttachment(Skin& skin, std::string name) { + PathAttachment* AtlasAttachmentLoader::newPathAttachment(Skin& skin, const String& name) { return new (__FILE__, __LINE__) PathAttachment(name); } - PointAttachment* AtlasAttachmentLoader::newPointAttachment(Skin& skin, std::string name) { + PointAttachment* AtlasAttachmentLoader::newPointAttachment(Skin& skin, const String& name) { return new (__FILE__, __LINE__) PointAttachment(name); } - ClippingAttachment* AtlasAttachmentLoader::newClippingAttachment(Skin& skin, std::string name) { + ClippingAttachment* AtlasAttachmentLoader::newClippingAttachment(Skin& skin, const String& name) { return new (__FILE__, __LINE__) ClippingAttachment(name); } - AtlasRegion* AtlasAttachmentLoader::findRegion(std::string name) { + AtlasRegion* AtlasAttachmentLoader::findRegion(const String& name) { AtlasRegion* ret; return _atlas->findRegion(name); } diff --git a/spine-cpp/spine-cpp/src/spine/Attachment.cpp b/spine-cpp/spine-cpp/src/spine/Attachment.cpp index ea91881fc..246faa984 100644 --- a/spine-cpp/spine-cpp/src/spine/Attachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/Attachment.cpp @@ -35,14 +35,14 @@ namespace Spine { RTTI_IMPL_NOPARENT(Attachment); - Attachment::Attachment(std::string name) : _name(name) { + Attachment::Attachment(const String& name) : _name(name) { assert(_name.length() > 0); } Attachment::~Attachment() { } - - const std::string& Attachment::getName() { + + const String& Attachment::getName() { return _name; } } diff --git a/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp b/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp index 7c417a7c8..8d35c2b08 100644 --- a/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp @@ -48,27 +48,27 @@ namespace Spine { _frames.setSize(frameCount); for (int i = 0; i < frameCount; ++i) { - _attachmentNames.push_back(std::string("")); + _attachmentNames.push_back(String()); } } void AttachmentTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector* pEvents, float alpha, MixPose pose, MixDirection direction) { assert(_slotIndex < skeleton._slots.size()); - - std::string attachmentName; + + String* attachmentName; Slot* slotP = skeleton._slots[_slotIndex]; Slot& slot = *slotP; if (direction == MixDirection_Out && pose == MixPose_Setup) { - attachmentName = slot._data._attachmentName; - slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName); + attachmentName = &slot._data._attachmentName; + slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName); return; } if (time < _frames[0]) { // Time is before first frame. if (pose == MixPose_Setup) { - attachmentName = slot._data._attachmentName; - slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName); + attachmentName = &slot._data._attachmentName; + slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName); } return; } @@ -82,15 +82,15 @@ namespace Spine { frameIndex = Animation::binarySearch(_frames, time, 1) - 1; } - attachmentName = _attachmentNames[frameIndex]; - slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName); + attachmentName = &_attachmentNames[frameIndex]; + slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName); } int AttachmentTimeline::getPropertyId() { return ((int)TimelineType_Attachment << 24) + _slotIndex; } - void AttachmentTimeline::setFrame(int frameIndex, float time, std::string attachmentName) { + void AttachmentTimeline::setFrame(int frameIndex, float time, const String& attachmentName) { _frames[frameIndex] = time; _attachmentNames[frameIndex] = attachmentName; } @@ -103,7 +103,7 @@ namespace Spine { _slotIndex = inValue; } - Vector& AttachmentTimeline::getFrames() { + const Vector& AttachmentTimeline::getFrames() { return _frames; } @@ -111,11 +111,11 @@ namespace Spine { _frames = inValue; } - Vector AttachmentTimeline::getAttachmentNames() { + const Vector& AttachmentTimeline::getAttachmentNames() { return _attachmentNames; } - void AttachmentTimeline::setAttachmentNames(Vector& inValue) { + void AttachmentTimeline::setAttachmentNames(Vector& inValue) { _attachmentNames = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/BoneData.cpp b/spine-cpp/spine-cpp/src/spine/BoneData.cpp index f0cbb9502..02af9eb41 100644 --- a/spine-cpp/spine-cpp/src/spine/BoneData.cpp +++ b/spine-cpp/spine-cpp/src/spine/BoneData.cpp @@ -33,7 +33,7 @@ #include namespace Spine { - BoneData::BoneData(int index, std::string name, BoneData* parent) : + BoneData::BoneData(int index, const String& name, BoneData* parent) : _index(index), _name(name), _parent(parent), @@ -50,11 +50,11 @@ namespace Spine { assert(_name.length() > 0); } - const int BoneData::getIndex() { + int BoneData::getIndex() { return _index; } - const std::string& BoneData::getName() { + const String& BoneData::getName() { return _name; } diff --git a/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp b/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp index 41148ae80..0bc0e56dd 100644 --- a/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp @@ -33,7 +33,7 @@ namespace Spine { RTTI_IMPL(BoundingBoxAttachment, VertexAttachment); - BoundingBoxAttachment::BoundingBoxAttachment(std::string name) : VertexAttachment(name) { + BoundingBoxAttachment::BoundingBoxAttachment(const String& name) : VertexAttachment(name) { // Empty } } diff --git a/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp b/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp index 644ba9c39..3ce1afe3f 100644 --- a/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp @@ -35,7 +35,7 @@ namespace Spine { RTTI_IMPL(ClippingAttachment, VertexAttachment); - ClippingAttachment::ClippingAttachment(std::string name) : VertexAttachment(name), _endSlot(NULL) { + ClippingAttachment::ClippingAttachment(const String& name) : VertexAttachment(name), _endSlot(NULL) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/Event.cpp b/spine-cpp/spine-cpp/src/spine/Event.cpp index f5ef271d2..b2725c755 100644 --- a/spine-cpp/spine-cpp/src/spine/Event.cpp +++ b/spine-cpp/spine-cpp/src/spine/Event.cpp @@ -65,12 +65,12 @@ namespace Spine { void Event::setFloatValue(int inValue) { _floatValue = inValue; } - - std::string Event::getStringValue() { + + const String& Event::getStringValue() { return _stringValue; } - void Event::setStringValue(std::string inValue) { + void Event::setStringValue(const String& inValue) { _stringValue = inValue; } } diff --git a/spine-cpp/spine-cpp/src/spine/EventData.cpp b/spine-cpp/spine-cpp/src/spine/EventData.cpp index 1d390e459..ad60f9afb 100644 --- a/spine-cpp/spine-cpp/src/spine/EventData.cpp +++ b/spine-cpp/spine-cpp/src/spine/EventData.cpp @@ -33,7 +33,7 @@ #include namespace Spine { - EventData::EventData(std::string name) : + EventData::EventData(const String& name) : _name(name), _intValue(0), _floatValue(0), @@ -42,7 +42,7 @@ namespace Spine { } /// The name of the event, which is unique within the skeleton. - const std::string& EventData::getName() { + const String& EventData::getName() { return _name; } @@ -62,11 +62,11 @@ namespace Spine { _floatValue = inValue; } - std::string EventData::getStringValue() { + const String& EventData::getStringValue() { return _stringValue; } - void EventData::setStringValue(std::string inValue) { + void EventData::setStringValue(const String& inValue) { _stringValue = inValue; } } diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp index 416d5cebe..a26974f0f 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp @@ -33,7 +33,7 @@ #include namespace Spine { - IkConstraintData::IkConstraintData(std::string name) : + IkConstraintData::IkConstraintData(const String& name) : _name(name), _order(0), _target(NULL), @@ -42,7 +42,7 @@ namespace Spine { // Empty } - const std::string& IkConstraintData::getName() { + const String& IkConstraintData::getName() { return _name; } diff --git a/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp b/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp index 2cbfef3d5..2df2edb19 100644 --- a/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp +++ b/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp @@ -33,7 +33,7 @@ #include namespace Spine { - LinkedMesh::LinkedMesh(MeshAttachment* mesh, std::string skin, int slotIndex, std::string parent) : + LinkedMesh::LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent) : _mesh(mesh), _skin(skin), _slotIndex(slotIndex), diff --git a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp index b6c5ff92a..071dfb931 100644 --- a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp @@ -33,7 +33,7 @@ namespace Spine { RTTI_IMPL(MeshAttachment, VertexAttachment); - MeshAttachment::MeshAttachment(std::string name) : VertexAttachment(name), + MeshAttachment::MeshAttachment(const String& name) : VertexAttachment(name), _regionOffsetX(0), _regionOffsetY(0), _regionWidth(0), @@ -148,11 +148,11 @@ namespace Spine { _a = inValue; } - std::string MeshAttachment::getPath() { + const String& MeshAttachment::getPath() { return _path; } - void MeshAttachment::setPath(std::string inValue) { + void MeshAttachment::setPath(const String& inValue) { _path = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp index 4e5c93cfd..92bd6eff6 100644 --- a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp @@ -33,7 +33,7 @@ namespace Spine { RTTI_IMPL(PathAttachment, VertexAttachment); - PathAttachment::PathAttachment(std::string name) : VertexAttachment(name), _closed(false), _constantSpeed(false) { + PathAttachment::PathAttachment(const String& name) : VertexAttachment(name), _closed(false), _constantSpeed(false) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp index caa545e3d..24ff73ddf 100644 --- a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp @@ -36,7 +36,7 @@ #include namespace Spine { - PathConstraintData::PathConstraintData(std::string name) : + PathConstraintData::PathConstraintData(const String& name) : _name(name), _order(0), _target(NULL), @@ -50,8 +50,8 @@ namespace Spine { _translateMix(0) { assert(_name.length() > 0); } - - const std::string& PathConstraintData::getName() { + + const String& PathConstraintData::getName() { return _name; } diff --git a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp index d69338695..e7aa27ff8 100644 --- a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp @@ -37,7 +37,7 @@ namespace Spine { RTTI_IMPL(PointAttachment, Attachment); - PointAttachment::PointAttachment(std::string name) : Attachment(name), _x(0), _y(0), _rotation(0) { + PointAttachment::PointAttachment(const String& name) : Attachment(name), _x(0), _y(0), _rotation(0) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/RTTI.cpp b/spine-cpp/spine-cpp/src/spine/RTTI.cpp index db6898c25..f4687eb53 100644 --- a/spine-cpp/spine-cpp/src/spine/RTTI.cpp +++ b/spine-cpp/spine-cpp/src/spine/RTTI.cpp @@ -29,18 +29,19 @@ *****************************************************************************/ #include +#include namespace Spine { - RTTI::RTTI(const std::string& className) : m_className(className), m_pBaseRTTI(NULL) { + RTTI::RTTI(const std::string& className) : _className(className), _pBaseRTTI(NULL) { // Empty } - RTTI::RTTI(const std::string& className, const RTTI& baseRTTI) : m_className(className), m_pBaseRTTI(&baseRTTI) { + RTTI::RTTI(const std::string& className, const RTTI& baseRTTI) : _className(className), _pBaseRTTI(&baseRTTI) { // Empty } const std::string& RTTI::getClassName() const { - return m_className; + return _className; } bool RTTI::isExactly(const RTTI& rtti) const { @@ -55,7 +56,7 @@ namespace Spine { return true; } - pCompare = pCompare->m_pBaseRTTI; + pCompare = pCompare->_pBaseRTTI; } return false; diff --git a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp index 8a83f28ea..cf7edfc60 100644 --- a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp @@ -48,7 +48,7 @@ namespace Spine { const int RegionAttachment::BRX = 6; const int RegionAttachment::BRY = 7; - RegionAttachment::RegionAttachment(std::string name) : Attachment(name), + RegionAttachment::RegionAttachment(const String& name) : Attachment(name), _x(0), _y(0), _rotation(0), @@ -249,11 +249,11 @@ namespace Spine { _a = inValue; } - std::string RegionAttachment::getPath() { + const String& RegionAttachment::getPath() { return _path; } - void RegionAttachment::setPath(std::string inValue) { + void RegionAttachment::setPath(const String& inValue) { _path = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp index 99c3cae86..6c8821a0e 100644 --- a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp @@ -269,23 +269,23 @@ namespace Spine { } } - Bone* Skeleton::findBone(std::string boneName) { + Bone* Skeleton::findBone(const String& boneName) { return ContainerUtil::findWithDataName(_bones, boneName); } - int Skeleton::findBoneIndex(std::string boneName) { + int Skeleton::findBoneIndex(const String& boneName) { return ContainerUtil::findIndexWithDataName(_bones, boneName); } - Slot* Skeleton::findSlot(std::string slotName) { + Slot* Skeleton::findSlot(const String& slotName) { return ContainerUtil::findWithDataName(_slots, slotName); } - int Skeleton::findSlotIndex(std::string slotName) { + int Skeleton::findSlotIndex(const String& slotName) { return ContainerUtil::findIndexWithDataName(_slots, slotName); } - void Skeleton::setSkin(std::string skinName) { + void Skeleton::setSkin(const String& skinName) { Skin* foundSkin = _data->findSkin(skinName); assert(foundSkin != NULL); @@ -303,7 +303,7 @@ namespace Spine { for (int i = 0, n = static_cast(_slots.size()); i < n; ++i) { Slot* slotP = _slots[i]; Slot& slot = *slotP; - std::string name = slot._data.getAttachmentName(); + const String& name = slot._data.getAttachmentName(); if (name.length() > 0) { Attachment* attachment = newSkin->getAttachment(i, name); if (attachment != NULL) { @@ -317,11 +317,11 @@ namespace Spine { _skin = newSkin; } - Attachment* Skeleton::getAttachment(std::string slotName, std::string attachmentName) { + Attachment* Skeleton::getAttachment(const String& slotName, const String& attachmentName) { return getAttachment(_data->findSlotIndex(slotName), attachmentName); } - Attachment* Skeleton::getAttachment(int slotIndex, std::string attachmentName) { + Attachment* Skeleton::getAttachment(int slotIndex, const String& attachmentName) { assert(attachmentName.length() > 0); if (_skin != NULL) { @@ -334,7 +334,7 @@ namespace Spine { return _data->getDefaultSkin() != NULL ? _data->getDefaultSkin()->getAttachment(slotIndex, attachmentName) : NULL; } - void Skeleton::setAttachment(std::string slotName, std::string attachmentName) { + void Skeleton::setAttachment(const String& slotName, const String& attachmentName) { assert(slotName.length() > 0); for (int i = 0, n = static_cast(_slots.size()); i < n; ++i) { @@ -353,12 +353,12 @@ namespace Spine { } } - printf("Slot not found: %s", slotName.c_str()); + printf("Slot not found: %s", slotName.buffer()); assert(false); } - IkConstraint* Skeleton::findIkConstraint(std::string constraintName) { + IkConstraint* Skeleton::findIkConstraint(const String& constraintName) { assert(constraintName.length() > 0); for (int i = 0, n = static_cast(_ikConstraints.size()); i < n; ++i) { @@ -370,7 +370,7 @@ namespace Spine { return NULL; } - TransformConstraint* Skeleton::findTransformConstraint(std::string constraintName) { + TransformConstraint* Skeleton::findTransformConstraint(const String& constraintName) { assert(constraintName.length() > 0); for (int i = 0, n = static_cast(_transformConstraints.size()); i < n; ++i) { @@ -383,7 +383,7 @@ namespace Spine { return NULL; } - PathConstraint* Skeleton::findPathConstraint(std::string constraintName) { + PathConstraint* Skeleton::findPathConstraint(const String& constraintName) { assert(constraintName.length() > 0); for (int i = 0, n = static_cast(_pathConstraints.size()); i < n; ++i) { diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp index 337d6c5a5..f732bef0e 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp @@ -135,12 +135,10 @@ namespace Spine { skeletonData = new (__FILE__, __LINE__) SkeletonData(); char* skeletonData_hash = readString(input); - skeletonData->_hash = std::string(skeletonData_hash); - SpineExtension::free(skeletonData_hash, __FILE__, __LINE__); + skeletonData->_hash.own(skeletonData_hash); char* skeletonData_version = readString(input); - skeletonData->_version = std::string(skeletonData_version); - SpineExtension::free(skeletonData_version, __FILE__, __LINE__); + skeletonData->_version.own(skeletonData_version); skeletonData->_width = readFloat(input); skeletonData->_height = readFloat(input); @@ -164,10 +162,7 @@ namespace Spine { const char* name = readString(input); BoneData* parent = i == 0 ? 0 : skeletonData->_bones[readVarint(input, 1)]; - data = new (__FILE__, __LINE__) BoneData(i, std::string(name), parent); - - SpineExtension::free(name, __FILE__, __LINE__); - + data = new (__FILE__, __LINE__) BoneData(i, String(name, true), parent); data->_rotation = readFloat(input); data->_x = readFloat(input) * _scale; data->_y = readFloat(input) * _scale; @@ -213,9 +208,8 @@ namespace Spine { const char* slotName = readString(input); BoneData* boneData = skeletonData->_bones[readVarint(input, 1)]; - SlotData* slotData = new (__FILE__, __LINE__) SlotData(i, std::string(slotName), *boneData); + SlotData* slotData = new (__FILE__, __LINE__) SlotData(i, String(slotName, true), *boneData); - SpineExtension::free(slotName, __FILE__, __LINE__); readColor(input, &slotData->_r, &slotData->_g, &slotData->_b, &slotData->_a); r = readByte(input); g = readByte(input); @@ -226,9 +220,7 @@ namespace Spine { slotData->_g2 = g / 255.0f; slotData->_b2 = b / 255.0f; } - char* slotData_attachmentName = readString(input); - slotData->_attachmentName = std::string(slotData_attachmentName); - SpineExtension::free(slotData_attachmentName, __FILE__, __LINE__); + slotData->_attachmentName.own(readString(input)); slotData->_blendMode = static_cast(readVarint(input, 1)); skeletonData->_slots[i] = slotData; @@ -241,11 +233,10 @@ namespace Spine { for (i = 0; i < ikConstraintsCount; ++i) { const char* name = readString(input); - IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(std::string(name)); + IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(String(name, true)); data->_order = readVarint(input, 1); - SpineExtension::free(name, __FILE__, __LINE__); int bonesCount = readVarint(input, 1); data->_bones.reserve(bonesCount); data->_bones.setSize(bonesCount); @@ -266,10 +257,9 @@ namespace Spine { for (i = 0; i < transformConstraintsCount; ++i) { const char* name = readString(input); - TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(std::string(name)); + TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(String(name, true)); data->_order = readVarint(input, 1); - SpineExtension::free(name, __FILE__, __LINE__); int bonesCount = readVarint(input, 1); data->_bones.reserve(bonesCount); data->_bones.setSize(bonesCount); @@ -300,10 +290,9 @@ namespace Spine { for (i = 0; i < pathConstraintsCount; ++i) { const char* name = readString(input); - PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(std::string(name)); + PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(String(name, true)); data->_order = readVarint(input, 1); - SpineExtension::free(name, __FILE__, __LINE__); int bonesCount = readVarint(input, 1); data->_bones.reserve(bonesCount); @@ -360,14 +349,14 @@ namespace Spine { if (skin == NULL) { delete input; delete skeletonData; - setError("Skin not found: ", linkedMesh->_skin.c_str()); + setError("Skin not found: ", linkedMesh->_skin.buffer()); return NULL; } Attachment* parent = skin->getAttachment(linkedMesh->_slotIndex, linkedMesh->_parent); if (parent == NULL) { delete input; delete skeletonData; - setError("Parent mesh not found: ", linkedMesh->_parent.c_str()); + setError("Parent mesh not found: ", linkedMesh->_parent.buffer()); return NULL; } linkedMesh->_mesh->_parentMesh = static_cast(parent); @@ -381,13 +370,10 @@ namespace Spine { skeletonData->_events.setSize(eventsCount); for (i = 0; i < eventsCount; ++i) { const char* name = readString(input); - EventData* eventData = new (__FILE__, __LINE__) EventData(std::string(name)); - SpineExtension::free(name, __FILE__, __LINE__); + EventData* eventData = new (__FILE__, __LINE__) EventData(String(name, true)); eventData->_intValue = readVarint(input, 0); eventData->_floatValue = readFloat(input); - const char* eventData_stringValue = readString(input); - eventData->_stringValue = std::string(eventData_stringValue); - SpineExtension::free(eventData_stringValue, __FILE__, __LINE__); + eventData->_stringValue.own(readString(input)); SpineExtension::free(readString(input), __FILE__, __LINE__); // skip audio path skeletonData->_events[i] = eventData; } @@ -435,7 +421,7 @@ namespace Spine { strncat(message + length, value2, 255 - length); } - _error = std::string(message); + _error = message; } char* SkeletonBinary::readString(DataInput* input) { @@ -524,7 +510,7 @@ namespace Spine { return NULL; } - skin = new (__FILE__, __LINE__) Skin(std::string(skinName)); + skin = new (__FILE__, __LINE__) Skin(String(skinName)); for (i = 0; i < slotCount; ++i) { int slotIndex = readVarint(input, 1); @@ -532,7 +518,7 @@ namespace Spine { const char* name = readString(input); Attachment* attachment = readAttachment(input, skin, slotIndex, name, skeletonData, nonessential); if (attachment) { - skin->addAttachment(slotIndex, std::string(name), attachment); + skin->addAttachment(slotIndex, String(name), attachment); } SpineExtension::free(name, __FILE__, __LINE__); } @@ -560,8 +546,8 @@ namespace Spine { if (!path) { path = name; } - region = _attachmentLoader->newRegionAttachment(*skin, std::string(name), std::string(path)); - region->_path = std::string(path); + region = _attachmentLoader->newRegionAttachment(*skin, String(name), String(path)); + region->_path = String(path); region->_rotation = readFloat(input); region->_x = readFloat(input) * _scale; region->_y = readFloat(input) * _scale; @@ -580,7 +566,7 @@ namespace Spine { } case AttachmentType_Boundingbox: { int vertexCount = readVarint(input, 1); - BoundingBoxAttachment* box = _attachmentLoader->newBoundingBoxAttachment(*skin, std::string(name)); + BoundingBoxAttachment* box = _attachmentLoader->newBoundingBoxAttachment(*skin, String(name)); readVertices(input, static_cast(box), vertexCount); if (nonessential) { /* Skip color. */ @@ -599,8 +585,8 @@ namespace Spine { if (!path) { path = name; } - mesh = _attachmentLoader->newMeshAttachment(*skin, std::string(name), std::string(path)); - mesh->_path = std::string(path); + mesh = _attachmentLoader->newMeshAttachment(*skin, String(name), String(path)); + mesh->_path = String(path); readColor(input, &mesh->_r, &mesh->_g, &mesh->_b, &mesh->_a); vertexCount = readVarint(input, 1); Vector float_array = readFloatArray(input, vertexCount << 1, 1); @@ -636,7 +622,7 @@ namespace Spine { path = name; } - mesh = _attachmentLoader->newMeshAttachment(*skin, std::string(name), std::string(path)); + mesh = _attachmentLoader->newMeshAttachment(*skin, String(name), String(path)); mesh->_path = path; readColor(input, &mesh->_r, &mesh->_g, &mesh->_b, &mesh->_a); skinName = readString(input); @@ -647,7 +633,7 @@ namespace Spine { mesh->_height = readFloat(input) * _scale; } - LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, std::string(skinName), slotIndex, std::string(parent)); + LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex, String(parent)); _linkedMeshes.push_back(linkedMesh); if (freeName) { @@ -660,7 +646,7 @@ namespace Spine { return mesh; } case AttachmentType_Path: { - PathAttachment* path = _attachmentLoader->newPathAttachment(*skin, std::string(name)); + PathAttachment* path = _attachmentLoader->newPathAttachment(*skin, String(name)); int vertexCount = 0; path->_closed = readBoolean(input); path->_constantSpeed = readBoolean(input); @@ -685,7 +671,7 @@ namespace Spine { return path; } case AttachmentType_Point: { - PointAttachment* point = _attachmentLoader->newPointAttachment(*skin, std::string(name)); + PointAttachment* point = _attachmentLoader->newPointAttachment(*skin, String(name)); point->_rotation = readFloat(input); point->_x = readFloat(input) * _scale; point->_y = readFloat(input) * _scale; @@ -806,8 +792,7 @@ namespace Spine { timeline->_slotIndex = slotIndex; for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { const char* attachmentName = readString(input); - timeline->setFrame(frameIndex, readFloat(input), std::string(attachmentName)); - SpineExtension::free(attachmentName, __FILE__, __LINE__); + timeline->setFrame(frameIndex, readFloat(input), String(attachmentName, true)); } timelines.push_back(timeline); duration = MAX(duration, timeline->_frames[frameCount - 1]); @@ -858,7 +843,7 @@ namespace Spine { } default: { ContainerUtil::cleanUpVectorOfPointers(timelines); - setError("Invalid timeline type for a slot: ", skeletonData->_slots[slotIndex]->_name.c_str()); + setError("Invalid timeline type for a slot: ", skeletonData->_slots[slotIndex]->_name.buffer()); return NULL; } } @@ -913,7 +898,7 @@ namespace Spine { } default: { ContainerUtil::cleanUpVectorOfPointers(timelines); - setError("Invalid timeline type for a bone: ", skeletonData->_bones[boneIndex]->_name.c_str()); + setError("Invalid timeline type for a bone: ", skeletonData->_bones[boneIndex]->_name.buffer()); return NULL; } } @@ -1014,17 +999,14 @@ namespace Spine { int slotIndex = readVarint(input, true); for (int iii = 0, nnn = readVarint(input, true); iii < nnn; iii++) { const char* attachmentName = readString(input); - Attachment* baseAttachment = skin->getAttachment(slotIndex, std::string(attachmentName)); + Attachment* baseAttachment = skin->getAttachment(slotIndex, String(attachmentName, true)); if (!baseAttachment) { ContainerUtil::cleanUpVectorOfPointers(timelines); setError("Attachment not found: ", attachmentName); - SpineExtension::free(attachmentName, __FILE__, __LINE__); return NULL; } - SpineExtension::free(attachmentName, __FILE__, __LINE__); - VertexAttachment* attachment = static_cast(baseAttachment); bool weighted = attachment->_bones.size() > 0; @@ -1147,8 +1129,8 @@ namespace Spine { event->_intValue = readVarint(input, false); event->_floatValue = readFloat(input); bool freeString = readBoolean(input); - const char* event_stringValue = freeString ? readString(input) : eventData->_stringValue.c_str(); - event->_stringValue = std::string(event_stringValue); + const char* event_stringValue = freeString ? readString(input) : eventData->_stringValue.buffer(); + event->_stringValue = String(event_stringValue); if (freeString) { SpineExtension::free(event_stringValue, __FILE__, __LINE__); } @@ -1159,7 +1141,7 @@ namespace Spine { duration = MAX(duration, timeline->_frames[eventCount - 1]); } - return new (__FILE__, __LINE__) Animation(std::string(name), timelines, duration); + return new (__FILE__, __LINE__) Animation(String(name), timelines, duration); } void SkeletonBinary::readCurve(DataInput* input, int frameIndex, CurveTimeline* timeline) { diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp index 67159eac3..26b79026d 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp @@ -70,55 +70,55 @@ namespace Spine { ContainerUtil::cleanUpVectorOfPointers(_pathConstraints); } - BoneData* SkeletonData::findBone(std::string boneName) { + BoneData* SkeletonData::findBone(const String& boneName) { return ContainerUtil::findWithName(_bones, boneName); } - int SkeletonData::findBoneIndex(std::string boneName) { + int SkeletonData::findBoneIndex(const String& boneName) { return ContainerUtil::findIndexWithName(_bones, boneName); } - SlotData* SkeletonData::findSlot(std::string slotName) { + SlotData* SkeletonData::findSlot(const String& slotName) { return ContainerUtil::findWithName(_slots, slotName); } - int SkeletonData::findSlotIndex(std::string slotName) { + int SkeletonData::findSlotIndex(const String& slotName) { return ContainerUtil::findIndexWithName(_slots, slotName); } - Skin* SkeletonData::findSkin(std::string skinName) { + Skin* SkeletonData::findSkin(const String& skinName) { return ContainerUtil::findWithName(_skins, skinName); } - EventData* SkeletonData::findEvent(std::string eventDataName) { + EventData* SkeletonData::findEvent(const String& eventDataName) { return ContainerUtil::findWithName(_events, eventDataName); } - Animation* SkeletonData::findAnimation(std::string animationName) { + Animation* SkeletonData::findAnimation(const String& animationName) { return ContainerUtil::findWithName(_animations, animationName); } - IkConstraintData* SkeletonData::findIkConstraint(std::string constraintName) { + IkConstraintData* SkeletonData::findIkConstraint(const String& constraintName) { return ContainerUtil::findWithName(_ikConstraints, constraintName); } - TransformConstraintData* SkeletonData::findTransformConstraint(std::string constraintName) { + TransformConstraintData* SkeletonData::findTransformConstraint(const String& constraintName) { return ContainerUtil::findWithName(_transformConstraints, constraintName); } - PathConstraintData* SkeletonData::findPathConstraint(std::string constraintName) { + PathConstraintData* SkeletonData::findPathConstraint(const String& constraintName) { return ContainerUtil::findWithName(_pathConstraints, constraintName); } - int SkeletonData::findPathConstraintIndex(std::string pathConstraintName) { + int SkeletonData::findPathConstraintIndex(const String& pathConstraintName) { return ContainerUtil::findIndexWithName(_pathConstraints, pathConstraintName); } - std::string SkeletonData::getName() { + const String& SkeletonData::getName() { return _name; } - void SkeletonData::setName(std::string inValue) { + void SkeletonData::setName(const String& inValue) { _name = inValue; } @@ -202,27 +202,27 @@ namespace Spine { _height = inValue; } - std::string SkeletonData::getVersion() { + const String& SkeletonData::getVersion() { return _version; } - void SkeletonData::setVersion(std::string inValue) { + void SkeletonData::setVersion(const String& inValue) { _version = inValue; } - std::string SkeletonData::getHash() { + const String& SkeletonData::getHash() { return _hash; } - void SkeletonData::setHash(std::string inValue) { + void SkeletonData::setHash(const String& inValue) { _hash = inValue; } - std::string SkeletonData::getImagesPath() { + const String& SkeletonData::getImagesPath() { return _imagesPath; } - void SkeletonData::setImagesPath(std::string inValue) { + void SkeletonData::setImagesPath(const String& inValue) { _imagesPath = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp index 8d774d7c9..4c2457213 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp @@ -122,7 +122,7 @@ namespace Spine { SkeletonData* skeletonData; Json *root, *skeleton, *bones, *boneMap, *ik, *transform, *path, *slots, *skins, *animations, *events; - _error.clear(); + _error = ""; _linkedMeshes.clear(); root = new (__FILE__, __LINE__) Json(json); @@ -567,7 +567,7 @@ namespace Spine { } else { mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1); - LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, std::string(Json::getString(attachmentMap, "skin", 0)), slotIndex, std::string(entry->_valueString)); + LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(Json::getString(attachmentMap, "skin", 0)), slotIndex, String(entry->_valueString)); _linkedMeshes.push_back(linkedMesh); } break; @@ -640,13 +640,13 @@ namespace Spine { Skin* skin = linkedMesh->_skin.length() == 0 ? skeletonData->getDefaultSkin() : skeletonData->findSkin(linkedMesh->_skin); if (skin == NULL) { delete skeletonData; - setError(root, "Skin not found: ", linkedMesh->_skin.c_str()); + setError(root, "Skin not found: ", linkedMesh->_skin.buffer()); return NULL; } Attachment* parent = skin->getAttachment(linkedMesh->_slotIndex, linkedMesh->_parent); if (parent == NULL) { delete skeletonData; - setError(root, "Parent mesh not found: ", linkedMesh->_parent.c_str()); + setError(root, "Parent mesh not found: ", linkedMesh->_parent.buffer()); return NULL; } linkedMesh->_mesh->_parentMesh = static_cast(parent); @@ -661,12 +661,12 @@ namespace Spine { skeletonData->_events.reserve(events->_size); skeletonData->_events.setSize(events->_size); for (eventMap = events->_child, i = 0; eventMap; eventMap = eventMap->_next, ++i) { - EventData* eventData = new (__FILE__, __LINE__) EventData(std::string(eventMap->_name)); + EventData* eventData = new (__FILE__, __LINE__) EventData(String(eventMap->_name)); eventData->_intValue = Json::getInt(eventMap, "int", 0); eventData->_floatValue = Json::getFloat(eventMap, "float", 0); const char* stringValue = Json::getString(eventMap, "string", 0); - eventData->_stringValue = std::string(stringValue ? stringValue : ""); + eventData->_stringValue = stringValue; skeletonData->_events[i] = eventData; } } @@ -802,7 +802,7 @@ namespace Spine { for (valueMap = timelineMap->_child, frameIndex = 0; valueMap; valueMap = valueMap->_next, ++frameIndex) { Json* name = Json::getItem(valueMap, "name"); - std::string attachmentName = name->_type == Json::JSON_NULL ? std::string("") : std::string(name->_valueString); + String attachmentName = name->_type == Json::JSON_NULL ? "" : name->_valueString; timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), attachmentName); } timelines.push_back(timeline); @@ -1159,7 +1159,7 @@ namespace Spine { event = new (__FILE__, __LINE__) Event(Json::getFloat(valueMap, "time", 0), *eventData); event->_intValue = Json::getInt(valueMap, "int", eventData->_intValue); event->_floatValue = Json::getFloat(valueMap, "float", eventData->_floatValue); - event->_stringValue = Json::getString(valueMap, "string", eventData->_stringValue.c_str()); + event->_stringValue = Json::getString(valueMap, "string", eventData->_stringValue.buffer()); timeline->setFrame(frameIndex, event); } timelines.push_back(timeline); @@ -1167,7 +1167,7 @@ namespace Spine { duration = MAX(duration, timeline->_frames[events->_size - 1]); } - return new (__FILE__, __LINE__) Animation(std::string(root->_name), timelines, duration); + return new (__FILE__, __LINE__) Animation(String(root->_name), timelines, duration); } void SkeletonJson::readVertices(Json* attachmentMap, VertexAttachment* attachment, int verticesLength) { @@ -1224,7 +1224,7 @@ namespace Spine { strncat(message + length, value2, 255 - length); } - _error = std::string(message); + _error = String(message); if (root) { delete root; diff --git a/spine-cpp/spine-cpp/src/spine/Skin.cpp b/spine-cpp/spine-cpp/src/spine/Skin.cpp index ab18751be..7b51a5aaf 100644 --- a/spine-cpp/spine-cpp/src/spine/Skin.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skin.cpp @@ -38,7 +38,7 @@ #include namespace Spine { - Skin::AttachmentKey::AttachmentKey(int slotIndex, std::string name) : + Skin::AttachmentKey::AttachmentKey(int slotIndex, const String& name) : _slotIndex(slotIndex), _name(name) { // Empty @@ -54,7 +54,7 @@ namespace Spine { return h1; } - Skin::Skin(std::string name) : _name(name) { + Skin::Skin(const String& name) : _name(name) { assert(_name.length() > 0); } @@ -65,13 +65,13 @@ namespace Spine { } } - void Skin::addAttachment(int slotIndex, std::string name, Attachment* attachment) { + void Skin::addAttachment(int slotIndex, const String& name, Attachment* attachment) { assert(attachment); _attachments.insert(AttachmentKey(slotIndex, name), attachment); } - Attachment* Skin::getAttachment(int slotIndex, std::string name) { + Attachment* Skin::getAttachment(int slotIndex, const String& name) { HashMap::Iterator i = _attachments.find(AttachmentKey(slotIndex, name)); Attachment* ret = NULL; @@ -83,7 +83,7 @@ namespace Spine { return ret; } - void Skin::findNamesForSlot(int slotIndex, Vector& names) { + void Skin::findNamesForSlot(int slotIndex, Vector& names) { for (HashMap::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) { if (i.key()._slotIndex == slotIndex) { names.push_back(i.key()._name); @@ -98,8 +98,8 @@ namespace Spine { } } } - - const std::string& Skin::getName() { + + const String& Skin::getName() { return _name; } diff --git a/spine-cpp/spine-cpp/src/spine/Slot.cpp b/spine-cpp/spine-cpp/src/spine/Slot.cpp index 9ea7c7651..f27201398 100644 --- a/spine-cpp/spine-cpp/src/spine/Slot.cpp +++ b/spine-cpp/spine-cpp/src/spine/Slot.cpp @@ -59,7 +59,7 @@ namespace Spine { _b = _data.getB(); _a = _data.getA(); - std::string attachmentName = _data.getAttachmentName(); + const String& attachmentName = _data.getAttachmentName(); if (attachmentName.length() > 0) { _attachment = NULL; setAttachment(_skeleton.getAttachment(_data.getIndex(), attachmentName)); diff --git a/spine-cpp/spine-cpp/src/spine/SlotData.cpp b/spine-cpp/spine-cpp/src/spine/SlotData.cpp index e8d517905..029c3ae64 100644 --- a/spine-cpp/spine-cpp/src/spine/SlotData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SlotData.cpp @@ -33,7 +33,7 @@ #include namespace Spine { - SlotData::SlotData(int index, std::string name, BoneData& boneData) : + SlotData::SlotData(int index, const String& name, BoneData& boneData) : _index(index), _name(name), _boneData(boneData), @@ -56,7 +56,7 @@ namespace Spine { return _index; } - const std::string& SlotData::getName() { + const String& SlotData::getName() { return _name; } @@ -128,11 +128,11 @@ namespace Spine { _hasSecondColor = inValue; } - std::string SlotData::getAttachmentName() { + const String& SlotData::getAttachmentName() { return _attachmentName; } - void SlotData::setAttachmentName(std::string inValue) { + void SlotData::setAttachmentName(const String& inValue) { _attachmentName = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp index fb3f5be91..e69fc4c05 100644 --- a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp @@ -35,7 +35,7 @@ #include namespace Spine { - TransformConstraintData::TransformConstraintData(std::string name) : + TransformConstraintData::TransformConstraintData(const String& name) : _name(name), _order(0), _target(NULL), @@ -54,7 +54,7 @@ namespace Spine { assert(_name.length() > 0); } - const std::string& TransformConstraintData::getName() { + const String& TransformConstraintData::getName() { return _name; } diff --git a/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp b/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp index 879750098..c67c423aa 100644 --- a/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp @@ -38,7 +38,7 @@ namespace Spine { RTTI_IMPL(VertexAttachment, Attachment); - VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) { + VertexAttachment::VertexAttachment(const String& name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) { // Empty }