cstringparimpl.h Source File

API: cstringparimpl.h Source File
API
cstringparimpl.h
1//==========================================================================
2// CSTRINGPARIMPL.H - part of
3// OMNeT++/OMNEST
4// Discrete System Simulation in C++
5//
6//==========================================================================
7
8/*--------------------------------------------------------------*
9 Copyright (C) 1992-2017 Andras Varga
10 Copyright (C) 2006-2017 OpenSim Ltd.
11
12 This file is distributed WITHOUT ANY WARRANTY. See the file
13 `license' for details on this and other legal matters.
14*--------------------------------------------------------------*/
15
16#ifndef __OMNETPP_CSTRINGPARIMPL_H
17#define __OMNETPP_CSTRINGPARIMPL_H
18
19#include "cparimpl.h"
20
21namespace omnetpp {
22namespace internal {
23
30class SIM_API cStringParImpl : public cParImpl
31{
32 protected:
33 // only one of expr and val is active at a time; however, we cannot use
34 // union here because std::string has constructor/destructor.
35 // selector: flags & FL_ISEXPR
36 cExpression *expr = nullptr;
37 std::string val;
38
39 // if not null: list of acceptable values
40 std::vector<std::string> *enumValues = nullptr;
41
42 private:
43 void copy(const cStringParImpl& other);
44 void validate(const char *value) const;
45
46 protected:
47 void deleteOld() {cParImpl::deleteOld(expr);}
48
49 public:
52
56 explicit cStringParImpl() {}
57
61 cStringParImpl(const cStringParImpl& other) : cParImpl(other) {copy(other);}
62
66 virtual ~cStringParImpl();
67
71 void operator=(const cStringParImpl& otherpar);
73
76
80 virtual cStringParImpl *dup() const override {return new cStringParImpl(*this);}
82
85
89 virtual void setEnumValues(const std::vector<std::string>& values);
90
94 virtual std::vector<std::string> getEnumValues() const;
96
99
103 virtual void setBoolValue(bool b) override;
104
108 virtual void setIntValue(intval_t l) override;
109
113 virtual void setDoubleValue(double d) override;
114
118 virtual void setStringValue(const char *s) override;
119
123 virtual void setObjectValue(cObject *object) override;
124
128 virtual void setXMLValue(cXMLElement *node) override;
129
134 virtual void setExpression(cExpression *e) override;
136
139
143 virtual bool boolValue(cComponent *context, const cPar *targetPar) const override;
144
148 virtual intval_t intValue(cComponent *context, const cPar *targetPar) const override;
149
153 virtual double doubleValue(cComponent *context, const cPar *targetPar) const override;
154
158 virtual const char *stringValue(cComponent *context, const cPar *targetPar) const override;
159
163 virtual std::string stdstringValue(cComponent *context, const cPar *targetPar) const override;
164
168 virtual cObject *objectValue(cComponent *context, const cPar *targetPar) const override;
169
173 virtual cXMLElement *xmlValue(cComponent *context, const cPar *targetPar) const override;
174
178 virtual cExpression *getExpression() const override;
180
183
187 virtual Type getType() const override;
188
192 virtual bool isNumeric() const override;
194
197
202 virtual void convertToConst(cComponent *context, const cPar *targetPar) override;
203
207 virtual std::string str() const override;
208
212 virtual std::string unparse() const override;
213
217 virtual void parse(const char *text, FileLine loc, const cPar *targetPar) override;
218
222 virtual int compare(const cParImpl *other) const override;
224};
225
226} // namespace internal
227} // namespace omnetpp
228
229#endif
230
231
Definition fileline.h:28
Common base for module and channel classes.
Definition ccomponent.h:51
Abstract base class for expression evaluators.
Definition cexpression.h:34
cObject()
Definition cobject.h:124
Represents a module or channel parameter.
Definition cpar.h:71
Represents an XML element in an XML configuration file.
Definition cxmlelement.h:76
virtual cXMLElement * xmlValue(cComponent *context, const cPar *targetPar) const override
virtual void setXMLValue(cXMLElement *node) override
virtual std::string stdstringValue(cComponent *context, const cPar *targetPar) const override
virtual void setEnumValues(const std::vector< std::string > &values)
cStringParImpl()
Definition cstringparimpl.h:56
virtual bool boolValue(cComponent *context, const cPar *targetPar) const override
virtual cObject * objectValue(cComponent *context, const cPar *targetPar) const override
virtual void setDoubleValue(double d) override
virtual void setIntValue(intval_t l) override
virtual void parse(const char *text, FileLine loc, const cPar *targetPar) override
virtual std::vector< std::string > getEnumValues() const
virtual std::string unparse() const override
virtual void setExpression(cExpression *e) override
virtual double doubleValue(cComponent *context, const cPar *targetPar) const override
virtual const char * stringValue(cComponent *context, const cPar *targetPar) const override
virtual void setStringValue(const char *s) override
virtual int compare(const cParImpl *other) const override
virtual void convertToConst(cComponent *context, const cPar *targetPar) override
virtual void setObjectValue(cObject *object) override
cStringParImpl(const cStringParImpl &other)
Definition cstringparimpl.h:61
virtual std::string str() const override
void operator=(const cStringParImpl &otherpar)
virtual cStringParImpl * dup() const override
Definition cstringparimpl.h:80
virtual cExpression * getExpression() const override
virtual intval_t intValue(cComponent *context, const cPar *targetPar) const override
virtual void setBoolValue(bool b) override
virtual Type getType() const override
virtual bool isNumeric() const override
int64_t intval_t
Signed integer type which is guaranteed to be at least 64 bits wide. It is used throughout the librar...
Definition simkerneldefs.h:101