1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Take advantage of some custom formatter shortcuts

This commit is contained in:
2014-05-15 23:17:32 -07:00
parent 3f92409a21
commit 2048b641d3
7 changed files with 43 additions and 8 deletions

View File

@ -199,6 +199,11 @@ plFileName plFileName::Join(const plFileName &base, const plFileName &path)
return base.fName + path.fName.Substr(1);
}
PL_FORMAT_IMPL(const plFileName &)
{
return PL_FORMAT_FORWARD(format, value.AsString());
}
/* plFileInfo */
plFileInfo::plFileInfo(const plFileName &filename)

View File

@ -47,6 +47,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cstdio>
#include <cstddef>
#include "plFormat.h"
#if HS_BUILD_FOR_WIN32
# define PATH_SEPARATOR '\\'
# define PATH_SEPARATOR_STR "\\"
@ -225,6 +227,10 @@ inline plFileName operator+(const char *left, const plFileName &right)
{ return left + right.AsString(); }
// Shortcut for use in plFormat
PL_FORMAT_TYPE(const plFileName &)
/** Structure to get information about a file by name.
* \sa plFileName
*/

View File

@ -144,6 +144,9 @@ namespace plFormat_Private
plStringBuffer<char> _impl_plFormat_DataHandler( \
const plFormat_Private::FormatSpec &format, _type value)
#define PL_FORMAT_FORWARD(format, fwd_value) \
_impl_plFormat_DataHandler((format), (fwd_value))
PL_FORMAT_TYPE(char)
PL_FORMAT_TYPE(wchar_t)
PL_FORMAT_TYPE(signed char)

View File

@ -114,7 +114,12 @@ bool plLocation::IsVirtual() const
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
plString plLocation::StringIze() const // Format to displayable string
{
return plString::Format("S0x%xF0x%x", fSequenceNumber, int(fFlags));
return plFormat("S0x{x}F0x{x}", fSequenceNumber, fFlags);
}
PL_FORMAT_IMPL(const plLocation &)
{
return PL_FORMAT_FORWARD(format, value.StringIze());
}
plLocation plLocation::MakeReserved(uint32_t number)
@ -261,10 +266,15 @@ plUoid& plUoid::operator=(const plUoid& rhs)
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
plString plUoid::StringIze() const // Format to displayable string
{
return plString::Format("(0x%x:0x%x:%s:C:[%u,%u])",
fLocation.GetSequenceNumber(),
int(fLocation.GetFlags()),
fObjectName.c_str(),
GetClonePlayerID(),
return plFormat("(0x{x}:0x{x}:{}:C:[{},{}])",
fLocation.GetSequenceNumber(),
fLocation.GetFlags(),
fObjectName,
GetClonePlayerID(),
GetCloneID());
}
PL_FORMAT_IMPL(const plUoid &)
{
return PL_FORMAT_FORWARD(format, value.StringIze());
}

View File

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plFixedKey.h"
#include "plLoadMask.h"
#include "plString.h"
#include "plFormat.h"
class hsStream;
@ -144,6 +144,8 @@ public:
static const plLocation kInvalidLoc;
};
PL_FORMAT_TYPE(const plLocation &)
//// plUoid //////////////////////////////////////////////////////////////////
class plUoid
@ -198,4 +200,6 @@ protected:
plLoadMask fLoadMask;
};
PL_FORMAT_TYPE(const plUoid &)
#endif // plUoid_h_inc

View File

@ -83,3 +83,8 @@ plString plUUID::AsString() const
ToString(str);
return str;
}
PL_FORMAT_IMPL(const plUUID &)
{
return PL_FORMAT_FORWARD(format, value.AsString());
}

View File

@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define pnUUID_h_inc
#include "HeadSpin.h"
#include "plString.h"
#include "plFormat.h"
class hsStream;
@ -96,4 +96,6 @@ public:
static plUUID Generate();
};
PL_FORMAT_TYPE(const plUUID &)
#endif // pnUUID_h_inc