29 template<
typename Range>
52 const int len = std::abs(limit -
value_) + 1;
54 std::vector<variant> res;
57 for(
int i =
value_; res.size() != res.capacity();
value_ < limit ? ++
i : --
i) {
66 std::ostringstream ss;
68 int fractional =
value_ % 1000;
69 int integer = (
value_ - fractional) / 1000;
73 if(integer == 0 &&
value_ < 0) {
80 fractional = std::abs(fractional);
82 if(fractional < 100) {
96 : callable_(std::move(callable))
121 std::ostringstream ss;
134 for(
const auto& input : v) {
140 ss << input.name <<
" ";
143 ss <<
"(read-write) ";
145 ss <<
"(writeonly) ";
148 ss <<
"-> " <<
callable_->query_value(input.name).to_debug_string(verbose, &seen);
190 return callable_->query_value(utils::any_cast<const formula_input_vector::const_iterator&>(iter)->name);
195 ++utils::any_cast<formula_input_vector::const_iterator&>(iter);
200 --utils::any_cast<formula_input_vector::const_iterator&>(iter);
205 std::ostringstream ss;
234 template<
typename Func>
237 return std::invoke(op, value);
240 template<
typename Func>
243 std::ostringstream ss;
245 ss << std::invoke(op, value.first);
247 ss << std::invoke(op, value.second);
252 template<
typename Range,
typename Func>
272 template<
typename Range,
typename Func>
273 std::string
to_string(
const Range& range,
const Func& op)
278 template<
typename Range,
typename Func>
285 std::ostringstream ss;
286 ss <<
"[" <<
to_string(range, op) <<
"]";
320 ++as_container_iterator(iter);
326 --as_container_iterator(iter);
332 return as_container_iterator(first) == as_container_iterator(second);
347 return make_callable<key_value_pair>(key, value);
virtual bool equals(const 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
Required by variant_value_base.
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(const variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
Generalized interface for container variants.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
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::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.
static const_iterator & as_container_iterator(utils::any &iter)
Casts opaque iter to a mutable const_iterator reference.
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
Required by variant_value_base.
variant build_range_variant(int limit) const
Iterator class for the variant.
virtual variant deref_iterator(const utils::any &) const override
Required by variant_value_base.
virtual variant deref_iterator(const utils::any &) const override
Required by variant_value_base.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
std::string string_
Required by variant_value_base.
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.
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
Contains the implementation details for lexical_cast and shouldn't be used directly.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::string join(const Range &v, const std::string &s=",")
Generates a new string joining container items in a list.
To & cast_as(To &, From &value)
auto make_serialized_range(const Range &range, const Func &op)
std::string serialize_empty(const std::vector< variant > &)
WFL empty list literal.
std::string serialize_value(const Func &op, const variant &value)
auto make_iterator_range(const variant_value_base *val, const Range &range) -> boost::iterator_range< variant_iterator >
std::string to_string(const Range &range, const Func &op)
std::string as_literal(const Range &range, const Func &op)
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