OpenClonk
C4NameList Class Reference

#include <C4NameList.h>

Public Member Functions

void Clear ()
 
bool Add (const char *szName, int32_t iCount=0)
 
bool Set (const char *szName, int32_t iCount)
 
bool IsEmpty ()
 
bool operator== (const C4NameList &rhs)
 
void CompileFunc (StdCompiler *pComp, bool fValues=true)
 

Public Attributes

char Name [C4MaxNameList][C4MaxName+1] = { { 0 } }
 
int32_t Count [C4MaxNameList] = { 0 }
 

Detailed Description

Definition at line 28 of file C4NameList.h.

Member Function Documentation

◆ Add()

bool C4NameList::Add ( const char *  szName,
int32_t  iCount = 0 
)

Definition at line 50 of file C4NameList.cpp.

51 {
52  // Find empty spot, set name and count
53  for (int32_t cnt=0; cnt<C4MaxNameList; cnt++)
54  if (!Name[cnt][0])
55  {
56  SCopy(szName,Name[cnt],C4MaxName);
57  Count[cnt]=iCount;
58  return true;
59  }
60  // No empty spots
61  return false;
62 }
const unsigned int C4MaxName
const int C4MaxNameList
Definition: C4NameList.h:23
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
char Name[C4MaxNameList][C4MaxName+1]
Definition: C4NameList.h:31
int32_t Count[C4MaxNameList]
Definition: C4NameList.h:32

References C4MaxName, C4MaxNameList, Count, Name, and SCopy().

Here is the call graph for this function:

◆ Clear()

void C4NameList::Clear ( )

Definition at line 23 of file C4NameList.cpp.

24 {
25  InplaceReconstruct(this);
26 }
std::enable_if< std::is_nothrow_default_constructible< T >::value >::type InplaceReconstruct(T *obj)
Definition: Standard.h:35

References InplaceReconstruct().

Referenced by C4SLandscape::Default().

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

◆ CompileFunc()

void C4NameList::CompileFunc ( StdCompiler pComp,
bool  fValues = true 
)

Definition at line 72 of file C4NameList.cpp.

73 {
74  bool deserializing = pComp->isDeserializer();
75  for (int32_t cnt=0; cnt<C4MaxNameList; cnt++)
76  if (deserializing || Name[cnt][0])
77  {
78  if (cnt) pComp->Separator(StdCompiler::SEP_SEP2);
79  // Name
81  // Value
82  if (fValues)
83  {
85  pComp->Value(mkDefaultAdapt(Count[cnt], 0));
86  }
87  }
88 }
StdStringAdapt mkStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
Definition: StdAdaptors.h:187
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:64
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 C4MaxName, C4MaxNameList, Count, StdCompiler::isDeserializer(), mkDefaultAdapt(), mkStringAdapt(), Name, StdCompiler::RCT_Idtf, StdCompiler::SEP_SEP2, StdCompiler::SEP_SET, StdCompiler::Separator(), and StdCompiler::Value().

Here is the call graph for this function:

◆ IsEmpty()

bool C4NameList::IsEmpty ( )

Definition at line 64 of file C4NameList.cpp.

65 {
66  for (auto & cnt : Name)
67  if (cnt[0])
68  return false;
69  return true;
70 }

References Name.

◆ operator==()

bool C4NameList::operator== ( const C4NameList rhs)
inline

Definition at line 39 of file C4NameList.h.

40  { return !std::memcmp((const uint8_t*)this,(const uint8_t*)&rhs,sizeof(C4NameList)); }

◆ Set()

bool C4NameList::Set ( const char *  szName,
int32_t  iCount 
)

Definition at line 28 of file C4NameList.cpp.

29 {
30  int32_t cnt;
31  // Find existing name, set count
32  for (cnt=0; cnt<C4MaxNameList; cnt++)
33  if (SEqual(Name[cnt],szName))
34  {
35  Count[cnt]=iCount;
36  return true;
37  }
38  // Find empty spot, set name and count
39  for (cnt=0; cnt<C4MaxNameList; cnt++)
40  if (Name[cnt][0]==0)
41  {
42  SCopy(szName,Name[cnt],C4MaxName);
43  Count[cnt]=iCount;
44  return true;
45  }
46  // No empty spots
47  return false;
48 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93

References C4MaxName, C4MaxNameList, Count, Name, SCopy(), and SEqual().

Here is the call graph for this function:

Member Data Documentation

◆ Count

int32_t C4NameList::Count[C4MaxNameList] = { 0 }

Definition at line 32 of file C4NameList.h.

Referenced by Add(), CompileFunc(), C4MapCreator::Create(), and Set().

◆ Name

char C4NameList::Name[C4MaxNameList][C4MaxName+1] = { { 0 } }

Definition at line 31 of file C4NameList.h.

Referenced by Add(), CompileFunc(), C4MapCreator::Create(), IsEmpty(), and Set().


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