mirror of https://github.com/zeldaret/botw.git
Havok: Finish hkStringPtr
This commit is contained in:
parent
d7a6dbcf8a
commit
e2810855f1
|
@ -7,6 +7,7 @@ add_library(hkStubs OBJECT
|
|||
Havok/Common/Base/Container/Array/hkArray.h
|
||||
Havok/Common/Base/Container/Array/hkArrayUtil.h
|
||||
Havok/Common/Base/Container/Array/hkSmallArray.h
|
||||
Havok/Common/Base/Container/String/hkString.h
|
||||
Havok/Common/Base/Container/String/hkStringPtr.h
|
||||
|
||||
Havok/Common/Base/DebugUtil/MultiThreadCheck/hkMultiThreadCheck.h
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <Havok/Common/Base/Types/hkBaseDefs.h>
|
||||
#include <Havok/Common/Base/Types/hkBaseTypes.h>
|
||||
|
||||
namespace hkString {
|
||||
|
||||
int strCmp(const char* s1, const char* s2);
|
||||
hkBool beginsWith(const char* str, const char* prefix);
|
||||
hkBool endsWith(const char* str, const char* suffix);
|
||||
|
||||
} // namespace hkString
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <Havok/Common/Base/Container/String/hkString.h>
|
||||
#include <Havok/Common/Base/Memory/Router/hkMemoryRouter.h>
|
||||
|
||||
class hkStringPtr {
|
||||
|
@ -11,12 +12,32 @@ public:
|
|||
};
|
||||
|
||||
hkStringPtr();
|
||||
hkStringPtr(const char* string); // NOLINT(google-explicit-constructor)
|
||||
hkStringPtr(const char* string, int len);
|
||||
hkStringPtr(const hkStringPtr& strRef);
|
||||
explicit hkStringPtr(hkFinishLoadedObjectFlag f);
|
||||
|
||||
~hkStringPtr();
|
||||
|
||||
inline const char* cString() const;
|
||||
inline operator const char*() const;
|
||||
inline operator const char*() const; // NOLINT(google-explicit-constructor)
|
||||
|
||||
hkStringPtr& operator=(const char* s);
|
||||
hkStringPtr& operator=(const hkStringPtr& s);
|
||||
|
||||
int getLength() const;
|
||||
|
||||
inline char operator[](int idx) const;
|
||||
|
||||
void printf(const char* fmt, ...);
|
||||
void set(const char* s, int len = -1);
|
||||
void setPointerAligned(const char* s);
|
||||
|
||||
inline hkBool32 operator==(const char* s) const;
|
||||
inline hkBool32 operator!=(const char* s) const;
|
||||
inline hkBool32 startsWith(const char* s) const;
|
||||
inline hkBool32 endsWith(const char* s) const;
|
||||
inline int compareTo(const char* rhs) const;
|
||||
|
||||
private:
|
||||
const char* m_stringAndFlag;
|
||||
|
@ -29,3 +50,34 @@ inline const char* hkStringPtr::cString() const {
|
|||
inline hkStringPtr::operator const char*() const {
|
||||
return cString();
|
||||
}
|
||||
|
||||
inline char hkStringPtr::operator[](int idx) const {
|
||||
return cString()[idx];
|
||||
}
|
||||
|
||||
inline hkBool32 hkStringPtr::operator==(const char* s) const {
|
||||
return compareTo(s) == 0;
|
||||
}
|
||||
|
||||
inline hkBool32 hkStringPtr::operator!=(const char* s) const {
|
||||
return compareTo(s) != 0;
|
||||
}
|
||||
|
||||
inline hkBool32 hkStringPtr::startsWith(const char* s) const {
|
||||
return hkString::beginsWith(cString(), s);
|
||||
}
|
||||
|
||||
inline hkBool32 hkStringPtr::endsWith(const char* s) const {
|
||||
return hkString::endsWith(cString(), s);
|
||||
}
|
||||
|
||||
inline int hkStringPtr::compareTo(const char* rhs) const {
|
||||
const char* lhs = cString();
|
||||
if (lhs && rhs)
|
||||
return hkString::strCmp(lhs, rhs);
|
||||
if (lhs != nullptr)
|
||||
return 1;
|
||||
if (rhs != nullptr)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,9 @@ private:
|
|||
hkInt16 m_value;
|
||||
};
|
||||
|
||||
using hkBool32 = hkUint32;
|
||||
using hkBoolLL = hkUint64;
|
||||
|
||||
class hkBool {
|
||||
public:
|
||||
HK_ALWAYS_INLINE hkBool() = default;
|
||||
|
@ -82,6 +85,8 @@ public:
|
|||
HK_FORCE_INLINE constexpr hkBool(bool b) : m_bool(static_cast<char>(b)) {}
|
||||
|
||||
HK_FORCE_INLINE constexpr explicit operator bool() const { return m_bool != 0; }
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
HK_FORCE_INLINE constexpr operator hkBool32() const { return m_bool != 0; }
|
||||
|
||||
HK_FORCE_INLINE constexpr hkBool& operator=(bool e) {
|
||||
m_bool = static_cast<char>(e);
|
||||
|
@ -95,9 +100,6 @@ private:
|
|||
char m_bool;
|
||||
};
|
||||
|
||||
using hkBool32 = hkUint32;
|
||||
using hkBoolLL = hkUint64;
|
||||
|
||||
/// For storing an enum with a particular storage size when specifying the underlying type of the
|
||||
/// enum is not an option.
|
||||
template <typename Enum, typename Storage>
|
||||
|
|
Loading…
Reference in New Issue