Ndk/EntityHandle: Add ToString() method

Former-commit-id: b99c515e893c6363f030ffdd18925e92870e9361
This commit is contained in:
Lynix 2015-09-14 22:41:55 +02:00
parent 6fa143d7a8
commit ea66d01246
2 changed files with 18 additions and 1 deletions

View File

@ -33,6 +33,8 @@ namespace Ndk
EntityHandle& Swap(EntityHandle& handle);
NzString ToString() const;
operator bool() const;
operator Entity*() const;
Entity* operator->() const;

View File

@ -2,6 +2,7 @@
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <Nazara/Core/StringStream.hpp>
#include <functional>
#include <limits>
@ -89,6 +90,20 @@ namespace Ndk
return *this;
}
inline NzString EntityHandle::ToString() const
{
NzStringStream ss;
ss << "EntityHandle(";
if (IsValid())
ss << "Entity(" << m_entity->GetId() << ')';
else
ss << "Null entity";
ss << ')';
return ss;
}
inline EntityHandle::operator bool() const
{
return IsValid();
@ -143,7 +158,7 @@ namespace Ndk
{
out << "EntityHandle(";
if (handle.IsValid())
out << "Entity(" << handle->GetId() << ")";
out << "Entity(" << handle->GetId() << ')';
else
out << "Null entity";