OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MCNode Class Reference

#include <C4MapCreatorS2.h>

Inheritance diagram for C4MCNode:
[legend]
Collaboration diagram for C4MCNode:
[legend]

Classes

class  int_bool
 

Public Member Functions

 C4MCNode (C4MCNode *pOwner=nullptr)
 
 C4MCNode (C4MCParser *pParser, C4MCNode *pOwner, C4MCNode &rTemplate, bool fClone)
 
virtual ~C4MCNode ()
 
virtual C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode)
 
void Clear ()
 
void Reg2Owner (C4MCNode *pOwner)
 
virtual C4MCNodeType Type ()
 
virtual C4MCOverlayOverlay ()
 
C4MCOverlayOwnerOverlay ()
 

Public Attributes

C4MCNodeOwner
 
C4MCNodeChild0
 
C4MCNodeChildL
 
C4MCNodePrev
 
C4MCNodeNext
 
C4MapCreatorS2MapCreator
 
char Name [C4MaxName]
 

Protected Member Functions

virtual bool GlobalScope ()
 
virtual bool SetOp (C4MCTokenType eOp)
 
C4MCNodeGetNodeByName (const char *szName)
 
virtual bool SetField (C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
int32_t IntPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
const char * StrPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
virtual void Evaluate ()
 
void ReEvaluate ()
 

Friends

class C4MCParser
 

Detailed Description

Definition at line 144 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

C4MCNode::C4MCNode ( C4MCNode pOwner = nullptr)

Definition at line 184 of file C4MapCreatorS2.cpp.

References Name, and Reg2Owner().

Referenced by clone().

185 {
186  // reg to owner
187  Reg2Owner(pOwner);
188  // no name
189  *Name=0;
190 }
char Name[C4MaxName]
void Reg2Owner(C4MCNode *pOwner)

Here is the call graph for this function:

Here is the caller graph for this function:

C4MCNode::C4MCNode ( C4MCParser pParser,
C4MCNode pOwner,
C4MCNode rTemplate,
bool  fClone 
)

Definition at line 192 of file C4MapCreatorS2.cpp.

References C4MCErr_NoRecTemplate, Child0, Name, Next, Owner, and Reg2Owner().

193 {
194  // Make sure the template is not used recursively within itself
195  for(C4MCNode* pParent = pOwner; pParent != nullptr; pParent = pParent->Owner)
196  if(pParent == &rTemplate)
197  throw C4MCParserErr(pParser, C4MCErr_NoRecTemplate, rTemplate.Name);
198  // set owner and stuff
199  Reg2Owner(pOwner);
200  // copy children from template
201  for (C4MCNode *pChild=rTemplate.Child0; pChild; pChild=pChild->Next)
202  pChild->clone(pParser, this);
203  // no name
204  *Name=0;
205 }
char Name[C4MaxName]
C4MCNode * Child0
C4MCNode * Owner
void Reg2Owner(C4MCNode *pOwner)
C4MCNode * Next
#define C4MCErr_NoRecTemplate

Here is the call graph for this function:

C4MCNode::~C4MCNode ( )
virtual

Definition at line 207 of file C4MapCreatorS2.cpp.

References Child0, ChildL, Clear(), Next, Owner, and Prev.

208 {
209  // clear
210  Clear();
211  // remove from list
212  if (Prev) Prev->Next = Next; else if (Owner) Owner->Child0 = Next;
213  if (Next) Next->Prev = Prev; else if (Owner) Owner->ChildL = Prev;
214 }
C4MCNode * Child0
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Next
C4MCNode * Prev

Here is the call graph for this function:

Member Function Documentation

void C4MCNode::Clear ( )

Definition at line 240 of file C4MapCreatorS2.cpp.

References Child0.

Referenced by C4MapCreatorS2::Clear(), and ~C4MCNode().

241 {
242  // delete all children; they'll unreg themselves
243  while (Child0) delete Child0;
244 }
C4MCNode * Child0

Here is the caller graph for this function:

virtual C4MCNode* C4MCNode::clone ( C4MCParser pParser,
C4MCNode pToNode 
)
inlinevirtual

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 156 of file C4MapCreatorS2.h.

References C4MCNode().

156 { return new C4MCNode(pParser, pToNode, *this, true); }
C4MCNode(C4MCNode *pOwner=nullptr)

Here is the call graph for this function:

virtual void C4MCNode::Evaluate ( )
inlineprotectedvirtual

Reimplemented in C4MCPoint, and C4MCOverlay.

Definition at line 170 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay::Evaluate(), C4MCPoint::Evaluate(), and ReEvaluate().

170 { } // called when all fields are initialized

Here is the caller graph for this function:

C4MCNode * C4MCNode::GetNodeByName ( const char *  szName)
protected

Definition at line 255 of file C4MapCreatorS2.cpp.

References ChildL, GetNodeByName(), Owner, Prev, and SEqual().

Referenced by C4MapCreatorS2::GetMap(), and GetNodeByName().

256 {
257  // search local list (backwards: last node has highest priority)
258  for (C4MCNode *pChild=ChildL; pChild; pChild=pChild->Prev)
259  // name match?
260  if (SEqual(pChild->Name, szName))
261  // yeah, success!
262  return pChild;
263  // search owner, if present
264  if (Owner) return Owner->GetNodeByName(szName);
265  // nothing found
266  return nullptr;
267 }
C4MCNode * GetNodeByName(const char *szName)
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Prev

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4MCNode::GlobalScope ( )
inlineprotectedvirtual

Reimplemented in C4MapCreatorS2.

Definition at line 162 of file C4MapCreatorS2.h.

162 { return false; } // whether node is a global scope
int32_t C4MCNode::IntPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protected

Definition at line 275 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

Referenced by C4MCOverlay::SetField(), and C4MCPoint::SetField().

276 {
277  // check if int32_t
278  if (ValType == MCT_INT || ValType == MCT_PERCENT || ValType == MCT_PX)
279  return iVal;
280  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
281 }
#define C4MCErr_FieldValInvalid

Here is the caller graph for this function:

virtual C4MCOverlay* C4MCNode::Overlay ( )
inlinevirtual

Reimplemented in C4MCOverlay.

Definition at line 187 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay::FirstOfChain(), and C4MCOverlay::PeekPix().

187 { return nullptr; } // return overlay, if this is one

Here is the caller graph for this function:

C4MCOverlay * C4MCNode::OwnerOverlay ( )

Definition at line 246 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Overlay(), and Owner.

Referenced by C4MCOverlay::Evaluate(), C4MCPoint::Evaluate(), and PreparePeek().

247 {
248  for (C4MCNode *pOwnr=Owner; pOwnr; pOwnr=pOwnr->Owner)
249  if (C4MCOverlay *pOwnrOvrl=pOwnr->Overlay())
250  return pOwnrOvrl;
251  // no overlay-owner
252  return nullptr;
253 }
C4MCOverlay * Overlay() override
C4MCNode * Owner

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::ReEvaluate ( )
protected

Definition at line 294 of file C4MapCreatorS2.cpp.

References Child0, Evaluate(), and Next.

Referenced by C4MCMap::SetSize().

295 {
296  // evaluate ourselves
297  Evaluate();
298  // evaluate children
299  for (C4MCNode *pChild=Child0; pChild; pChild=pChild->Next)
300  pChild->ReEvaluate();
301 }
virtual void Evaluate()
C4MCNode * Child0
C4MCNode * Next

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::Reg2Owner ( C4MCNode pOwner)

Definition at line 216 of file C4MapCreatorS2.cpp.

References Child0, ChildL, MapCreator, Next, Owner, and Prev.

Referenced by C4MCNode().

217 {
218  // init list
219  Child0=ChildL=nullptr;
220  // owner?
221  if ((Owner=pOwner))
222  {
223  // link into it
224  if ((Prev = Owner->ChildL))
225  Prev->Next = this;
226  else
227  Owner->Child0 = this;
228  Owner->ChildL = this;
229  MapCreator=pOwner->MapCreator;
230  }
231  else
232  {
233  Prev=nullptr;
234  MapCreator=nullptr;
235  }
236  // we're always last entry
237  Next=nullptr;
238 }
C4MCNode * Child0
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Next
C4MCNode * Prev
C4MapCreatorS2 * MapCreator

Here is the caller graph for this function:

bool C4MCNode::SetField ( C4MCParser pParser,
const char *  szField,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedvirtual

Reimplemented in C4MCPoint, and C4MCOverlay.

Definition at line 269 of file C4MapCreatorS2.cpp.

Referenced by C4MCOverlay::SetField().

270 {
271  // no fields in base class
272  return false;
273 }

Here is the caller graph for this function:

virtual bool C4MCNode::SetOp ( C4MCTokenType  eOp)
inlineprotectedvirtual

Reimplemented in C4MCOverlay.

Definition at line 163 of file C4MapCreatorS2.h.

163 { return false; } // set following operator
const char * C4MCNode::StrPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protected

Definition at line 283 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

284 {
285  // check if identifier
286  if (ValType != MCT_IDTF)
287  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
288  return szSVal;
289 }
#define C4MCErr_FieldValInvalid

Here is the caller graph for this function:

virtual C4MCNodeType C4MCNode::Type ( )
inlinevirtual

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 186 of file C4MapCreatorS2.h.

References MCN_Node.

Referenced by AlgoPolygon(), and C4MapCreatorS2::GetMap().

186 { return MCN_Node; } // get node type

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4MCParser
friend

Definition at line 190 of file C4MapCreatorS2.h.

Member Data Documentation

C4MCNode * C4MCNode::Child0
C4MCNode * C4MCNode::ChildL

Definition at line 147 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2::GetMap(), GetNodeByName(), Reg2Owner(), and ~C4MCNode().

char C4MCNode::Name[C4MaxName]

Definition at line 149 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), and C4MCNode().

C4MCNode * C4MCNode::Next

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