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 const void * () const
 
C4Propertyoperator= (void *p)
 
bool operator< (const C4Property &cmp) const
 
const char * GetSafeKey () const
 

Public Attributes

C4StringKey {nullptr}
 
C4Value Value
 

Detailed Description

Definition at line 40 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 44 of file C4PropList.h.

References C4RefCnt::IncRef().

44  : Key(Key), Value(Value)
45  { assert(Key); Key->IncRef(); }
C4Value Value
Definition: C4PropList.h:55
void IncRef()
Definition: C4StringTable.h:27
C4String * Key
Definition: C4PropList.h:54
Here is the call graph for this function:

◆ C4Property() [3/4]

C4Property::C4Property ( const C4Property o)
inline

Definition at line 46 of file C4PropList.h.

References C4RefCnt::IncRef(), and Key.

46 : Key(o.Key), Value(o.Value) { if (Key) Key->IncRef(); }
C4Value Value
Definition: C4PropList.h:55
void IncRef()
Definition: C4StringTable.h:27
C4String * Key
Definition: C4PropList.h:54
Here is the call graph for this function:

◆ C4Property() [4/4]

C4Property::C4Property ( C4Property &&  o)
inline

Definition at line 49 of file C4PropList.h.

49 : Key(o.Key), Value(std::move(o.Value)) { o.Key = nullptr; }
C4Value Value
Definition: C4PropList.h:55
C4String * Key
Definition: C4PropList.h:54

◆ ~C4Property()

C4Property::~C4Property ( )
inline

Definition at line 52 of file C4PropList.h.

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

52 { if (Key) Key->DecRef(); }
C4String * Key
Definition: C4PropList.h:54
void DecRef()
Definition: C4StringTable.h:28
Here is the call graph for this function:

Member Function Documentation

◆ CompileFunc()

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

Definition at line 502 of file C4PropList.cpp.

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

Referenced by C4PropList::IsFrozen(), and ~C4Property().

503 {
504  StdStrBuf s;
505  if (!pComp->isDeserializer())
506  s = Key->GetData();
507  pComp->Value(s);
508  if (pComp->isDeserializer())
509  {
510  if (Key) Key->DecRef();
511  Key = ::Strings.RegString(s);
512  Key->IncRef();
513  }
515  pComp->Value(mkParAdapt(Value, numbers));
516 }
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
C4Value Value
Definition: C4PropList.h:55
void IncRef()
Definition: C4StringTable.h:27
StdStrBuf GetData() const
Definition: C4StringTable.h:50
C4String * RegString(StdStrBuf String)
C4StringTable Strings
Definition: C4Globals.cpp:42
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
C4String * Key
Definition: C4PropList.h:54
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:476
void DecRef()
Definition: C4StringTable.h:28
#define s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSafeKey()

const char* C4Property::GetSafeKey ( ) const
inline

Definition at line 60 of file C4PropList.h.

References C4String::GetCStr(), and Key.

Referenced by operator<().

60 { 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
C4String * Key
Definition: C4PropList.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator const void *()

C4Property::operator const void * ( ) const
inline

Definition at line 56 of file C4PropList.h.

References Key.

56 { return Key; }
C4String * Key
Definition: C4PropList.h:54

◆ operator<()

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

Definition at line 59 of file C4PropList.h.

References GetSafeKey().

59 { return strcmp(GetSafeKey(), cmp.GetSafeKey())<0; }
const char * GetSafeKey() const
Definition: C4PropList.h:60
Here is the call graph for this function:

◆ operator=() [1/3]

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

Definition at line 47 of file C4PropList.h.

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

48  { if(o.Key) o.Key->IncRef(); if (Key) Key->DecRef(); Key = o.Key; Value = o.Value; return *this; }
C4Value Value
Definition: C4PropList.h:55
void IncRef()
Definition: C4StringTable.h:27
C4String * Key
Definition: C4PropList.h:54
void DecRef()
Definition: C4StringTable.h:28
Here is the call graph for this function:

◆ operator=() [2/3]

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

Definition at line 50 of file C4PropList.h.

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

51  { if (Key) Key->DecRef(); Key = o.Key; o.Key = nullptr; Value = std::move(o.Value); return *this; }
C4Value Value
Definition: C4PropList.h:55
C4String * Key
Definition: C4PropList.h:54
void DecRef()
Definition: C4StringTable.h:28
Here is the call graph for this function:

◆ operator=() [3/3]

C4Property& C4Property::operator= ( void *  p)
inline

Definition at line 57 of file C4PropList.h.

References C4RefCnt::DecRef(), Key, and C4Value::Set0().

58  { assert(!p); if (Key) Key->DecRef(); Key = nullptr; Value.Set0(); return *this; }
C4Value Value
Definition: C4PropList.h:55
void Set0()
Definition: C4Value.h:336
C4String * Key
Definition: C4PropList.h:54
void DecRef()
Definition: C4StringTable.h:28
Here is the call graph for this function:

Member Data Documentation

◆ Key

◆ Value


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