Molybden API
Loading...
Searching...
No Matches
js_array.hpp
1// Copyright (c) 2000-2024 TeamDev. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_JS_ARRAY_HPP
6#define MOLYBDEN_JS_ARRAY_HPP
7
8#include "molybden/js/js_object.hpp"
9
10namespace molybden {
11
12class JsArrayImpl;
13
25class JsArray : public JsObject {
26 public:
27 using Private = JsArrayImpl;
28
29 explicit JsArray(std::unique_ptr<Private> impl);
30 ~JsArray() override;
31
38 JsValue get(uint32_t index);
39
67 template <class T>
68 void set(uint32_t index, T&& value);
69
73 uint32_t length();
74
86 std::vector<JsValue> toVector();
87
88 private:
89 void setValue(uint32_t index, const JsValue& value);
90
91 JsArrayImpl& Impl();
92};
93
94} // namespace molybden
95
96#endif // MOLYBDEN_JS_ARRAY_HPP
A JavaScript array.
Definition js_array.hpp:25
std::vector< JsValue > toVector()
Fetches the JavaScript array values to a vector.
JsValue get(uint32_t index)
Returns the element by the specified index.
uint32_t length()
Returns the length of the JavaScript array.
void set(uint32_t index, T &&value)
Inserts the specified element into the array at the specified index.
Definition js_array_detail.hpp:14
A JavaScript object.
Definition js_object.hpp:26
A JavaScript value.
Definition js_value.hpp:44