OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
StringArray.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: StringArray.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Class StringArray:
10// A class used to parse array attributes.
11//
12// ------------------------------------------------------------------------
13//
14// $Date: 2000/03/27 09:33:36 $
15// $Author: Andreas Adelmann $
16//
17// ------------------------------------------------------------------------
18
20#include <vector>
23#include "Expressions/AValue.h"
26
27using namespace Expressions;
28
29// Class StringArray
30// ------------------------------------------------------------------------
31
32namespace Attributes {
33
34 StringArray::StringArray(const std::string& name, const std::string& help)
35 : AttributeHandler(name, help, 0) {}
36
38
39 const std::string& StringArray::getType() const {
40 static std::string type = "string array";
41 return type;
42 }
43
47
48 void StringArray::parseComponent(Attribute& attr, Statement& statement, bool, int index) const {
49 std::vector<std::string> array = Attributes::getStringArray(attr);
50
51 if (AttributeBase* base = &attr.getBase()) {
52 array = dynamic_cast<AValue<std::string>*>(base)->evaluate();
53 }
54
55 while (int(array.size()) < index) {
56 array.push_back(std::string());
57 }
58
59 array[index - 1] = Expressions::parseStringValue(statement, "String value expected.");
60 Attributes::setStringArray(attr, array);
61 }
62
63}; // namespace Attributes
Abstract base class for attribute values of different types.
Abstract base class for attribute parsers.
A representation of an Object attribute.
Definition Attribute.h:52
AttributeBase & getBase() const
Return reference to polymorphic value.
Definition Attribute.cpp:52
virtual const std::string & getType() const
Return attribute type string `‘string array’'.
virtual void parseComponent(Attribute &, Statement &, bool, int) const
Parse a component of the array.
virtual void parse(Attribute &, Statement &, bool) const
Parse the attribute.
Object attribute with a constant array value.
Definition AValue.h:35
Interface for statements.
Definition Statement.h:37
A collection of routines to construct object Attributes and retrieve.
void setStringArray(Attribute &attr, const std::vector< std::string > &value)
Set string array value.
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
Representation objects and parsers for attribute expressions.
std::string parseStringValue(Statement &, const char msg[])
std::vector< std::string > parseStringArray(Statement &)
Parse string array.