double value support
This commit is contained in:
parent
9e541031fd
commit
105e708d42
@ -84,7 +84,7 @@ class lambda {
|
||||
};
|
||||
|
||||
using node = boost::make_recursive_variant<
|
||||
std::nullptr_t, std::string, int, bool, lambda,
|
||||
std::nullptr_t, std::string, int, double, bool, lambda,
|
||||
std::shared_ptr<internal::object_t<boost::recursive_variant_>>,
|
||||
std::map<const std::string, boost::recursive_variant_>,
|
||||
std::vector<boost::recursive_variant_>>::type;
|
||||
|
@ -24,6 +24,11 @@ inline bool is_node_empty::operator()(const int& value) const {
|
||||
return value == 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool is_node_empty::operator()(const double& value) const {
|
||||
return value == 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool is_node_empty::operator()(const bool& value) const {
|
||||
return !value;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <sstream>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
#include "mstch/mstch.hpp"
|
||||
@ -27,6 +28,13 @@ inline std::string render_node::operator()(const int& value) const {
|
||||
return std::to_string(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string render_node::operator()(const double& value) const {
|
||||
std::stringstream ss;
|
||||
ss << value;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string render_node::operator()(const bool& value) const {
|
||||
return value?"true":"false";
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
}
|
||||
|
||||
mstch::node vat() {
|
||||
return static_cast<int>(m_value * 0.2);
|
||||
return m_value * 0.2;
|
||||
}
|
||||
|
||||
mstch::node currency() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
class partial_view: public mstch::object {
|
||||
private:
|
||||
int m_value;
|
||||
|
||||
public:
|
||||
partial_view(): m_value{10000} {
|
||||
register_methods(this, {
|
||||
@ -30,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
mstch::node taxed_value() {
|
||||
return static_cast<int>(m_value - (m_value * 0.4));
|
||||
return m_value - (m_value * 0.4);
|
||||
}
|
||||
|
||||
mstch::node in_ca() {
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
}
|
||||
|
||||
mstch::node taxed_value() {
|
||||
return static_cast<int>(m_value - (m_value * 0.4));
|
||||
return m_value - (m_value * 0.4);
|
||||
}
|
||||
|
||||
mstch::node in_ca() {
|
||||
|
Loading…
Reference in New Issue
Block a user