getNamedValue method

JsonValue? getNamedValue(
  1. String name
)

Implementation

JsonValue? getNamedValue(String name) {
  final retValuePtr = calloc<COMObject>();
  final nameHstring = convertToHString(name);

  final hr = ptr.ref.vtable
          .elementAt(6)
          .cast<
              Pointer<
                  NativeFunction<
                      HRESULT Function(
                          Pointer, IntPtr name, Pointer<COMObject>)>>>()
          .value
          .asFunction<int Function(Pointer, int name, Pointer<COMObject>)>()(
      ptr.ref.lpVtbl, nameHstring, retValuePtr);

  if (FAILED(hr)) {
    free(retValuePtr);
    throw WindowsException(hr);
  }

  WindowsDeleteString(nameHstring);

  if (retValuePtr.ref.lpVtbl == nullptr) {
    free(retValuePtr);
    return null;
  }

  return JsonValue.fromRawPointer(retValuePtr);
}