OpenClonk
C4Property Class Reference

#include <C4PropList.h>

Collaboration diagram for C4Property:
[legend]

Public Member Functions

 C4Property ()=default
 
 C4Property (C4String *Key, const C4Value &Value)
 
 C4Property (const C4Property &o)
 
C4Propertyoperator= (const C4Property &o)
 
 C4Property (C4Property &&o)
 
C4Propertyoperator= (C4Property &&o)
 
 ~C4Property ()
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *)
 
 operator bool () const
 
bool operator< (const C4Property &cmp) const
 
const char * GetSafeKey () const
 

Public Attributes

C4StringKey {nullptr}
 
C4Value Value
 

Detailed Description

Definition at line 39 of file C4PropList.h.

Constructor & Destructor Documentation

◆ C4Property() [1/4]

C4Property::C4Property ( )
default

◆ C4Property() [2/4]

C4Property::C4Property ( C4String Key,
const C4Value Value 
)
inline

Definition at line 43 of file C4PropList.h.

43  : Key(Key), Value(Value)
44  { assert(Key); Key->IncRef(); }
C4Value Value
Definition: C4PropList.h:54
C4String * Key
Definition: C4PropList.h:53
void IncRef()
Definition: C4StringTable.h:27

References C4RefCnt::IncRef(), and Key.

Here is the call graph for this function:

◆ C4Property() [3/4]

C4Property::C4Property ( const C4Property o)
inline

Definition at line 45 of file C4PropList.h.

45 : Key(o.Key), Value(o.Value) { if (Key) Key->IncRef(); }

References C4RefCnt::IncRef(), and Key.

Here is the call graph for this function:

◆ C4Property() [4/4]

C4Property::C4Property ( C4Property &&  o)
inline

Definition at line 48 of file C4PropList.h.

48 : Key(o.Key), Value(std::move(o.Value)) { o.Key = nullptr; }

◆ ~C4Property()

C4Property::~C4Property ( )
inline

Definition at line 51 of file C4PropList.h.

51 { if (Key) Key->DecRef(); }
void DecRef()
Definition: C4StringTable.h:28

References C4RefCnt::DecRef(), and Key.

Here is the call graph for this function:

Member Function Documentation

◆ CompileFunc()

void C4Property::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers 
)

Definition at line 471 of file C4PropList.cpp.

472 {
473  StdStrBuf s;
474  if (!pComp->isDeserializer())
475  s = Key->GetData();
476  pComp->Value(s);
477  if (pComp->isDeserializer())
478  {
479  if (Key) Key->DecRef();
481  Key->IncRef();
482  }
484  pComp->Value(mkParAdapt(Value, numbers));
485 }
#define s
C4StringTable Strings
Definition: C4Globals.cpp:42
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdStrBuf GetData() const
Definition: C4StringTable.h:50
C4String * RegString(StdStrBuf String)
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

References C4RefCnt::DecRef(), C4String::GetData(), C4RefCnt::IncRef(), StdCompiler::isDeserializer(), Key, mkParAdapt(), C4StringTable::RegString(), s, StdCompiler::SEP_SET, StdCompiler::Separator(), Strings, StdCompiler::Value(), and Value.

Here is the call graph for this function:

◆ GetSafeKey()

const char* C4Property::GetSafeKey ( ) const
inline

Definition at line 57 of file C4PropList.h.

57 { if (Key && Key->GetCStr()) return Key->GetCStr(); return ""; } // get key as C string; return "" if undefined. never return nullptr
const char * GetCStr() const
Definition: C4StringTable.h:49

References C4String::GetCStr(), and Key.

Referenced by operator<().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator bool()

C4Property::operator bool ( ) const
inlineexplicit

Definition at line 55 of file C4PropList.h.

55 { return Key != nullptr; }

References Key.

◆ operator<()

bool C4Property::operator< ( const C4Property cmp) const
inline

Definition at line 56 of file C4PropList.h.

56 { return strcmp(GetSafeKey(), cmp.GetSafeKey())<0; }
const char * GetSafeKey() const
Definition: C4PropList.h:57

References GetSafeKey().

Here is the call graph for this function:

◆ operator=() [1/2]

C4Property& C4Property::operator= ( C4Property &&  o)
inline

Definition at line 49 of file C4PropList.h.

50  { if (Key) Key->DecRef(); Key = o.Key; o.Key = nullptr; Value = std::move(o.Value); return *this; }

References C4RefCnt::DecRef(), Key, and Value.

Here is the call graph for this function:

◆ operator=() [2/2]

C4Property& C4Property::operator= ( const C4Property o)
inline

Definition at line 46 of file C4PropList.h.

47  { if(o.Key) o.Key->IncRef(); if (Key) Key->DecRef(); Key = o.Key; Value = o.Value; return *this; }

References C4RefCnt::DecRef(), C4RefCnt::IncRef(), Key, and Value.

Here is the call graph for this function:

Member Data Documentation

◆ Key

◆ Value


The documentation for this class was generated from the following files: