/** * @brief Set name, value and default value for option * @param [in] name Name of option with full path ("Settings/AutomaticRescan") * @param [in] defaultValue Default value for option. This value * is restored for otion when Reset() is run. * @sa COption::Reset() */ int COption::Init(const String& name, const varprop::VariantValue& defaultValue) { int retVal = COption::OPT_OK; m_strName = name; if (m_strName.empty()) return OPT_ERR; // Dont' check type here since we are initing it! varprop::VT_TYPE inType = defaultValue.GetType(); switch (inType) { case varprop::VT_NULL: retVal = OPT_UNKNOWN_TYPE; break; case varprop::VT_BOOL: m_value.SetBool(defaultValue.GetBool()); m_valueDef.SetBool(defaultValue.GetBool()); break; case varprop::VT_INT: m_value.SetInt(defaultValue.GetInt()); m_valueDef.SetInt(defaultValue.GetInt()); break; case varprop::VT_FLOAT: m_value.SetFloat(defaultValue.GetFloat()); m_valueDef.SetFloat(defaultValue.GetFloat()); break; case varprop::VT_STRING: m_value.SetString(defaultValue.GetString()); m_valueDef.SetString(defaultValue.GetString()); break; case varprop::VT_TIME: m_value.SetTime(defaultValue.GetTime()); m_valueDef.SetTime(defaultValue.GetTime()); break; default: retVal = OPT_UNKNOWN_TYPE; } return retVal; }