Page tree
Skip to end of metadata
Go to start of metadata

template<class Cont >
void FB::JSObject::GetArrayValues ( const FB::JSObjectPtr src,
Cont &  dst 
)
static

Gets Array values out of src and adds them to the STL container dst.

Parameters
srcSource for the.
[in,out]dstDestination for the.

todo Find a better place for this conversion method. Gotcha to watch out for: has to

be included after variant.h and everywhere where variant::convert_cast<SomeContainer>() is used.

Definition at line 165 of file JSObject.h.

References FB::variant::convert_cast().

166  {
167  if (!src) {
168  return;
169  }
170  try {
171  FB::variant tmp = src->GetProperty("length");
172  long length = tmp.convert_cast<long>();
173  std::back_insert_iterator<Cont> inserter(dst);
174 
175  for(int i=0; i<length; ++i) {
176  tmp = src->GetProperty(i);
177  *inserter++ = tmp.convert_cast<typename Cont::value_type>();
178  }
179  } catch(const FB::script_error& e) {
180  throw e;
181  }
182  }
const T convert_cast() const
Converts the stored value to the requested type if possible and returns the resulting value...
Definition: variant.h:667
Accepts any datatype, used in all interactions with javascript. Provides tools for getting back out t...
Definition: variant.h:198
Exception type; when thrown in a JSAPI method, a javascript exception will be thrown.
Definition: JSExceptions.h:28

Here is the call graph for this function:

  • No labels