Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xml attribute tidy up #4971

Merged
merged 13 commits into from Jul 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions xbmc/LangInfo.cpp
Expand Up @@ -35,6 +35,7 @@
#include "utils/StringUtils.h"
#include "utils/Weather.h"
#include "utils/XBMCTinyXML.h"
#include "utils/XMLUtils.h"

using namespace std;
using namespace PVR;
Expand Down Expand Up @@ -279,10 +280,10 @@ bool CLangInfo::Load(const std::string& strFileName, bool onlyCheckLanguage /*=
const TiXmlNode *pCharSets = pRootElement->FirstChild("charsets");
if (pCharSets && !pCharSets->NoChildren())
{
const TiXmlNode *pGui = pCharSets->FirstChild("gui");
const TiXmlElement *pGui = pCharSets->FirstChildElement("gui");
if (pGui && !pGui->NoChildren())
{
CStdString strForceUnicodeFont = ((TiXmlElement*) pGui)->Attribute("unicodefont");
CStdString strForceUnicodeFont = XMLUtils::GetAttribute(pGui, "unicodefont");

if (strForceUnicodeFont.Equals("true"))
m_defaultRegion.m_forceUnicodeFont=true;
Expand Down Expand Up @@ -318,7 +319,7 @@ bool CLangInfo::Load(const std::string& strFileName, bool onlyCheckLanguage /*=
while (pRegion)
{
CRegion region(m_defaultRegion);
region.m_strName=pRegion->Attribute("name");
region.m_strName = XMLUtils::GetAttribute(pRegion, "name");
if (region.m_strName.empty())
region.m_strName="N/A";

Expand Down Expand Up @@ -346,8 +347,8 @@ bool CLangInfo::Load(const std::string& strFileName, bool onlyCheckLanguage /*=
if (pTime && !pTime->NoChildren())
{
region.m_strTimeFormat=pTime->FirstChild()->Value();
region.m_strMeridiemSymbols[MERIDIEM_SYMBOL_AM]=pTime->Attribute("symbolAM");
region.m_strMeridiemSymbols[MERIDIEM_SYMBOL_PM]=pTime->Attribute("symbolPM");
region.m_strMeridiemSymbols[MERIDIEM_SYMBOL_AM] = XMLUtils::GetAttribute(pTime, "symbolAM");
region.m_strMeridiemSymbols[MERIDIEM_SYMBOL_PM] = XMLUtils::GetAttribute(pTime, "symbolPM");
}

const TiXmlNode *pTempUnit=pRegion->FirstChild("tempunit");
Expand Down
25 changes: 13 additions & 12 deletions xbmc/addons/AddonCallbacksAddon.cpp
Expand Up @@ -31,6 +31,7 @@
#include "network/Network.h"
#include "utils/CharsetConverter.h"
#include "utils/StringUtils.h"
#include "utils/XMLUtils.h"
#include "cores/dvdplayer/DVDCodecs/DVDCodecs.h"

using namespace XFILE;
Expand Down Expand Up @@ -196,32 +197,32 @@ bool CAddonCallbacksAddon::GetAddonSetting(void *addonData, const char *strSetti
const TiXmlElement *setting = category->FirstChildElement("setting");
while (setting)
{
const char *id = setting->Attribute("id");
const char *type = setting->Attribute("type");
const std::string id = XMLUtils::GetAttribute(setting, "id");
const std::string type = XMLUtils::GetAttribute(setting, "type");

if (strcmpi(id, strSettingName) == 0 && type)
if (id == strSettingName && !type.empty())
{
if (strcmpi(type, "text") == 0 || strcmpi(type, "ipaddress") == 0 ||
strcmpi(type, "folder") == 0 || strcmpi(type, "action") == 0 ||
strcmpi(type, "music") == 0 || strcmpi(type, "pictures") == 0 ||
strcmpi(type, "folder") == 0 || strcmpi(type, "programs") == 0 ||
strcmpi(type, "file") == 0 || strcmpi(type, "fileenum") == 0)
if (type == "text" || type == "ipaddress" ||
type == "folder" || type == "action" ||
type == "music" || type == "pictures" ||
type == "programs" || type == "fileenum" ||
type == "file")
{
strcpy((char*) settingValue, addonHelper->m_addon->GetSetting(id).c_str());
return true;
}
else if (strcmpi(type, "number") == 0 || strcmpi(type, "enum") == 0 ||
strcmpi(type, "labelenum") == 0)
else if (type == "number" || type == "enum" ||
type == "labelenum")
{
*(int*) settingValue = (int) atoi(addonHelper->m_addon->GetSetting(id));
return true;
}
else if (strcmpi(type, "bool") == 0)
else if (type == "bool")
{
*(bool*) settingValue = (bool) (addonHelper->m_addon->GetSetting(id) == "true" ? true : false);
return true;
}
else if (strcmpi(type, "slider") == 0)
else if (type == "slider")
{
const char *option = setting->Attribute("option");
if (option && strcmpi(option, "int") == 0)
Expand Down
35 changes: 18 additions & 17 deletions xbmc/addons/AddonDll.h
Expand Up @@ -32,6 +32,7 @@
#include "utils/log.h"
#include "interfaces/IAnnouncer.h"
#include "interfaces/AnnouncementManager.h"
#include "utils/XMLUtils.h"

using namespace XFILE;

Expand Down Expand Up @@ -476,39 +477,39 @@ ADDON_STATUS CAddonDll<TheDll, TheStruct, TheProps>::TransferSettings()
{
ADDON_STATUS status = ADDON_STATUS_OK;
const char *id = setting->Attribute("id");
const char *type = setting->Attribute("type");
const std::string type = XMLUtils::GetAttribute(setting, "type");
const char *option = setting->Attribute("option");

if (type)
if (id && !type.empty())
{
if (strcmpi(type,"sep") == 0 || strcmpi(type,"lsep") == 0)
if (type == "sep" || type == "lsep")
{
/* Don't propagate separators */
}
else if (strcmpi(type, "text") == 0 || strcmpi(type, "ipaddress") == 0 ||
strcmpi(type, "video") == 0 || strcmpi(type, "audio") == 0 ||
strcmpi(type, "image") == 0 || strcmpi(type, "folder") == 0 ||
strcmpi(type, "executable") == 0 || strcmpi(type, "file") == 0 ||
strcmpi(type, "action") == 0 || strcmpi(type, "date") == 0 ||
strcmpi(type, "time") == 0 || strcmpi(type, "select") == 0 ||
strcmpi(type, "addon") == 0 || strcmpi(type, "labelenum") == 0 ||
strcmpi(type, "fileenum") == 0 )
else if (type == "text" || type == "ipaddress" ||
type == "video" || type == "audio" ||
type == "image" || type == "folder" ||
type == "executable" || type == "file" ||
type == "action" || type == "date" ||
type == "time" || type == "select" ||
type == "addon" || type == "labelenum" ||
type == "fileenum" )
{
status = m_pDll->SetSetting(id, (const char*) GetSetting(id).c_str());
}
else if ((strcmpi(type, "enum") == 0 || strcmpi(type,"integer") == 0) ||
strcmpi(type, "labelenum") == 0 || strcmpi(type, "rangeofnum") == 0)
else if (type == "enum" || type =="integer" ||
type == "labelenum" || type == "rangeofnum")
{
int tmp = atoi(GetSetting(id));
status = m_pDll->SetSetting(id, (int*) &tmp);
}
else if (strcmpi(type, "bool") == 0)
else if (type == "bool")
{
bool tmp = (GetSetting(id) == "true") ? true : false;
status = m_pDll->SetSetting(id, (bool*) &tmp);
}
else if (strcmpi(type, "rangeofnum") == 0 || strcmpi(type, "slider") == 0 ||
strcmpi(type, "number") == 0)
else if (type == "rangeofnum" || type == "slider" ||
type == "number")
{
float tmpf = (float)atof(GetSetting(id));
int tmpi;
Expand All @@ -526,7 +527,7 @@ ADDON_STATUS CAddonDll<TheDll, TheStruct, TheProps>::TransferSettings()
else
{
/* Log unknowns as an error, but go ahead and transfer the string */
CLog::Log(LOGERROR, "Unknown setting type '%s' for %s", type, Name().c_str());
CLog::Log(LOGERROR, "Unknown setting type '%s' for %s", type.c_str(), Name().c_str());
status = m_pDll->SetSetting(id, (const char*) GetSetting(id).c_str());
}

Expand Down