OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
TokenListArray.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: TokenListArray.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class TokenListArray:
10 // A class used to parse a "token list array" attribute.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:36 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
20 #include "Attributes/Attributes.h"
22 #include "Expressions/AValue.h"
24 #include <vector>
25 
26 using namespace Expressions;
27 
28 
29 // Class TokenListArray
30 // ------------------------------------------------------------------------
31 
32 namespace Attributes {
33 
34  TokenListArray::TokenListArray(const std::string &name, const std::string &help):
35  AttributeHandler(name, help, 0)
36  {}
37 
38 
40  {}
41 
42 
43  const std::string &TokenListArray::getType() const {
44  static const std::string type("token list array");
45  return type;
46  }
47 
48 
49  void TokenListArray::parse(Attribute &attr, Statement &stat, bool) const {
51  }
52 
53 
55  (Attribute &attr, Statement &statement, bool, int index) const {
56  std::vector<std::list<Token> > array;
57 
58  if(AttributeBase *base = &attr.getBase()) {
59  array = dynamic_cast<AValue<std::list<Token> > *>(base)->evaluate();
60  }
61 
62  while(int(array.size()) < index) {
63  array.push_back(std::list<Token>());
64  }
65 
66  array[index - 1] = Expressions::parseTokenList(statement);
67  Attributes::setTokenListArray(attr, array);
68  }
69 
70 };
Abstract base class for attribute values of different types.
Definition: AttributeBase.h:32
A representation of an Object attribute.
Definition: Attribute.h:55
Interface for statements.
Definition: Statement.h:38
virtual const std::string & getType() const
Return attribute type string ``token list array&#39;&#39;.
Abstract base class for attribute parsers.
Object attribute with a constant array value.
Definition: AValue.h:35
virtual void parseComponent(Attribute &, Statement &, bool, int) const
Parse a component.
const std::string name
std::list< Token > parseTokenList(Statement &)
Parse a token list (for macro argument and the like).
void setTokenListArray(Attribute &attr, const std::vector< std::list< Token > > &value)
Set token list array value.
Definition: Attributes.cpp:526
virtual void parse(Attribute &, Statement &, bool) const
Parse the attribute.
std::vector< std::list< Token > > parseTokenListArray(Statement &)
Parse a token list array (for LIST commands).
AttributeBase & getBase() const
Return reference to polymorphic value.
Definition: Attribute.cpp:67