OpenClonk
C4MCParser Class Reference

#include <C4MapCreatorS2.h>

Public Member Functions

 C4MCParser (C4MapCreatorS2 *pMapCreator)
 
 ~C4MCParser ()
 
void Clear ()
 
void ParseFile (const char *szFilename, C4Group *pGrp)
 
void Parse (const char *szScript)
 
void ParseMemFile (const char *szScript, const char *szFilename)
 

Friends

class C4MCParserErr
 

Detailed Description

Definition at line 355 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

◆ C4MCParser()

C4MCParser::C4MCParser ( C4MapCreatorS2 pMapCreator)

Definition at line 930 of file C4MapCreatorS2.cpp.

931 {
932  // store map creator
933  MapCreator=pMapCreator;
934  // reset some fields
935  Code=nullptr; BPos = nullptr; CPos=nullptr; *Filename=0;
936 }

◆ ~C4MCParser()

C4MCParser::~C4MCParser ( )

Definition at line 938 of file C4MapCreatorS2.cpp.

939 {
940  // clean up
941  Clear();
942 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4MCParser::Clear ( )

Definition at line 944 of file C4MapCreatorS2.cpp.

945 {
946  // clear code if present
947  delete [] Code; Code=nullptr; BPos = nullptr; CPos=nullptr;
948  // reset filename
949  *Filename=0;
950 }

Referenced by Parse(), ParseFile(), ParseMemFile(), and ~C4MCParser().

Here is the caller graph for this function:

◆ Parse()

void C4MCParser::Parse ( const char *  szScript)

Definition at line 1482 of file C4MapCreatorS2.cpp.

1483 {
1484  // clear any old data
1485  Clear();
1486  // parse it
1487  BPos=szScript;
1488  CPos=szScript;
1489  ParseTo(MapCreator);
1490  if (false) PrintNodeTree(MapCreator, 0);
1491  // free code
1492  // on errors, this will be done be destructor
1493  Clear();
1494 
1495 }

References Clear().

Here is the call graph for this function:

◆ ParseFile()

void C4MCParser::ParseFile ( const char *  szFilename,
C4Group pGrp 
)

Definition at line 1451 of file C4MapCreatorS2.cpp.

1452 {
1453  size_t iSize; // file size
1454 
1455  // clear any old data
1456  Clear();
1457  // store filename
1458  SCopy(szFilename, Filename, C4MaxName);
1459  // check group
1460  if (!pGrp) throw C4MCParserErr(this, C4MCErr_NoGroup);
1461  // get file
1462  if (!pGrp->AccessEntry(szFilename, &iSize))
1463  // 404
1464  throw C4MCParserErr(this, C4MCErr_404);
1465  // file is empty?
1466  if (!iSize) return;
1467  // alloc mem
1468  Code = new char[iSize+1];
1469  // read file
1470  pGrp->Read((void *) Code, iSize);
1471  Code[iSize]=0;
1472  // parse it
1473  BPos=Code;
1474  CPos=Code;
1475  ParseTo(MapCreator);
1476  if (false) PrintNodeTree(MapCreator, 0);
1477  // free code
1478  // on errors, this will be done be destructor
1479  Clear();
1480 }
const unsigned int C4MaxName
#define C4MCErr_NoGroup
#define C4MCErr_404
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
int iSize
Definition: TstC4NetIO.cpp:32
bool Read(void *buffer, size_t size) override
Definition: C4Group.cpp:1430
bool AccessEntry(const char *wildcard, size_t *size=nullptr, char *filename=nullptr, bool needs_to_be_a_group=false)
Definition: C4Group.cpp:2104
friend class C4MCParserErr

References C4Group::AccessEntry(), C4MaxName, C4MCErr_404, C4MCErr_NoGroup, C4MCParserErr, Clear(), iSize, C4Group::Read(), and SCopy().

Here is the call graph for this function:

◆ ParseMemFile()

void C4MCParser::ParseMemFile ( const char *  szScript,
const char *  szFilename 
)

Definition at line 1497 of file C4MapCreatorS2.cpp.

1498 {
1499  // clear any old data
1500  Clear();
1501  // store filename
1502  SCopy(szFilename, Filename, C4MaxName);
1503  // parse it
1504  BPos=szScript;
1505  CPos=szScript;
1506  ParseTo(MapCreator);
1507  // on errors, this will be done be destructor
1508  Clear();
1509 }

References C4MaxName, Clear(), and SCopy().

Referenced by c4_mapgen_handle_new().

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

Friends And Related Function Documentation

◆ C4MCParserErr

friend class C4MCParserErr
friend

Definition at line 382 of file C4MapCreatorS2.h.

Referenced by ParseFile().


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