|
Molybden
|
A JavaScript value. More...
#include <js_value.hpp>
Public Member Functions | |
| JsValue () | |
Constructs an empty JsValue. | |
| bool | isEmpty () const |
Returns true if this JsValue does not hold a value (or, equally, represents null or undefined). | |
| const std::string & | asString () const |
| Returns the string that the value represents if it does, otherwise it should not be called. | |
| bool | isString () const |
| Indicates if the given value represents a string. | |
| double | asNumber () const |
| Returns the number that the value represents if it does, otherwise it should not be called. | |
| bool | isNumber () const |
| Indicates if the given value represents a number. | |
| bool | asBool () const |
| Returns the boolean that the value represents if it does, otherwise it should not be called. | |
| 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. | |
| std::shared_ptr< JsProxyObject > | asJsProxyObject () const |
Returns a JsProxyObject if the value represents a boolean value. | |
| operator bool () const | |
| Indicates whether the value is empty. | |
| JsValue (const JsValue &other) | |
| JsValue (JsValue &&other) | |
Static Public Member Functions | |
| template<class T > | |
| static JsValue | from (T &&value) |
| Constructs a JavaScript value from the convertible C++ one. | |
A JavaScript value.
This class stores C++ values that are convertible to JavaScript ones.
The type mapping rules are the following:
| C++ | JavaScript |
|---|---|
| double | Double |
| std::string | String |
| bool | Boolean |
| std::shared_ptr<SomeJsObject> | Object |
| std::shared_ptr<JsArray> | Array |
| std::shared_ptr<SomeJsProxyObject> | Proxy Object |
where
SomeJsObject is JsObject or derived;SomeJsProxyObject is JsProxyObject or derived.Other types cannot be automatically converted to JavaScript values, and first must be converted to one of the types above.
|
static |
Constructs a JavaScript value from the convertible C++ one.
| T | the type of the C++ value. |
| value | the C++ value. |
JsValue that represents the given C++ value.