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 183 of file C4MapCreatorS2.cpp.

References Name, and Reg2Owner().

Referenced by clone().

184 {
185  // reg to owner
186  Reg2Owner(pOwner);
187  // no name
188  *Name=0;
189 }
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 191 of file C4MapCreatorS2.cpp.

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

192 {
193  // Make sure the template is not used recursively within itself
194  for(C4MCNode* pParent = pOwner; pParent != nullptr; pParent = pParent->Owner)
195  if(pParent == &rTemplate)
196  throw C4MCParserErr(pParser, C4MCErr_NoRecTemplate, rTemplate.Name);
197  // set owner and stuff
198  Reg2Owner(pOwner);
199  // copy children from template
200  for (C4MCNode *pChild=rTemplate.Child0; pChild; pChild=pChild->Next)
201  pChild->clone(pParser, this);
202  // no name
203  *Name=0;
204 }
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 206 of file C4MapCreatorS2.cpp.

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

207 {
208  // clear
209  Clear();
210  // remove from list
211  if (Prev) Prev->Next = Next; else if (Owner) Owner->Child0 = Next;
212  if (Next) Next->Prev = Prev; else if (Owner) Owner->ChildL = Prev;
213 }
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 239 of file C4MapCreatorS2.cpp.

References Child0.

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

240 {
241  // delete all children; they'll unreg themselves
242  while (Child0) delete Child0;
243 }
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 254 of file C4MapCreatorS2.cpp.

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

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

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

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

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

275 {
276  // check if int32_t
277  if (ValType == MCT_INT || ValType == MCT_PERCENT || ValType == MCT_PX)
278  return iVal;
279  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
280 }
#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 245 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Overlay(), and Owner.

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

246 {
247  for (C4MCNode *pOwnr=Owner; pOwnr; pOwnr=pOwnr->Owner)
248  if (C4MCOverlay *pOwnrOvrl=pOwnr->Overlay())
249  return pOwnrOvrl;
250  // no overlay-owner
251  return nullptr;
252 }
C4MCOverlay * Overlay()
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 293 of file C4MapCreatorS2.cpp.

References Child0, Evaluate(), and Next.

Referenced by C4MCMap::SetSize().

294 {
295  // evaluate ourselves
296  Evaluate();
297  // evaluate children
298  for (C4MCNode *pChild=Child0; pChild; pChild=pChild->Next)
299  pChild->ReEvaluate();
300 }
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 215 of file C4MapCreatorS2.cpp.

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

Referenced by C4MCNode().

216 {
217  // init list
218  Child0=ChildL=nullptr;
219  // owner?
220  if ((Owner=pOwner))
221  {
222  // link into it
223  if ((Prev = Owner->ChildL))
224  Prev->Next = this;
225  else
226  Owner->Child0 = this;
227  Owner->ChildL = this;
228  MapCreator=pOwner->MapCreator;
229  }
230  else
231  {
232  Prev=nullptr;
233  MapCreator=nullptr;
234  }
235  // we're always last entry
236  Next=nullptr;
237 }
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 268 of file C4MapCreatorS2.cpp.

Referenced by C4MCOverlay::SetField().

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

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 282 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

283 {
284  // check if identifier
285  if (ValType != MCT_IDTF)
286  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
287  return szSVal;
288 }
#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: