[Compbench-devel] CompBenchmarks++/libcompbenchmarks/CEL CEL-Array.cpp, NONE, 1.1 CEL-Array.h, NONE
Brought to you by:
xfred
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/CEL In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26450 Added Files: CEL-Array.cpp CEL-Array.h CEL-Atom.cpp CEL-Atom.h CEL-Block.cpp CEL-Block.h CEL-Cmp.cpp CEL-Cmp.h CEL-Cond.cpp CEL-Cond.h CEL-Function.cpp CEL-Function.h CEL-Logic.cpp CEL-Logic.h CEL-Loop.cpp CEL-Loop.h CEL-Math.cpp CEL-Math.h CEL-Reader.cpp CEL-Reader.h CEL-Stack.cpp CEL-Stack.h CEL-Str.cpp CEL-Str.h CEL-Var.cpp CEL-Var.h CEL-Version.cpp CEL-Version.h Makefile.am Log Message: First import. --- NEW FILE: CEL-Cond.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Cond.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Cond.h> #include <stdlib.h> using namespace CBM; CelCond::CelCond() : CelAtom() { } CelCond::~CelCond() { } CelCondIf::CelCondIf() : CelCond() { } std::string CelCondIf::xmlEntityName(void) { return("cel-cond-if"); } std::string CelCondIf::Evaluate(void) { int n = childs.size(); CelAtom *C; CelAtom *OK; CelAtom *NOK; if ((n<2) || (n>3)) return("0"); C=childs[0]; OK=childs[1]; if (n==3) NOK=childs[2]; else NOK=0; if (C->Evaluate() == "1") { return(OK->Evaluate()); } else { if (NOK) return(NOK->Evaluate()); else return(0); } } CelCondIf::~CelCondIf() { } --- NEW FILE: CEL-Math.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Math.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Math.h> #include <stdlib.h> using namespace CBM; CelMath::CelMath() : CelAtom() { } CelMath::~CelMath() { } CelMathInc::CelMathInc() : CelMath() { } std::string CelMathInc::xmlEntityName(void) { return("cel-math-inc"); } std::string CelMathInc::Evaluate(void) { int i; int n = childs.size(); CelAtom *A; std::string r; char tmp[32]; if (n!=1) return(0); A=childs[0]; i=atoi(A->Evaluate().c_str()); i++; sprintf(tmp, "%d", i); r=tmp; return(r); } CelMathInc::~CelMathInc() { } CelMathDec::CelMathDec() : CelMath() { } std::string CelMathDec::xmlEntityName(void) { return("cel-math-dec"); } std::string CelMathDec::Evaluate(void) { int i; int n = childs.size(); CelAtom *A; std::string r; char tmp[32]; if (n!=1) return(0); A=childs[0]; i=atoi(A->Evaluate().c_str()); i--; sprintf(tmp, "%d", i); r=tmp; return(r); } CelMathDec::~CelMathDec() { } --- NEW FILE: CEL-Version.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Version.h,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELVERSION #define H_CBM_CELVERSION 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelVersion : public CelAtom { private: int internal; int internal_mul; int digits; void setInternal(std::string _version); void updateVersion(void); protected: std::string version; virtual std::string xmlEntityName(void); public: CelVersion(std::string _version); virtual std::string Evaluate(void); virtual ~CelVersion(); }; } #endif --- NEW FILE: CEL-Block.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Block.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELBLOCK #define H_CBM_CELBLOCK 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelBlock : public CelAtom { protected: virtual std::string xmlEntityName(void); public: CelBlock(); virtual std::string Evaluate(void); virtual ~CelBlock(); }; } #endif --- NEW FILE: CEL-Cond.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Cond.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELCOND #define H_CBM_CELCOND 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelCond : public CelAtom { protected: CelCond(); public: virtual ~CelCond(); }; /** \brief ? */ class CelCondIf : public CelCond { protected: virtual std::string xmlEntityName(void); public: CelCondIf(); virtual std::string Evaluate(void); virtual ~CelCondIf(); }; } #endif --- NEW FILE: CEL-Var.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Var.cpp,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Var.h> using namespace CBM; typedef struct { std::string name; std::string value; } celVar_t; std::vector<celVar_t*> celVars; void CBM::CELVarDone(void) { int i; int n = celVars.size(); std::vector<celVar_t*> ncelVars; celVar_t *V; for(i=0; i<n; i++) { V=celVars[i]; delete(V); } celVars=ncelVars; } celVar_t *celVarGet(std::string _name) { int i; int n = celVars.size(); celVar_t *V; for(i=0; i<n; i++) { V=celVars[i]; if (V->name==_name) return(V); } return(0); } std::string celVarRemove(std::string _name) { celVar_t *cv = celVarGet(_name); celVar_t *V; std::vector<celVar_t*> ncelVars; int i; int n = celVars.size(); if (!cv) return("0"); for(i=0; i<n; i++) { V=celVars[i]; if (V!=cv) ncelVars.push_back(V); } celVars=ncelVars; delete(cv); return("1"); } CelVar::CelVar() : CelAtom() { } CelVar::~CelVar() { } CelVarSet::CelVarSet() : CelVar() { } std::string CelVarSet::xmlEntityName(void) { return("cel-var-set"); } std::string CelVarSet::Evaluate(void) { int n = childs.size(); CelAtom *N; CelAtom *V; std::string name; std::string value; celVar_t *cv; if (n!=2) return("0"); N=childs[0]; V=childs[1]; name=N->Evaluate(); value=V->Evaluate(); cv=celVarGet(name); if (!cv) { cv=new celVar_t; celVars.push_back(cv); } cv->name=name; cv->value=value; return("1"); } CelVarSet::~CelVarSet() { } CelVarGet::CelVarGet() : CelVar() { } std::string CelVarGet::xmlEntityName(void) { return("cel-var-get"); } std::string CelVarGet::Evaluate(void) { int n = childs.size(); CelAtom *N; celVar_t *cv; if (n!=1) return("0"); N=childs[0]; cv=celVarGet(N->Evaluate()); if (cv) return(cv->value); else return("0"); } CelVarGet::~CelVarGet() { } CelVarUndef::CelVarUndef() : CelVar() { } std::string CelVarUndef::xmlEntityName(void) { return("cel-var-undef"); } std::string CelVarUndef::Evaluate(void) { int n = childs.size(); CelAtom *N; if (n!=1) return("0"); N=childs[0]; return(celVarRemove(N->Evaluate())); } CelVarUndef::~CelVarUndef() { } --- NEW FILE: CEL-Math.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Math.h,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELMATH #define H_CBM_CELMATH 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelMath : public CelAtom { protected: public: CelMath(); virtual ~CelMath(); }; /** \brief ? */ class CelMathInc : public CelMath { protected: virtual std::string xmlEntityName(void); public: CelMathInc(); virtual std::string Evaluate(void); virtual ~CelMathInc(); }; /** \brief ? */ class CelMathDec : public CelMath { protected: virtual std::string xmlEntityName(void); public: CelMathDec(); virtual std::string Evaluate(void); virtual ~CelMathDec(); }; } #endif --- NEW FILE: CEL-Array.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Array.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Array.h> #include <stdlib.h> using namespace CBM; typedef struct { std::string name; std::vector<std::string> value; } celArray_t; std::vector<celArray_t*> celArrays; void CBM::CELArrayDone(void) { int i; int n = celArrays.size(); std::vector<celArray_t*> ncelArrays; celArray_t *A; for(i=0; i<n; i++) { A=celArrays[i]; delete(A); } celArrays=ncelArrays; } celArray_t *celArrayGet(std::string _name) { int i; int n = celArrays.size(); celArray_t *A; for(i=0; i<n; i++) { A=celArrays[i]; if (A->name==_name) return(A); } return(0); } std::string celArrayRemove(std::string _name) { celArray_t *ca = celArrayGet(_name); celArray_t *A; std::vector<celArray_t*> ncelArrays; int i; int n = celArrays.size(); if (!ca) return("0"); for(i=0; i<n; i++) { A=celArrays[i]; if (A!=ca) ncelArrays.push_back(A); } celArrays=ncelArrays; delete(ca); return("1"); } CelArray::CelArray() : CelAtom() { } CelArray::~CelArray() { } CelArrayDef::CelArrayDef() : CelArray() { } std::string CelArrayDef::xmlEntityName(void) { return("cel-array-def"); } std::string CelArrayDef::Evaluate(void) { int n = childs.size(); CelAtom *N; std::string name; celArray_t *ca; if (n!=1) return("0"); N=childs[0]; name=N->Evaluate(); ca=celArrayGet(name); if (!ca) { ca=new celArray_t; celArrays.push_back(ca); } ca->name=name; return("1"); } CelArrayDef::~CelArrayDef() { } CelArrayAdd::CelArrayAdd() : CelArray() { } std::string CelArrayAdd::xmlEntityName(void) { return("cel-array-add"); } std::string CelArrayAdd::Evaluate(void) { int n = childs.size(); CelAtom *N; CelAtom *V; std::string name; std::string value; celArray_t *ca; if (n!=2) return("0"); N=childs[0]; V=childs[1]; name=N->Evaluate(); value=V->Evaluate(); ca=celArrayGet(name); if (!ca) { ca=new celArray_t; celArrays.push_back(ca); } ca->name=name; ca->value.push_back(value); return("1"); } CelArrayAdd::~CelArrayAdd() { } CelArraySize::CelArraySize() : CelArray() { } std::string CelArraySize::xmlEntityName(void) { return("cel-array-size"); } std::string CelArraySize::Evaluate(void) { int n = childs.size(); std::string r; CelAtom *N; char tmp[32]; celArray_t *ca; std::string name; if (n!=1) return("0"); N=childs[0]; name=N->Evaluate(); ca=celArrayGet(name); if (!ca) { return("0"); } sprintf(tmp, "%d", ca->value.size()); r=tmp; return(r); } CelArraySize::~CelArraySize() { } CelArrayGet::CelArrayGet() : CelArray() { } std::string CelArrayGet::xmlEntityName(void) { return("cel-array-get"); } std::string CelArrayGet::Evaluate(void) { int n = childs.size(); CelAtom *N; CelAtom *I; std::string is; int i; celArray_t *ca; if (n!=2) return("0"); N=childs[0]; I=childs[1]; is=I->Evaluate(); i=atoi(is.c_str()); ca=celArrayGet(N->Evaluate()); if (ca) { if ((i>=0) && ((unsigned) i<ca->value.size())) return(ca->value[i]); else return("0"); } else return("0"); } CelArrayGet::~CelArrayGet() { } CelArrayUndef::CelArrayUndef() : CelArray() { } std::string CelArrayUndef::xmlEntityName(void) { return("cel-array-undef"); } std::string CelArrayUndef::Evaluate(void) { int n = childs.size(); CelAtom *N; if (n!=1) return("0"); N=childs[0]; return(celArrayRemove(N->Evaluate())); } CelArrayUndef::~CelArrayUndef() { } --- NEW FILE: CEL-Stack.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Stack.cpp,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Stack.h> #include <CEL/CEL-Var.h> #include <stack> using namespace CBM; std::stack<std::string> celStack; CelStack::CelStack() : CelAtom() { } CelStack::~CelStack() { } CelStackPush::CelStackPush() : CelStack() { } std::string CelStackPush::xmlEntityName(void) { return("cel-stack-push"); } std::string CelStackPush::Evaluate(void) { int n = childs.size(); int i; CelAtom *N; if (!n) return("0"); for(i=0; i<n; i++) { N=childs[i]; celStack.push(N->Evaluate()); } return("1"); } CelStackPush::~CelStackPush() { } CelStackPop::CelStackPop() { } std::string CelStackPop::xmlEntityName(void) { return("cel-stack-pop"); } std::string CelStackPop::Evaluate(void) { int n = childs.size(); std::string r; if (n) return("0"); if (!celStack.empty()) { r=celStack.top(); celStack.pop(); return(r); } return("0"); } CelStackPop::~CelStackPop() { } --- NEW FILE: CEL-Array.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Array.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELARRAY #define H_CBM_CELARRAY 1 #include <CEL/CEL-Atom.h> namespace CBM { void CELArrayDone(void); /** \brief ? */ class CelArray : public CelAtom { protected: CelArray(); public: virtual ~CelArray(); }; /** \brief ? */ class CelArrayDef : public CelArray { protected: virtual std::string xmlEntityName(void); public: CelArrayDef(); virtual std::string Evaluate(void); virtual ~CelArrayDef(); }; class CelArrayAdd : public CelArray { protected: virtual std::string xmlEntityName(void); public: CelArrayAdd(); virtual std::string Evaluate(void); virtual ~CelArrayAdd(); }; class CelArraySize : public CelArray { protected: virtual std::string xmlEntityName(void); public: CelArraySize(); virtual std::string Evaluate(void); virtual ~CelArraySize(); }; class CelArrayGet : public CelArray { protected: virtual std::string xmlEntityName(void); public: CelArrayGet(); virtual std::string Evaluate(void); virtual ~CelArrayGet(); }; class CelArrayUndef : public CelArray { protected: virtual std::string xmlEntityName(void); public: CelArrayUndef(); virtual std::string Evaluate(void); virtual ~CelArrayUndef(); }; } #endif --- NEW FILE: CEL-Var.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Var.h,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELVAR #define H_CBM_CELVAR 1 #include <CEL/CEL-Atom.h> namespace CBM { void CELVarDone(void); /** \brief ? */ class CelVar : public CelAtom { protected: CelVar(); public: virtual ~CelVar(); }; /** \brief ? */ class CelVarSet : public CelVar { protected: virtual std::string xmlEntityName(void); public: CelVarSet(); virtual std::string Evaluate(void); virtual ~CelVarSet(); }; class CelVarGet : public CelVar { protected: virtual std::string xmlEntityName(void); public: CelVarGet(); virtual std::string Evaluate(void); virtual ~CelVarGet(); }; class CelVarUndef : public CelVar { protected: virtual std::string xmlEntityName(void); public: CelVarUndef(); virtual std::string Evaluate(void); virtual ~CelVarUndef(); }; } #endif --- NEW FILE: Makefile.am --- # ----------------------------------------------------------------------------- # $Id: Makefile.am,v 1.1 2007/03/05 20:32:40 xfred Exp $ # $Source: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/CEL/Makefile.am,v $ # # This is free software. # For details, see the GNU Public License in the COPYING file, or # Look http://www.fsf.org # ----------------------------------------------------------------------------- noinst_LTLIBRARIES = libCEL.la sources = CEL-Atom.cpp CEL-Str.cpp CEL-Logic.cpp \ CEL-Version.cpp CEL-Math.cpp \ CEL-Cmp.cpp CEL-Cond.cpp CEL-Var.cpp \ CEL-Array.cpp \ CEL-Block.cpp CEL-Loop.cpp \ CEL-Function.cpp CEL-Stack.cpp \ CEL-Reader.cpp libCEL_la_SOURCES = $(sources) libPlaninclude_HEADERS = $(sources:.cpp=.h) $(EXTRA_DIST:.cpp=.h) libPlanincludedir = $(includedir)/compbenchmarks/CEL INCLUDES = -I $(top_srcdir)/libcompbenchmarks @XML_CPPFLAGS@ libCEL_la_LIBADD = @XML_LIBS@ --- NEW FILE: CEL-Logic.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Logic.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELLOGIC #define H_CBM_CELLOGIC 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelLogic : public CelAtom { protected: public: CelLogic(); virtual ~CelLogic(); }; /** \brief ? */ class CelLogicTrue : public CelLogic { protected: virtual std::string xmlEntityName(void); public: CelLogicTrue(); virtual std::string Evaluate(void); virtual ~CelLogicTrue(); }; /** \brief ? */ class CelLogicFalse : public CelLogic { protected: virtual std::string xmlEntityName(void); public: CelLogicFalse(); virtual std::string Evaluate(void); virtual ~CelLogicFalse(); }; /** \brief ? */ class CelLogicOr : public CelLogic { protected: virtual std::string xmlEntityName(void); public: CelLogicOr(); virtual std::string Evaluate(void); virtual ~CelLogicOr(); }; /** \brief ? */ class CelLogicAnd : public CelLogic { protected: virtual std::string xmlEntityName(void); public: CelLogicAnd(); virtual std::string Evaluate(void); virtual ~CelLogicAnd(); }; /** \brief ? */ class CelLogicNot : public CelLogic { protected: virtual std::string xmlEntityName(void); public: CelLogicNot(); virtual std::string Evaluate(void); virtual ~CelLogicNot(); }; } #endif --- NEW FILE: CEL-Logic.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Logic.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Logic.h> using namespace CBM; CelLogic::CelLogic() : CelAtom() { } CelLogic::~CelLogic() { } CelLogicTrue::CelLogicTrue() : CelLogic() { } std::string CelLogicTrue::xmlEntityName(void) { return("cel-logic-true"); } std::string CelLogicTrue::Evaluate(void) { return("1"); } CelLogicTrue::~CelLogicTrue() { } CelLogicFalse::CelLogicFalse() : CelLogic() { } std::string CelLogicFalse::xmlEntityName(void) { return("cel-logic-false"); } std::string CelLogicFalse::Evaluate(void) { return("0"); } CelLogicFalse::~CelLogicFalse() { } CelLogicOr::CelLogicOr() : CelLogic() { } std::string CelLogicOr::xmlEntityName(void) { return("cel-logic-or"); } std::string CelLogicOr::Evaluate(void) { int i; int n = childs.size(); CelAtom *A; for(i=0; i<n; i++) { A=childs[i]; if (A->Evaluate() != "0") return("1"); } return("0"); } CelLogicOr::~CelLogicOr() { } CelLogicAnd::CelLogicAnd() : CelLogic() { } std::string CelLogicAnd::xmlEntityName(void) { return("cel-logic-and"); } std::string CelLogicAnd::Evaluate(void) { int i; int n = childs.size(); CelAtom *A; for(i=0; i<n; i++) { A=childs[i]; if (A->Evaluate() == "0") return("0"); } return("1"); } CelLogicAnd::~CelLogicAnd() { } CelLogicNot::CelLogicNot() : CelLogic() { } std::string CelLogicNot::xmlEntityName(void) { return("cel-logic-not"); } std::string CelLogicNot::Evaluate(void) { int n = childs.size(); CelAtom *A; if (n==1) { A=childs[0]; if (A->Evaluate() != "0") return("0"); else return("1"); } return("0"); } CelLogicNot::~CelLogicNot() { } --- NEW FILE: CEL-Block.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Block.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Block.h> using namespace CBM; CelBlock::CelBlock() { } std::string CelBlock::xmlEntityName(void) { return("cel-block"); } std::string CelBlock::Evaluate(void) { int n = childs.size(); int i; CelAtom *A; std::string r = "0"; for(i=0;i<n;i++) { A=childs[i]; r=A->Evaluate(); } return(r); } CelBlock::~CelBlock() { } --- NEW FILE: CEL-Loop.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Loop.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Loop.h> #include <stdlib.h> using namespace CBM; CelLoop::CelLoop() : CelAtom() { } std::string CelLoop::xmlEntityName(void) { return("cel-loop"); } std::string CelLoop::Evaluate(void) { int n = childs.size(); int i; CelAtom *C; CelAtom *A; std::string r; int l_break = 0; if (n<2) return("0"); C=childs[0]; while ((!l_break) && (C->Evaluate() == "1")) { for(i=1; i<n; i++) { A=childs[i]; if (A->xmlEntityName()=="cel-loop-break") { l_break=1; break; } r=A->Evaluate(); } } return(r); } CelLoop::~CelLoop() { } CelLoopBreak::CelLoopBreak() { } std::string CelLoopBreak::xmlEntityName(void) { return("cel-loop-break"); } std::string CelLoopBreak::Evaluate(void) { return("0"); } CelLoopBreak::~CelLoopBreak() { } --- NEW FILE: CEL-Function.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Function.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELFUNCTION #define H_CBM_CELFUNCTION 1 #include <CEL/CEL-Atom.h> namespace CBM { void CELFunctionDone(void); /** \brief ? */ class CelFunction : public CelAtom { protected: CelFunction(); public: virtual ~CelFunction(); }; /** \brief ? */ class CelFunctionDef : public CelFunction { protected: virtual std::string xmlEntityName(void); public: CelFunctionDef(); virtual std::string Evaluate(void); virtual ~CelFunctionDef(); }; class CelFunctionCall : public CelFunction { protected: virtual std::string xmlEntityName(void); public: CelFunctionCall(); virtual std::string Evaluate(void); virtual ~CelFunctionCall(); }; class CelFunctionReturn : public CelFunction { protected: virtual std::string xmlEntityName(void); public: CelFunctionReturn(); virtual std::string Evaluate(void); virtual ~CelFunctionReturn(); }; } #endif --- NEW FILE: CEL-Loop.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Loop.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELLOOP #define H_CBM_CELLOOP 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelLoop : public CelAtom { protected: virtual std::string xmlEntityName(void); public: CelLoop(); virtual std::string Evaluate(void); virtual ~CelLoop(); }; /** \brief ? */ class CelLoopBreak : public CelAtom { protected: virtual std::string xmlEntityName(void); public: CelLoopBreak(); virtual std::string Evaluate(void); virtual ~CelLoopBreak(); }; } #endif --- NEW FILE: CEL-Cmp.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Cmp.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Cmp.h> #include <stdlib.h> using namespace CBM; CelCmp::CelCmp() : CelAtom() { } CelCmp::~CelCmp() { } CelCmpEq::CelCmpEq() : CelCmp() { } std::string CelCmpEq::xmlEntityName(void) { return("cel-cmp-eq"); } std::string CelCmpEq::Evaluate(void) { int i; int n = childs.size(); CelAtom *A; std::string previous; int previousSet = 0; if (n<=1) return("0"); for(i=0; i<n; i++) { A=childs[i]; if (previousSet) { if (A->Evaluate() != previous) return("0"); } else { previousSet=1; previous=A->Evaluate(); } } return("1"); } CelCmpEq::~CelCmpEq() { } CelCmpAE::CelCmpAE() : CelCmp() { } std::string CelCmpAE::xmlEntityName(void) { return("cel-cmp-ae"); } std::string CelCmpAE::Evaluate(void) { int i; int n = childs.size(); CelAtom *A; int previousSet = 0; std::string dum; int tmp; int previous_tmp; if (n<=1) return("0"); for(i=0; i<n; i++) { A=childs[i]; if (previousSet) { dum=A->Evaluate(); tmp=atoi(dum.c_str()); if (tmp < previous_tmp) return("0"); } else { previousSet=1; dum=A->Evaluate(); previous_tmp=atoi(dum.c_str()); } } return("1"); } CelCmpAE::~CelCmpAE() { } --- NEW FILE: CEL-Reader.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Reader.cpp,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Reader.h> #include <CEL/CEL-Atom.h> #include <Base/XMLReader.h> using namespace CBM; CELReader::CELReader(std::string _filename) { CBM::XMLReader r; root=r.read(_filename); } CELAtom *CELReader::parse(void) { CBM::XMLNode *N; int i; int n; if (!root) return(0); n=root->nodeNumber(); for(i=0;i<n;i++) { N=root->getNode(i); if (N->Name()=="cel-str") { } } } CELReader::~CELReader() { } --- NEW FILE: CEL-Function.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Function.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Function.h> using namespace CBM; typedef struct { std::string name; CBM::CelAtom *function; } celFunction_t; std::vector<celFunction_t*> celFunctions; celFunction_t *celFunctionGet(std::string _name) { int i; int n = celFunctions.size(); celFunction_t *F; for(i=0; i<n; i++) { F=celFunctions[i]; if (F->name==_name) return(F); } return(0); } void CBM::CELFunctionDone(void) { } CelFunction::CelFunction() : CelAtom() { } CelFunction::~CelFunction() { } CelFunctionDef::CelFunctionDef() : CelFunction() { } std::string CelFunctionDef::xmlEntityName(void) { return("cel-function-def"); } std::string CelFunctionDef::Evaluate(void) { int n = childs.size(); CelAtom *N; std::string name; celFunction_t *cf; if (n<2) return("0"); N=childs[0]; name=N->Evaluate(); cf=celFunctionGet(name); if (!cf) { cf=new celFunction_t; celFunctions.push_back(cf); cf->name=name; cf->function=this; return("1"); } else return("0"); } CelFunctionDef::~CelFunctionDef() { } CelFunctionCall::CelFunctionCall() { } std::string CelFunctionCall::xmlEntityName(void) { return("cel-function-call"); } std::string CelFunctionCall::Evaluate(void) { int n = childs.size(); int i; CelAtom *N; celFunction_t *cf; std::string r = "0"; if (n!=1) return("0"); N=childs[0]; cf=celFunctionGet(N->Evaluate()); if (cf) { n=cf->function->Childs().size(); for(i=1;i<n;i++) { N=cf->function->Childs()[i]; r=N->Evaluate(); if (N->xmlEntityName()=="cel-function-return") { break; } } return(r); } else return("0"); } CelFunctionCall::~CelFunctionCall() { } CelFunctionReturn::CelFunctionReturn() { } std::string CelFunctionReturn::xmlEntityName(void) { return("cel-function-return"); } std::string CelFunctionReturn::Evaluate(void) { int n = childs.size(); CelAtom *N; std::string r = "0"; if (n!=1) return("0"); N=childs[0]; return(N->Evaluate()); } CelFunctionReturn::~CelFunctionReturn() { } --- NEW FILE: CEL-Version.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Version.cpp,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Version.h> #include <System/System.h> #include <stdlib.h> using namespace CBM; CelVersion::CelVersion(std::string _version) : CelAtom() { setInternal(_version); updateVersion(); } std::string CelVersion::xmlEntityName(void) { return("cel-version"); } void CelVersion::setInternal(std::string _version) { int i = 0; int mul = 1; std::string cur; int tmp; internal=0; internal_mul=0; digits=0; while ( (cur=cbmSystem->Split(_version, ".", i))!="") { tmp=atoi(cur.c_str()); internal+=tmp; internal*=100; mul*=100; i++; digits+=2; } internal/=100; while (digits<8) { digits+=2; mul*=100; } internal_mul=mul; } void CelVersion::updateVersion(void) { /* int inter = internal; int mul = internal_mul; int tmp; char c[16]; version=""; while (mul>1) { tmp=(inter/mul); sprintf(c, "%d", tmp); inter-=(tmp*mul); mul/=100; version+=c; if (mul>1) version+="."; } */ char c[16]; /* sprintf(c, "%d", internal); */ sprintf(c, "%0*d", digits, internal); version=c; } std::string CelVersion::Evaluate(void) { return(version); } CelVersion::~CelVersion() { } --- NEW FILE: CEL-Stack.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Stack.h,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELSTACK #define H_CBM_CELSTACK 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelStack : public CelAtom { protected: CelStack(); public: virtual ~CelStack(); }; /** \brief ? */ class CelStackPush : public CelStack { protected: virtual std::string xmlEntityName(void); public: CelStackPush(); virtual std::string Evaluate(void); virtual ~CelStackPush(); }; class CelStackPop : public CelStack { protected: virtual std::string xmlEntityName(void); public: CelStackPop(); virtual std::string Evaluate(void); virtual ~CelStackPop(); }; } #endif --- NEW FILE: CEL-Reader.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Reader.h,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELREADER #define H_CBM_CELREADER 1 #include <Base/XML.h> namespace CBM { /** \brief Interface to CEL XML files ? */ class CELReader { protected: XMLNode *root; public: /** Constructor */ CELReader(std::string _filename); class CELAtom *parse(void); /** Destructor */ virtual ~CELReader(); }; } #endif --- NEW FILE: CEL-Str.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Str.cpp,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Str.h> using namespace CBM; CelStr::CelStr(std::string _string) : CelAtom() { string=_string; } std::string CelStr::xmlEntityName(void) { return("cel-str"); } std::string CelStr::xmlValue(void) { return(string); } std::string CelStr::Evaluate(void) { return(string); } CelStr::~CelStr() { } CelStrConcat::CelStrConcat() : CelAtom() { } std::string CelStrConcat::xmlEntityName(void) { return("cel-str-concat"); } std::string CelStrConcat::Evaluate(void) { std::string r = ""; int n = childs.size(); int i; CelAtom *A; for(i=0; i<n; i++) { A=childs[i]; r+=A->Evaluate(); } return(r); } CelStrConcat::~CelStrConcat() { } --- NEW FILE: CEL-Str.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Str.h,v 1.1 2007/03/05 20:32:40 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELSTR #define H_CBM_CELSTR 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelStr : public CelAtom { protected: std::string string; virtual std::string xmlEntityName(void); virtual std::string xmlValue(void); public: CelStr(std::string _string); virtual std::string Evaluate(void); virtual ~CelStr(); }; class CelStrConcat : public CelAtom { protected: virtual std::string xmlEntityName(void); public: CelStrConcat(); virtual std::string Evaluate(void); virtual ~CelStrConcat(); }; } #endif --- NEW FILE: CEL-Atom.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Atom.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELATOM #define H_CBM_CELATOM 1 #include <vector> #include <string> namespace CBM { /** \brief ? */ class CelAtom { protected: std::vector<CelAtom *> childs; CelAtom(); virtual void indent(std::string& str, int _indent); virtual std::string xmlValue(void); virtual std::string xmlProperties(void); public: virtual std::string xmlEntityName(void) = 0; virtual std::vector<CelAtom *>& Childs(void); virtual void add(CelAtom *_atom); virtual std::string Evaluate(void) = 0; virtual std::string str(int _indent = 0); virtual ~CelAtom(); }; } #endif --- NEW FILE: CEL-Cmp.h --- /* ---------------------------------------------------------------------------- $Id: CEL-Cmp.h,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBM_CELCMP #define H_CBM_CELCMP 1 #include <CEL/CEL-Atom.h> namespace CBM { /** \brief ? */ class CelCmp : public CelAtom { protected: public: CelCmp(); virtual ~CelCmp(); }; /** \brief ? */ class CelCmpEq : public CelCmp { protected: virtual std::string xmlEntityName(void); public: CelCmpEq(); virtual std::string Evaluate(void); virtual ~CelCmpEq(); }; /** \brief ? */ class CelCmpAE : public CelCmp { protected: virtual std::string xmlEntityName(void); public: CelCmpAE(); virtual std::string Evaluate(void); virtual ~CelCmpAE(); }; } #endif --- NEW FILE: CEL-Atom.cpp --- /* ---------------------------------------------------------------------------- $Id: CEL-Atom.cpp,v 1.1 2007/03/05 20:32:39 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <CEL/CEL-Atom.h> using namespace CBM; CelAtom::CelAtom() { } void CelAtom::indent(std::string& str, int _indent) { int i = _indent; while (i--) str+=" "; } std::string CelAtom::xmlProperties(void) { return(""); } std::string CelAtom::xmlValue(void) { return(""); } std::vector<CelAtom *>& CelAtom::Childs(void) { return(childs); } void CelAtom::add(CBM::CelAtom *_atom) { childs.push_back(_atom); } std::string CelAtom::str(int _indent) { int i; int n = childs.size(); CelAtom *A; std::string r; std::string p; std::string v; r="<"; r+=xmlEntityName(); p=xmlProperties(); v=xmlValue(); if (p!="") { r+=" "; r+=p; } if (v!="") { r+=">"; r+=v; } if (n) { if (v=="") r+=">\n"; else r+="\n"; for(i=0;i<n;i++) { A=childs[i]; indent(r, _indent+1); r+=A->str(_indent+1); } indent(r,_indent); r+="</"; r+=xmlEntityName(); r+=">\n"; } else { if (v=="") r+="/>\n"; else { r+="</"; r+=xmlEntityName(); r+=">\n"; } } return(r); } CelAtom::~CelAtom() { } |