forked from Mirrors/openclonk
C4Property: Remove raw operator void*
operator void* is a quick and dirty workaround for the lack of explicit operator bool in old C++ standards. Since we can use explicit operator bool now, we don't need the operator void* anymore. Incidentally, that operator also allowed C4Set to equality compare C4Property entries, which is unintuitive. Replace it with an explicit specialization of C4Set::Equals.master
parent
31c7805f10
commit
0a81206b7e
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2009-2016, The OpenClonk Team and contributors
|
||||
* Copyright (c) 2009-2019, The OpenClonk Team and contributors
|
||||
*
|
||||
* Distributed under the terms of the ISC license; see accompanying file
|
||||
* "COPYING" for details.
|
||||
|
@ -53,10 +53,16 @@ public:
|
|||
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *);
|
||||
C4String * Key{nullptr};
|
||||
C4Value Value;
|
||||
operator const void * () const { return Key; }
|
||||
explicit operator bool() const { return Key != nullptr; }
|
||||
bool operator < (const C4Property &cmp) const { return strcmp(GetSafeKey(), cmp.GetSafeKey())<0; }
|
||||
const char *GetSafeKey() const { if (Key && Key->GetCStr()) return Key->GetCStr(); return ""; } // get key as C string; return "" if undefined. never return nullptr
|
||||
};
|
||||
|
||||
inline bool C4Set<C4Property>::Equals(const C4Property &a, const C4Property &b)
|
||||
{
|
||||
return a.Key == b.Key;
|
||||
}
|
||||
|
||||
class C4PropListNumbered;
|
||||
class C4PropList
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue