5#ifndef MOLYBDEN_JS_VALUE_HPP
6#define MOLYBDEN_JS_VALUE_HPP
12#include "molybden/base/internal/void_t.hpp"
114 explicit operator bool()
const;
121 template <
typename,
typename =
void>
122 struct IsFunctor : std::false_type {};
124 template <
typename T>
125 struct IsFunctor<T, internal::void_t<decltype(&T::operator())>>
130 typename std::enable_if<std::is_floating_point<T>::value ||
131 std::is_integral<T>::value,
132 T*>::type v =
nullptr);
136 typename std::enable_if<
137 std::is_function<
typename std::remove_pointer<T>::type>::value,
138 T*>::type v =
nullptr);
142 typename std::enable_if<IsFunctor<T>::value, T*>::type v =
nullptr);
147 typename std::enable_if<IsFunctor<T>::value, T*>::type v =
nullptr);
148 explicit JsValue(
const char* value);
149 explicit JsValue(
const std::string& value);
150 explicit JsValue(std::string&& value);
152 explicit JsValue(
double value);
153 explicit JsValue(std::shared_ptr<JsObject> value);
154 explicit JsValue(std::shared_ptr<JsProxyObject> value);
156 std::unique_ptr<JsValueImpl> impl_;
A JavaScript value.
Definition js_value.hpp:44
static JsValue from(T &&value)
Constructs a JavaScript value from the convertible C++ one.
Definition js_value_detail.hpp:51
double asNumber() const
Returns the number that the value represents if it does, otherwise it should not be called.
std::shared_ptr< JsProxyObject > asJsProxyObject() const
Returns a JsProxyObject if the value represents a boolean value.
bool isNumber() const
Indicates if the given value represents a number.
JsValue()
Constructs an empty JsValue.
bool isString() const
Indicates if the given value represents a string.
bool isBool() const
Indicates if the given value represents a boolean.
std::shared_ptr< JsObject > asJsObject() const
Returns a JsObject if the value represents a boolean value.
bool isEmpty() const
Returns true if this JsValue does not hold a value (or, equally, represents null or undefined).
bool asBool() const
Returns the boolean that the value represents if it does, otherwise it should not be called.
const std::string & asString() const
Returns the string that the value represents if it does, otherwise it should not be called.