/** * Constructs a Hash type. * @param key_type The key type of the hash. Defaults to the Scalar type. * @param element_type The element type of the hash. Defaults to the Data type. * @param from The "from" type parameter. * @param to The "to" type parameter. */ explicit basic_hash(Type key_type = scalar(), Type element_type = data(), int64_t from = std::numeric_limits<int64_t>::min(), int64_t to = std::numeric_limits<int64_t>::max()) : _key_type(rvalue_cast(key_type)), _element_type(rvalue_cast(element_type)), _from(from), _to(to) { }
T mutate_as(value& v) { // Check for variable first if (boost::get<variable>(&v)) { return boost::get<T>(dereference(v)); } // Move the value return rvalue_cast(boost::get<T>(v)); }
T move_as() { if (auto var = boost::get<variable>(this)) { value copy = var->value(); return copy.move_as<T>(); } // Move this value return rvalue_cast(boost::get<T>(*this)); }
/** * Constructs a Struct type. * @param types The types that make up the struct. */ explicit basic_struct(std::unordered_map<std::string, Type> types = std::unordered_map<std::string, Type>()) : _types(rvalue_cast(types)) { }
val(T&& obj) : _obj(rvalue_cast(obj)) {}
/** * Constructs a Variant type. * @param types The types that make up the variant. */ explicit basic_variant(std::vector<Type> types = std::vector<Type>()) : _types(rvalue_cast(types)) { }
/** * Constructs a lexer exception. * @param message The lexer exception message. * @param begin The beginning iterator where lexing failed. * @param end The ending iterator (exclusive) where lexing failed. */ lexer_exception(std::string const& message, Iterator begin, Iterator end) : std::runtime_error(message), _begin(rvalue_cast(begin)), _end(rvalue_cast(end)) { }
parse_exception(boost::spirit::x3::expectation_failure<Iterator> const& ex, lexer::position begin, lexer::position end) : parse_exception(format_message(ex.which(), static_cast<lexer::token_id>(ex.where()->id())), rvalue_cast(begin), rvalue_cast(end)) { }
ActionMap &addMap(std::string key) { auto ret = std::make_shared<ActionMap>(key, this); add(rvalue_cast(key), ret); return *ret; }
Type &addAction(std::string key = Type::title()) { auto ret = std::make_shared<Type>(key, this); add(rvalue_cast(key), ret); return *ret; }
ActionMap(std::string id = "", ActionMap *parent = nullptr) : ActionElement(rvalue_cast(id), parent) {}
value& operator=(T&& value) { value_base::operator=(rvalue_cast(value)); return *this; }
value(T&& value) noexcept : value_base(rvalue_cast(value)) { }