Browse Source

Take advantage of some custom formatter shortcuts

Michael Hansen 10 years ago
parent
commit
2048b641d3
  1. 5
      Sources/Plasma/CoreLib/plFileSystem.cpp
  2. 6
      Sources/Plasma/CoreLib/plFileSystem.h
  3. 3
      Sources/Plasma/CoreLib/plFormat.h
  4. 22
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp
  5. 6
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h
  6. 5
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp
  7. 4
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.h

5
Sources/Plasma/CoreLib/plFileSystem.cpp

@ -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)

6
Sources/Plasma/CoreLib/plFileSystem.h

@ -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
*/

3
Sources/Plasma/CoreLib/plFormat.h

@ -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)

22
Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp

@ -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());
}

6
Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h

@ -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

5
Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp

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

4
Sources/Plasma/NucleusLib/pnUUID/pnUUID.h

@ -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

Loading…
Cancel
Save