OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
22#include "Expressions/AValue.h"
24#include <vector>
25
26using namespace Expressions;
27
28
29// Class TokenListArray
30// ------------------------------------------------------------------------
31
32namespace 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);
68 }
69
70};
const std::string name
Representation objects and parsers for attribute expressions.
Definition: Expressions.h:64
std::vector< std::list< Token > > parseTokenListArray(Statement &)
Parse a token list array (for LIST commands).
std::list< Token > parseTokenList(Statement &)
Parse a token list (for macro argument and the like).
A collection of routines to construct object Attributes and retrieve.
Definition: Attributes.cpp:85
void setTokenListArray(Attribute &attr, const std::vector< std::list< Token > > &value)
Set token list array value.
Definition: Attributes.cpp:646
boost::function< boost::tuple< double, bool >(arguments_t)> type
Definition: function.hpp:21
A representation of an Object attribute.
Definition: Attribute.h:52
AttributeBase & getBase() const
Return reference to polymorphic value.
Definition: Attribute.cpp:69
Abstract base class for attribute values of different types.
Definition: AttributeBase.h:32
Abstract base class for attribute parsers.
virtual void parseComponent(Attribute &, Statement &, bool, int) const
Parse a component.
virtual void parse(Attribute &, Statement &, bool) const
Parse the attribute.
virtual const std::string & getType() const
Return attribute type string `‘token list array’'.
Interface for statements.
Definition: Statement.h:38
Object attribute with a constant array value.
Definition: AValue.h:35