schema_editor/comdel/domain/value.h

67 lines
1.3 KiB
C
Raw Normal View History

2022-03-31 21:20:41 +00:00
#ifndef DOMAIN_VALUE_H
#define DOMAIN_VALUE_H
#include "addressspace.h"
#include <string>
#include <optional>
2022-04-08 17:13:53 +00:00
2022-03-31 21:20:41 +00:00
namespace domain {
class Value
{
public:
enum ValueType {
INT,
STRING,
BOOL,
ADDRESS_SPACE,
ATTRIBUTE_REFERENCE,
WIRE_REFERENCE,
NIL,
2022-03-31 21:20:41 +00:00
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();
2022-04-05 21:48:07 +00:00
void setInt(long long intValue);
void setString(std::string value);
void setBool(bool value);
void setReference(std::string value);
2022-03-31 21:20:41 +00:00
static Value fromInt(long long value);
static Value fromString(std::string value);
static Value fromBool(bool value);
static Value fromNull();
2022-03-31 21:20:41 +00:00
static Value fromAddressSpace(AddressSpace addressSpace);
static Value fromReference(std::string value, ValueType type);
static Value ofType(ValueType type);
};
} // namespace domain
#endif // DOMAIN_VALUE_H