Skip to content

Commit

Permalink
Minor refactor in experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Oct 17, 2015
1 parent 6c73c48 commit 2850af8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Pomdog {
namespace MagicaVoxel {
namespace {

static std::string Error(std::string const& assetName, char const* description)
static std::string Error(std::string const& assetName, std::string const& description)
{
return description + (": " + assetName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Pomdog {
namespace MagicaVoxel {
namespace {

static std::string Error(std::string const& assetName, char const* description)
static std::string Error(std::string const& assetName, std::string const& description)
{
return description + (": " + assetName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ namespace {
//}
//-----------------------------------------------------------------------
template <typename T>
static T GetMemberAs(rapidjson::Value const& object, char const* name)
static T GetMemberAs(rapidjson::Value const& object, std::string const& name)
{
POMDOG_ASSERT(object.HasMember(name));
POMDOG_ASSERT(!name.empty());
POMDOG_ASSERT(object.HasMember(name.c_str()));

auto const& value = object[name];
auto const& value = object[name.c_str()];
POMDOG_ASSERT(value.IsNumber());

if (value.IsInt()) {
Expand Down
4 changes: 2 additions & 2 deletions experimental/Pomdog.Experimental/Spine/AnimationLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static JointIndex FindJoint(std::vector<BoneDesc> const& bones, std::string cons

} // unnamed namespace
//-----------------------------------------------------------------------
AnimationClip CreateAnimationClip(SkeletonDesc const& desc, char const* name)
AnimationClip CreateAnimationClip(SkeletonDesc const& desc, std::string const& name)
{
auto iter = std::find_if(std::begin(desc.AnimationClips), std::end(desc.AnimationClips),
[name](AnimationClipDesc const& clip){ return clip.Name == name; });
[&name](AnimationClipDesc const& clip){ return clip.Name == name; });

POMDOG_ASSERT(std::end(desc.AnimationClips) != iter);

Expand Down
4 changes: 3 additions & 1 deletion experimental/Pomdog.Experimental/Spine/AnimationLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef POMDOG_ANIMATIONLOADER_F321C327_HPP
#define POMDOG_ANIMATIONLOADER_F321C327_HPP

#include <string>

namespace Pomdog {

class AnimationClip;
Expand All @@ -12,7 +14,7 @@ namespace Spine {

class SkeletonDesc;

AnimationClip CreateAnimationClip(SkeletonDesc const& desc, char const* name);
AnimationClip CreateAnimationClip(SkeletonDesc const& desc, std::string const& name);

} // namespace Spine
} // namespace Pomdog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace Spine {
std::vector<Detail::Skeletal2D::SpriteAnimationTrack> CreateSpriteAnimationTrack(
SkeletonDesc const& desc,
TexturePacker::TextureAtlas const& textureAtlas,
char const* name)
std::string const& name)
{
using namespace Detail::Skeletal2D;
using Detail::CRC32;

auto iter = std::find_if(std::begin(desc.AnimationClips), std::end(desc.AnimationClips),
[name](AnimationClipDesc const& clip){ return clip.Name == name; });
[&name](AnimationClipDesc const& clip){ return clip.Name == name; });

POMDOG_ASSERT(std::end(desc.AnimationClips) != iter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "Pomdog.Experimental/TexturePacker/TextureAtlas.hpp"
#include <vector>
#include <string>

namespace Pomdog {
namespace Detail {
Expand All @@ -22,7 +23,7 @@ class SkeletonDesc;
std::vector<Detail::Skeletal2D::SpriteAnimationTrack> CreateSpriteAnimationTrack(
SkeletonDesc const& desc,
TexturePacker::TextureAtlas const& textureAtlas,
char const* name);
std::string const& name);

} // namespace Spine
} // namespace Pomdog
Expand Down

0 comments on commit 2850af8

Please sign in to comment.