OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 ( C4MapCreatorS2 pMapCreator)

Definition at line 929 of file C4MapCreatorS2.cpp.

930 {
931  // store map creator
932  MapCreator=pMapCreator;
933  // reset some fields
934  Code=nullptr; BPos = nullptr; CPos=nullptr; *Filename=0;
935 }
C4MCParser::~C4MCParser ( )

Definition at line 937 of file C4MapCreatorS2.cpp.

References Clear().

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

Here is the call graph for this function:

Member Function Documentation

void C4MCParser::Clear ( )

Definition at line 943 of file C4MapCreatorS2.cpp.

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

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

Here is the caller graph for this function:

void C4MCParser::Parse ( const char *  szScript)

Definition at line 1481 of file C4MapCreatorS2.cpp.

References Clear().

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

Here is the call graph for this function:

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

Definition at line 1450 of file C4MapCreatorS2.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 1496 of file C4MapCreatorS2.cpp.

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

Referenced by c4_mapgen_handle_new().

1497 {
1498  // clear any old data
1499  Clear();
1500  // store filename
1501  SCopy(szFilename, Filename, C4MaxName);
1502  // parse it
1503  BPos=szScript;
1504  CPos=szScript;
1505  ParseTo(MapCreator);
1506  // on errors, this will be done be destructor
1507  Clear();
1508 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
const unsigned int C4MaxName

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

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: