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

template<class API >
boost::shared_ptr<API> FB::get_jsapi ( const FB::JSObjectPtr jso)

Get a JSAPI-derived interface from a JSObject.

Since
1.4
if (boost::shared_ptr<MyCustomAPI> ptr = FB::get_jsapi<MyCustomAPI>(jsobject)) {
doStuff(ptr);
} else {
// failed ...
}
Returns
Returns a boost::shared_ptr<API> which is empty on failure and non-empty on success.

Definition at line 374 of file JSObject.h.

References ptr_cast().

375  {
376  typedef boost::shared_ptr<API> APIPtr;
377 
378  if (!jso) {
379  return APIPtr();
380  }
381 
382  if (FB::JSAPIPtr jsapi = jso->getJSAPI()) {
383  return FB::ptr_cast<API>(jsapi);
384  }
385 
386  return APIPtr();
387  }
boost::shared_ptr< T > ptr_cast(boost::shared_ptr< U > const &r)
Convenience function for doing a dynamic cast of one boost::shared_ptr to another.
Definition: APITypes.h:339
boost::shared_ptr< FB::JSAPI > JSAPIPtr
Defines an alias for a JSAPI shared_ptr (you should never use a JSAPI* directly)
Definition: APITypes.h:94

Here is the call graph for this function:

  • No labels