59 lines
1.1 KiB
C
59 lines
1.1 KiB
C
|
#ifndef DOMAIN_VALUE_H
|
||
|
#define DOMAIN_VALUE_H
|
||
|
|
||
|
#include "addressspace.h"
|
||
|
|
||
|
#include <string>
|
||
|
#include <optional>
|
||
|
|
||
|
namespace domain {
|
||
|
|
||
|
class Value
|
||
|
{
|
||
|
public:
|
||
|
enum ValueType {
|
||
|
INT,
|
||
|
STRING,
|
||
|
BOOL,
|
||
|
ADDRESS_SPACE,
|
||
|
ATTRIBUTE_REFERENCE,
|
||
|
WIRE_REFERENCE,
|
||
|
UNDEFINED,
|
||
|
};
|
||
|
|
||
|
private:
|
||
|
long long intValue;
|
||
|
std::string stringValue;
|
||
|
bool boolValue;
|
||
|
std::optional<AddressSpace> addressSpace;
|
||
|
std::string reference;
|
||
|
|
||
|
ValueType type;
|
||
|
|
||
|
public:
|
||
|
|
||
|
Value() {
|
||
|
this->type = UNDEFINED;
|
||
|
}
|
||
|
|
||
|
ValueType getType();
|
||
|
bool isType(ValueType type);
|
||
|
|
||
|
long long asInt();
|
||
|
std::string asString();
|
||
|
bool asBool();
|
||
|
std::string asReference();
|
||
|
AddressSpace asAddressSpace();
|
||
|
|
||
|
static Value fromInt(long long value);
|
||
|
static Value fromString(std::string value);
|
||
|
static Value fromBool(bool value);
|
||
|
static Value fromAddressSpace(AddressSpace addressSpace);
|
||
|
static Value fromReference(std::string value, ValueType type);
|
||
|
static Value ofType(ValueType type);
|
||
|
};
|
||
|
|
||
|
} // namespace domain
|
||
|
|
||
|
#endif // DOMAIN_VALUE_H
|