Exemplo n.º 1
0
bool CSettingCategory::Deserialize(const TiXmlNode *node, bool update /* = false */)
{
  // handle <visible> conditions
  if (!ISetting::Deserialize(node, update))
    return false;
    
  const TiXmlElement *element = node->ToElement();
  if (element == NULL)
    return false;
    
  int tmp = -1;
  if (element->QueryIntAttribute(XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0)
    m_label = tmp;
  if (element->QueryIntAttribute(XML_ATTR_HELP, &m_help) == TIXML_SUCCESS && m_help > 0)
    m_help = tmp;

  const TiXmlNode *accessNode = node->FirstChild("access");
  if (accessNode != NULL && !m_accessCondition.Deserialize(accessNode))
    return false;
    
  const TiXmlNode *groupNode = node->FirstChildElement(XML_GROUP);
  while (groupNode != NULL)
  {
    std::string groupId;
    if (CSettingGroup::DeserializeIdentification(groupNode, groupId))
    {
      CSettingGroup *group = NULL;
      for (SettingGroupList::iterator itGroup = m_groups.begin(); itGroup != m_groups.end(); itGroup++)
      {
        if ((*itGroup)->GetId() == groupId)
        {
          group = *itGroup;
          break;
        }
      }
      
      update = (group != NULL);
      if (!update)
        group = new CSettingGroup(groupId, m_settingsManager);

      if (group->Deserialize(groupNode, update))
      {
        if (!update)
          addISetting(groupNode, group, m_groups);
      }
      else
      {
        CLog::Log(LOGWARNING, "CSettingCategory: unable to read group \"%s\"", groupId.c_str());
        if (!update)
          delete group;
      }
    }
      
    groupNode = groupNode->NextSibling(XML_GROUP);
  }
    
  return true;
}
Exemplo n.º 2
0
bool CSettingGroup::Deserialize(const TiXmlNode *node, bool update /* = false */)
{
  // handle <visible> conditions
  if (!ISetting::Deserialize(node, update))
    return false;

  const TiXmlElement *settingElement = node->FirstChildElement(XML_SETTING);
  while (settingElement != NULL)
  {
    std::string settingId;
    if (CSettingCategory::DeserializeIdentification(settingElement, settingId))
    {
      CSetting *setting = NULL;
      for (SettingList::iterator itSetting = m_settings.begin(); itSetting != m_settings.end(); itSetting++)
      {
        if ((*itSetting)->GetId() == settingId)
        {
          setting = *itSetting;
          break;
        }
      }
      
      update = (setting != NULL);
      if (!update)
      {
        const char* settingType = settingElement->Attribute(XML_ATTR_TYPE);
        if (settingType == NULL || strlen(settingType) <= 0)
        {
          CLog::Log(LOGERROR, "CSettingGroup: unable to read setting type of \"%s\"", settingId.c_str());
          return false;
        }

        setting = m_settingsManager->CreateSetting(settingType, settingId, m_settingsManager);
        if (setting == NULL)
          CLog::Log(LOGERROR, "CSettingGroup: unknown setting type \"%s\" of \"%s\"", settingType, settingId.c_str());
      }
      
      if (setting == NULL)
        CLog::Log(LOGERROR, "CSettingGroup: unable to create new setting \"%s\"", settingId.c_str());
      else if (!setting->Deserialize(settingElement, update))
      {
        CLog::Log(LOGWARNING, "CSettingGroup: unable to read setting \"%s\"", settingId.c_str());
        if (!update)
          delete setting;
      }
      else if (!update)
        addISetting(settingElement, setting, m_settings);
    }
      
    settingElement = settingElement->NextSiblingElement(XML_SETTING);
  }
    
  return true;
}
Exemplo n.º 3
0
bool CSettingSection::Deserialize(const TiXmlNode *node, bool update /* = false */)
{
  // handle <visible> conditions
  if (!ISetting::Deserialize(node, update))
    return false;
    
  const TiXmlElement *element = node->ToElement();
  if (element == NULL)
    return false;

  int tmp = -1;
  if (element->QueryIntAttribute(XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0)
    m_label = tmp;
  if (element->QueryIntAttribute(XML_ATTR_HELP, &tmp) == TIXML_SUCCESS && tmp > 0)
    m_help = tmp;
    
  const TiXmlNode *categoryNode = node->FirstChild(XML_CATEGORY);
  while (categoryNode != NULL)
  {
    std::string categoryId;
    if (CSettingCategory::DeserializeIdentification(categoryNode, categoryId))
    {
      CSettingCategory *category = NULL;
      for (SettingCategoryList::iterator itCategory = m_categories.begin(); itCategory != m_categories.end(); itCategory++)
      {
        if ((*itCategory)->GetId() == categoryId)
        {
          category = *itCategory;
          break;
        }
      }
      
      update = (category != NULL);
      if (!update)
        category = new CSettingCategory(categoryId, m_settingsManager);

      if (category->Deserialize(categoryNode, update))
      {
        if (!update)
          addISetting(categoryNode, category, m_categories);
      }
      else
      {
        CLog::Log(LOGWARNING, "CSettingSection: unable to read category \"%s\"", categoryId.c_str());
        if (!update)
          delete category;
      }
    }
      
    categoryNode = categoryNode->NextSibling(XML_CATEGORY);
  }
    
  return true;
}
Exemplo n.º 4
0
void CSettingSection::AddCategories(const SettingCategoryList &categories)
{
  for (SettingCategoryList::const_iterator itCategory = categories.begin(); itCategory != categories.end(); ++itCategory)
    addISetting(NULL, *itCategory, m_categories);
}
Exemplo n.º 5
0
void CSettingSection::AddCategory(CSettingCategory *category)
{
  addISetting(NULL, category, m_categories);
}
Exemplo n.º 6
0
void CSettingCategory::AddGroups(const SettingGroupList &groups)
{
  for (SettingGroupList::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup)
    addISetting(NULL, *itGroup, m_groups);
}
Exemplo n.º 7
0
void CSettingCategory::AddGroup(CSettingGroup *group)
{
  addISetting(NULL, group, m_groups);
}
Exemplo n.º 8
0
void CSettingGroup::AddSettings(const SettingList &settings)
{
  for (SettingList::const_iterator itSetting = settings.begin(); itSetting != settings.end(); ++itSetting)
    addISetting(NULL, *itSetting, m_settings);
}
Exemplo n.º 9
0
void CSettingGroup::AddSetting(CSetting *setting)
{
  addISetting(NULL, setting, m_settings);
}