void PropertySet::SetString(const String &sPropertyName, const String &sValue) { std::shared_ptr<Property> pProperty = GetProperty_(sPropertyName); bool bChanged = sValue != pProperty->GetStringValue(); pProperty->SetStringValue(sValue); if (bChanged) OnPropertyChanged_(pProperty); }
bool ScriptInterface::GetProperty(JS::HandleValue obj, const char* name, JS::MutableHandleObject out) { JSContext* cx = GetContext(); JSAutoRequest rq(cx); JS::RootedValue val(cx); if (!GetProperty_(obj, name, &val)) return false; if (!val.isObject()) { LOGERROR("GetProperty failed: trying to get an object, but the property is not an object!"); return false; } out.set(&val.toObject()); return true; }
bool PropertySet::XMLLoad(XNode *pBackupNode) { XNode *pPropertiesNode = pBackupNode->GetChild(_T("Properties")); if (!pPropertiesNode) return true; for (int i = 0; i < pPropertiesNode->GetChildCount(); i++) { XNode *pPropertyNode = pPropertiesNode->GetChild(i); String sName = pPropertyNode->name; String sStringValue = pPropertyNode->GetAttrValue(_T("StringValue")); int iLongValue = _ttoi(pPropertyNode->GetAttrValue(_T("LongValue"))); std::shared_ptr<Property> pProperty = GetProperty_(sName); if (pProperty) { pProperty->SetStringValue(sStringValue); pProperty->SetLongValue(iLongValue); } } return true; }
long PropertySet::GetLong(const String &sPropertyName) { return GetProperty_(sPropertyName)->GetLongValue(); }
bool PropertySet::GetBool(const String &sPropertyName) { return GetProperty_(sPropertyName)->GetBoolValue(); }
bool ScriptInterface::GetProperty(JS::HandleValue obj, const char* name, JS::MutableHandleValue out) { return GetProperty_(obj, name, out); }