I'm building a native NodeJS C++ module based on V8. I got the following code in loop:
Local<Array> nodes = Array::New();
/********** INSIDE THE LOOP ************/
Local<Object> node_obj = Object::New();
node_obj->Set(data_symbol, String::New(input.substr(openPos + (lastTag > 1 ? 3 : 2), pos - openPos - (lastTag > 1 ? 3 : 2) - 1).c_str()));
node_obj->Set(tag_symbol, Integer::New(lastTag));
nodes->Set(id, node_obj);
And I'm populating an array with objects, so the output (in JS) will look like this:
[
{tag: 2, data: "asdsadsadasfddgdfgdfg"},
{tag: 1, data: "afg235235232fgdfg"}
]
My questions is how I can append a string to the data_symbol of the last object of the array?
Full code can be found here: http://pastebin.com/tCgWCxyA
Example of what I'm trying to do:
Lets take this structure for example:
struct Node {
short tag;
std::string data;
Node(const std::string& input, short tagId) : tag(tagId), data(input) {}
};
std::vector<Node> elems;
My question is how I can do
elems.back().data.append("SomeString");
in V8?