From 3fbba9f3e248c32d02430cde6ab5c6699c414d92 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Wed, 16 Nov 2016 14:48:48 +0200 Subject: [PATCH] Adjust the Object entity methods to use the new method of receiving formatted strings. --- source/Entity/Object.cpp | 19 +++++++++++++++++-- source/Entity/Object.hpp | 7 ++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source/Entity/Object.cpp b/source/Entity/Object.cpp index b8873a0b..5a34dd72 100644 --- a/source/Entity/Object.cpp +++ b/source/Entity/Object.cpp @@ -64,9 +64,23 @@ const String & CObject::GetTag() const } // ------------------------------------------------------------------------------------------------ -void CObject::SetTag(CSStr tag) +void CObject::SetTag(const StackStrF & tag) { - m_Tag.assign(tag); + if (tag.mLen > 0) + { + m_Tag.assign(tag.mPtr, tag.mLen); + } + else + { + m_Tag.clear(); + } +} + +// ------------------------------------------------------------------------------------------------ +CObject & CObject::ApplyTag(StackStrF & tag) +{ + SetTag(tag); + return *this; } // ------------------------------------------------------------------------------------------------ @@ -888,6 +902,7 @@ void Register_CObject(HSQUIRRELVM vm) .Prop(_SC("Active"), &CObject::IsActive) // Core Methods .Func(_SC("Bind"), &CObject::BindEvent) + .FmtFunc(_SC("SetTag"), &CObject::ApplyTag) .Func(_SC("CustomEvent"), &CObject::CustomEvent) // Core Overloads .Overload< bool (CObject::*)(void) >(_SC("Destroy"), &CObject::Destroy) diff --git a/source/Entity/Object.hpp b/source/Entity/Object.hpp index bba32bae..81ce1c9f 100644 --- a/source/Entity/Object.hpp +++ b/source/Entity/Object.hpp @@ -156,7 +156,12 @@ public: /* -------------------------------------------------------------------------------------------- * Modify the associated user tag. */ - void SetTag(CSStr tag); + void SetTag(const StackStrF & tag); + + /* -------------------------------------------------------------------------------------------- + * Modify the associated user tag. + */ + CObject & ApplyTag(StackStrF & tag); /* -------------------------------------------------------------------------------------------- * Retrieve the associated user data.