MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
module-namespace.cc File Reference
#include "mbconfig.h"
#include "mathp.h"
#include "parser.h"
#include "dataman.h"
Include dependency graph for module-namespace.cc:

Go to the source code of this file.

Classes

class  TableNameSpace
 
struct  NameSpaceDR
 

Functions

int module_init (const char *module_name, void *pdm, void *php)
 This function registers our user defined element for the math parser. More...
 

Function Documentation

int module_init ( const char *  module_name,
void *  pdm,
void *  php 
)

This function registers our user defined element for the math parser.

It is called when the "module load" statement appears in the input file.

Definition at line 119 of file module-namespace.cc.

References MathParser::bNameValidate(), IncludeParser::GetLineData(), HighParser::GetMathParser(), HighParser::GetString(), HighParser::IsArg(), MBDYN_EXCEPT_ARGS, MathParser::RegisterNameSpace(), and SetDescData().

120 {
121  MBDynParser& HP = *((MBDynParser *)php);
122 
123  NameSpaceDR *pDR = new NameSpaceDR;
124  if (pDR == 0) {
125  return false;
126  }
127  SetDescData("namespace", pDR);
128 
129  int rc = 0;
130  while (HP.IsArg()) {
131  const char *sName = HP.GetString();
132 
133  if (!HP.GetMathParser().bNameValidate(sName)) {
134  silent_cerr("Parser error in module-namespace::module_init(), "
135  " invalid namespace \"" << sName << "\" at line "
136  << HP.GetLineData() << std::endl);
138  }
139 
140  /* registers namespace */
141  MathParser::NameSpace *pNS = new TableNameSpace(sName);
142  rc = HP.GetMathParser().RegisterNameSpace(pNS);
143  if (rc != 0) {
144  delete pNS;
145  }
146  }
147 
148  return rc;
149 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
int RegisterNameSpace(NameSpace *ns)
Definition: mathp.cc:4602
bool SetDescData(const std::string &name, DescRead *rf)
Definition: parser.cc:301
bool bNameValidate(const std::string &s) const
Definition: mathp.cc:3292
virtual MathParser & GetMathParser(void)
Definition: parser.cc:668
virtual std::string GetString(const std::string &sDefVal)
Definition: parser.cc:1074
virtual bool IsArg(void)
Definition: parser.cc:807
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function: