Saturday 8 April 2017

How to handle a map argument in a nodejs C++ module

I have a C++ module for nodejs. I need to accept a key/value pair as argument for a method. Not sure what to do after this:

void MyClient::AcceptData(const FunctionCallbackInfo<Value>& args)
{
    Isolate* isolate = args.GetIsolate();

    if (args.Length() != 1)
    {
        isolate->ThrowException(v8::Exception::TypeError(String::NewFromUtf8(isolate,
            "Usage: Key/Value Map")));
        return;
    }

    if (!args[0]->IsMap())
    {
        isolate->ThrowException(v8::Exception::TypeError(String::NewFromUtf8(isolate, "Wrong argument")));
        return;
    }

// now what? How do I get a C++ map out of args[0] ?
}



via Sharath

No comments:

Post a Comment