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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7406 Next »

void FB::JSAPIAuto::SetProperty ( const std::string &  propertyName,
const variant value 
)
virtual

Sets the value of a property.

Parameters
propertyNameName of the property.
valueThe value.

Implements FB::JSAPI.

Definition at line 224 of file JSAPIAuto.cpp.

225 {
226  boost::recursive_mutex::scoped_lock lock(m_zoneMutex);
227  if(!m_valid)
228  throw object_invalidated();
229 
230  PropertyFunctorsMap::iterator it = m_propertyFunctorsMap.find(propertyName);
231  // Note that if an explicit property exists but is not accessible in the current security context,
232  // we throw an exception.
233  if(it != m_propertyFunctorsMap.end()) {
234  if (memberAccessible(m_zoneMap.find(propertyName))) {
235  try {
236  it->second.set(value);
237  } catch (const FB::bad_variant_cast& ex) {
238  std::string errorMsg("Could not convert from ");
239  errorMsg += ex.from;
240  errorMsg += " to ";
241  errorMsg += ex.to;
242  throw FB::invalid_arguments(errorMsg);
243  }
244  } else {
245  throw invalid_member(propertyName);
246  }
247  } else if (m_allowDynamicAttributes || (m_attributes.find(propertyName) != m_attributes.end() && !m_attributes[propertyName].readonly)) {
248  registerAttribute(propertyName, value);
249  } else {
250  throw invalid_member(propertyName);
251  }
252 }
virtual void registerAttribute(const std::string &name, const FB::variant &value, bool readonly=false)
Registers an attribute name and sets the value to _value. Optionally read-only.
Definition: JSAPIAuto.cpp:383
Thrown by a JSAPI object when the argument(s) provided to a SetProperty or Invoke call are found to b...
Definition: JSExceptions.h:47
Thrown when variant::cast<type> or variant::convert_cast<type> fails because the type of the value st...
Definition: variant.h:133
  • No labels