Flutter Engine
tonic::DartConverter< std::vector< T > > Struct Template Reference

#include <dart_converter.h>

Public Types

using ValueType = typename DartConverterTypes< T >::ValueType
 
using ConverterType = typename DartConverterTypes< T >::ConverterType
 

Static Public Member Functions

static Dart_Handle ToDart (const std::vector< ValueType > &val)
 
static void SetReturnValue (Dart_NativeArguments args, const std::vector< ValueType > &val)
 
static std::vector< ValueTypeFromDart (Dart_Handle handle)
 
static std::vector< ValueTypeFromArguments (Dart_NativeArguments args, int index, Dart_Handle &exception)
 

Detailed Description

template<typename T>
struct tonic::DartConverter< std::vector< T > >

Definition at line 362 of file dart_converter.h.

Member Typedef Documentation

◆ ConverterType

template<typename T >
using tonic::DartConverter< std::vector< T > >::ConverterType = typename DartConverterTypes<T>::ConverterType

Definition at line 364 of file dart_converter.h.

◆ ValueType

template<typename T >
using tonic::DartConverter< std::vector< T > >::ValueType = typename DartConverterTypes<T>::ValueType

Definition at line 363 of file dart_converter.h.

Member Function Documentation

◆ FromArguments()

template<typename T >
static std::vector<ValueType> tonic::DartConverter< std::vector< T > >::FromArguments ( Dart_NativeArguments  args,
int  index,
Dart_Handle &  exception 
)
inlinestatic

Definition at line 411 of file dart_converter.h.

413  {
414  return FromDart(Dart_GetNativeArgument(args, index));
415  }
G_BEGIN_DECLS FlValue * args
static std::vector< ValueType > FromDart(Dart_Handle handle)

◆ FromDart()

template<typename T >
static std::vector<ValueType> tonic::DartConverter< std::vector< T > >::FromDart ( Dart_Handle  handle)
inlinestatic

Definition at line 385 of file dart_converter.h.

References length, and TONIC_DCHECK.

385  {
386  std::vector<ValueType> result;
387 
388  if (!Dart_IsList(handle))
389  return result;
390 
391  intptr_t length = 0;
392  Dart_ListLength(handle, &length);
393 
394  if (length == 0)
395  return result;
396 
397  result.reserve(length);
398 
399  std::vector<Dart_Handle> items(length);
400  Dart_Handle items_result =
401  Dart_ListGetRange(handle, 0, length, items.data());
402  TONIC_DCHECK(!Dart_IsError(items_result));
403 
404  for (intptr_t i = 0; i < length; ++i) {
405  TONIC_DCHECK(items[i]);
406  result.push_back(DartConverter<ConverterType>::FromDart(items[i]));
407  }
408  return result;
409  }
#define TONIC_DCHECK
Definition: macros.h:32
size_t length

◆ SetReturnValue()

template<typename T >
static void tonic::DartConverter< std::vector< T > >::SetReturnValue ( Dart_NativeArguments  args,
const std::vector< ValueType > &  val 
)
inlinestatic

Definition at line 380 of file dart_converter.h.

References tonic::ToDart().

381  {
382  Dart_SetReturnValue(args, ToDart(val));
383  }
G_BEGIN_DECLS FlValue * args
static Dart_Handle ToDart(const std::vector< ValueType > &val)

◆ ToDart()

template<typename T >
static Dart_Handle tonic::DartConverter< std::vector< T > >::ToDart ( const std::vector< ValueType > &  val)
inlinestatic

Definition at line 366 of file dart_converter.h.

References tonic::DartListFactory< T, Enable >::NewList().

366  {
367  Dart_Handle list = DartListFactory<ValueType>::NewList(
368  ToDartTypeHandle<ValueType>(), val.size());
369  if (Dart_IsError(list))
370  return list;
371  for (size_t i = 0; i < val.size(); i++) {
372  Dart_Handle result =
373  Dart_ListSetAt(list, i, DartConverter<ConverterType>::ToDart(val[i]));
374  if (Dart_IsError(result))
375  return result;
376  }
377  return list;
378  }
static Dart_Handle NewList(Dart_Handle type_handle, intptr_t length)
Dart_Handle ToDart(const char *val)

The documentation for this struct was generated from the following file: