Back to index

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

#include <RSLParser.h>

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

List of all members.

Public Member Functions

 RSLList ()
 ~RSLList ()
void Add (RSLValue *value)
void Print (std::ostream &os=std::cout) const
std::list< RSLValue * >::iterator begin ()
std::list< RSLValue * >::iterator end ()
std::list< RSLValue * >
::const_iterator 
begin () const
std::list< RSLValue * >
::const_iterator 
end () const
std::list< RSLValue * >::size_type size () const
RSLValueEvaluate (std::map< std::string, std::string > &vars) const

Private Attributes

std::list< RSLValue * > values

Detailed Description

Definition at line 85 of file RSLParser.h.


Constructor & Destructor Documentation

Definition at line 154 of file RSLParser.cpp.

    : RSLValue() {}

Definition at line 157 of file RSLParser.cpp.

                    {
    for (std::list<RSLValue*>::iterator it = begin(); it != end(); it++)
      delete *it;
  }

Here is the call graph for this function:


Member Function Documentation

void Arc::RSLList::Add ( RSLValue value)

Definition at line 162 of file RSLParser.cpp.

                                   {
    values.push_back(value);
  }

Here is the caller graph for this function:

std::list<RSLValue*>::iterator Arc::RSLList::begin ( ) [inline]

Definition at line 92 of file RSLParser.h.

                                       {
      return values.begin();
    }

Here is the caller graph for this function:

std::list<RSLValue*>::const_iterator Arc::RSLList::begin ( ) const [inline]

Definition at line 98 of file RSLParser.h.

                                                   {
      return values.begin();
    }
std::list<RSLValue*>::iterator Arc::RSLList::end ( ) [inline]

Definition at line 95 of file RSLParser.h.

                                     {
      return values.end();
    }

Here is the caller graph for this function:

std::list<RSLValue*>::const_iterator Arc::RSLList::end ( ) const [inline]

Definition at line 101 of file RSLParser.h.

                                                 {
      return values.end();
    }
RSLValue * Arc::RSLValue::Evaluate ( std::map< std::string, std::string > &  vars) const [inherited]

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:

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

Implements Arc::RSLValue.

Definition at line 166 of file RSLParser.cpp.

                                          {
    for (std::list<RSLValue*>::const_iterator it = begin();
         it != end(); it++) {
      if (it != begin())
        os << " ";
      os << **it;
    }
  }

Here is the call graph for this function:

std::list<RSLValue*>::size_type Arc::RSLList::size ( ) const [inline]

Definition at line 104 of file RSLParser.h.

                                             {
      return values.size();
    }

Here is the caller graph for this function:


Member Data Documentation

std::list<RSLValue*> Arc::RSLList::values [private]

Definition at line 108 of file RSLParser.h.


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