38 const int len = std::abs(limit -
value_) + 1;
40 std::vector<variant> res;
43 for(
int i =
value_; res.size() != res.capacity();
value_ < limit ? ++
i : --
i) {
52 std::ostringstream ss;
54 int fractional =
value_ % 1000;
55 int integer = (
value_ - fractional) / 1000;
59 if(integer == 0 &&
value_ < 0) {
66 fractional = std::abs(fractional);
68 if(fractional < 100) {
82 : callable_(std::move(callable))
108 std::ostringstream ss;
121 for(
const auto& input : v) {
127 ss << input.name <<
" ";
130 ss <<
"(read-write) ";
132 ss <<
"(writeonly) ";
135 ss <<
"-> " <<
callable_->query_value(input.name).to_debug_string(verbose, &seen);
177 return callable_->query_value(utils::any_cast<const formula_input_vector::const_iterator&>(iter)->name);
182 ++utils::any_cast<formula_input_vector::const_iterator&>(iter);
187 --utils::any_cast<formula_input_vector::const_iterator&>(iter);
192 std::ostringstream ss;
220 std::ostringstream ss;
226 bool first_time =
true;
228 for(
const auto& member : container_) {
235 ss << to_string_detail(member, mod_func);
239 if(annotate_empty && container_.empty()) {
253 return to_string_impl(
false,
false, [](
const variant& v) {
return v.
string_cast(); });
277 ++utils::any_cast<typename T::const_iterator&>(iter);
283 --utils::any_cast<typename T::const_iterator&>(iter);
289 return utils::any_cast<typename T::const_iterator>(first) == utils::any_cast<typename T::const_iterator>(second);
303 const auto& other_list = value_cast<variant_list>(std::move(second));
306 throw type_error(
"List op requires two lists of the same length");
309 std::vector<variant> res;
313 res.push_back(op_func(
get_container()[
i], other_list->get_container()[
i]));
321 const auto& other_container = value_ref_cast<variant_list>(other).get_container();
338 const auto& other_container = value_ref_cast<variant_list>(other).get_container();
353 return *utils::any_cast<const variant_vector::const_iterator&>(iter);
358 std::ostringstream ss;
360 ss << mod_func(container_val.first);
362 ss << mod_func(container_val.second);
369 return get_container() == value_ref_cast<variant_map>(other).get_container();
374 return get_container() < value_ref_cast<variant_map>(other).get_container();
379 const variant_map_raw::value_type&
p = *utils::any_cast<const variant_map_raw::const_iterator&>(iter);
380 auto the_pair = std::make_shared<key_value_pair>(
p.first,
p.second);
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
virtual std::string get_debug_string(formula_seen_stack &seen, bool verbose) const override
Returns debug info for the variant value.
variant_callable(const_formula_callable_ptr callable)
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
virtual variant deref_iterator(const utils::any &iter) const override
Implements the dereference functionality of variant_iterator for a value of this type.
virtual void iterator_inc(utils::any &iter) const override
Implements the increment functionality of variant_iterator for a value of this type.
virtual boost::iterator_range< variant_iterator > make_iterator() const override
Creates an iterator pair that can be used for iteration.
formula_input_vector inputs
virtual void iterator_dec(utils::any &iter) const override
Implements the decrement functionality of variant_iterator for a value of this type.
const_formula_callable_ptr callable_
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
std::string to_string_impl(bool annotate, bool annotate_empty, mod_func_t mod_func) const
Implementation to handle string conversion for string_cast, get_serialized_string,...
virtual std::string string_cast() const override
Returns the stored variant value in plain string form.
virtual void iterator_dec(utils::any &) const override
Implements the decrement functionality of variant_iterator for a value of this type.
virtual std::size_t num_elements() const override
virtual std::string get_debug_string(formula_seen_stack &seen, bool verbose) const override
Returns debug info for the variant value.
virtual boost::iterator_range< variant_iterator > make_iterator() const override
Creates an iterator pair that can be used for iteration.
variant_vector & get_container()
std::function< std::string(const variant &)> mod_func_t
virtual bool iterator_equals(const utils::any &first, const utils::any &second) const override
Implements the equality functionality of variant_iterator for a value of this type.
virtual void iterator_inc(utils::any &) const override
Implements the increment functionality of variant_iterator for a value of this type.
std::string to_string_impl(const bool sign_value) const
variant build_range_variant(int limit) const
Iterator class for the variant.
variant_list(const variant_vector &vec)
virtual variant deref_iterator(const utils::any &) const override
Implements the dereference functionality of variant_iterator for a value of this type.
variant list_op(value_base_ptr second, const std::function< variant(variant &, variant &)> &op_func)
Applies the provided function to the corresponding variants in this and another list.
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
virtual std::string to_string_detail(const variant_map_raw::value_type &container_val, mod_func_t mod_func) const override
virtual variant deref_iterator(const utils::any &) const override
Implements the dereference functionality of variant_iterator for a value of this type.
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
Base class for all variant types.
virtual boost::iterator_range< variant_iterator > make_iterator() const
Creates an iterator pair that can be used for iteration.
virtual variant deref_iterator(const utils::any &iter) const
Implements the dereference functionality of variant_iterator for a value of this type.
virtual std::size_t num_elements() const
Returns the number of elements in a type.
std::string serialize_to_string() const
std::string string_cast() const
std::string to_debug_string(bool verbose=false, formula_seen_stack *seen=nullptr) const
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
std::shared_ptr< variant_value_base > value_base_ptr
std::vector< variant > variant_vector
std::vector< const_formula_callable_ptr > formula_seen_stack
std::vector< formula_input > formula_input_vector
std::shared_ptr< const formula_callable > const_formula_callable_ptr
static map_location::direction n