Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Private Attributes
Arc::RSLValue Class Reference

#include <RSLParser.h>

Inheritance diagram for Arc::RSLValue:
Inheritance graph
[legend]
Collaboration diagram for Arc::RSLValue:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RSLValue ()
virtual ~RSLValue ()
RSLValueEvaluate (std::map< std::string, std::string > &vars) const
virtual void Print (std::ostream &os=std::cout) const =0

Static Private Attributes

static Logger logger

Detailed Description

Definition at line 32 of file RSLParser.h.


Constructor & Destructor Documentation

Definition at line 17 of file RSLParser.cpp.

{}
Arc::RSLValue::~RSLValue ( ) [virtual]

Definition at line 19 of file RSLParser.cpp.

{}

Member Function Documentation

RSLValue * Arc::RSLValue::Evaluate ( std::map< std::string, std::string > &  vars) const

Definition at line 21 of file RSLParser.cpp.

                                                                       {
    const RSLLiteral *n;
    const RSLVariable *v;
    const RSLConcat *c;
    const RSLList *l;
    const RSLSequence *s;
    if ((n = dynamic_cast<const RSLLiteral*>(this)))
      return new RSLLiteral(n->Value());
    else if ((v = dynamic_cast<const RSLVariable*>(this))) {
      std::map<std::string, std::string>::iterator it = vars.find(v->Var());
      return new RSLLiteral((it != vars.end()) ? it->second : "");
    }
    else if ((c = dynamic_cast<const RSLConcat*>(this))) {
      RSLValue *left = c->Left()->Evaluate(vars);
      if (!left) {
        std::stringstream ss;
        ss << *c->Left();
        logger.msg(ERROR, "Can't evaluate left operand for RSL "
                   "concatenation: %s", ss.str());
        return NULL;
      }
      RSLValue *right = c->Right()->Evaluate(vars);
      if (!right) {
        std::stringstream ss;
        ss << *c->Right();
        logger.msg(ERROR, "Can't evaluate right operand for RSL "
                   "concatenation: %s", ss.str());
        delete left;
        return NULL;
      }
      RSLLiteral *nleft = dynamic_cast<RSLLiteral*>(left);
      if (!nleft) {
        std::stringstream ss;
        ss << *left;
        logger.msg(ERROR, "Left operand for RSL concatenation does not "
                   "evaluate to a literal: %s", ss.str());
        delete left;
        delete right;
        return NULL;
      }
      RSLLiteral *nright = dynamic_cast<RSLLiteral*>(right);
      if (!nright) {
        std::stringstream ss;
        ss << *right;
        logger.msg(ERROR, "Right operand for RSL concatenation does not "
                   "evaluate to a literal: %s", ss.str());
        delete left;
        delete right;
        return NULL;
      }
      RSLLiteral *result = new RSLLiteral(nleft->Value() + nright->Value());
      delete left;
      delete right;
      return result;
    }
    else if ((l = dynamic_cast<const RSLList*>(this))) {
      RSLList *result = new RSLList;
      for (std::list<RSLValue*>::const_iterator it = l->begin();
           it != l->end(); it++) {
        RSLValue *value = (*it)->Evaluate(vars);
        if (!value) {
          std::stringstream ss;
          ss << **it;
          logger.msg(ERROR, "Can't evaluate RSL list member: %s", ss.str());
          delete result;
          return NULL;
        }
        result->Add(value);
      }
      return result;
    }
    else if ((s = dynamic_cast<const RSLSequence*>(this))) {
      RSLList *result = new RSLList;
      for (std::list<RSLValue*>::const_iterator it = s->begin();
           it != s->end(); it++) {
        RSLValue *value = (*it)->Evaluate(vars);
        if (!value) {
          std::stringstream ss;
          ss << **it;
          logger.msg(ERROR, "Can't evaluate RSL sequence member: %s", ss.str());
          delete result;
          return NULL;
        }
        result->Add(value);
      }
      return new RSLSequence(result);
    }
    else {
      logger.msg(ERROR, "Unknown RSL value type - should not happen");
      return NULL;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void Arc::RSLValue::Print ( std::ostream &  os = std::cout) const [pure virtual]

Member Data Documentation

Logger Arc::RSLValue::logger [static, private]

Definition at line 39 of file RSLParser.h.


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