Skip to content
Browse files

cleaned up GetExtElements and make available outside the addon manager

  • Loading branch information...
1 parent 2fb6892 commit 6cc382eb0fad37fa669a891f64040b4448540ef8 Jonathan Marshall committed Feb 19, 2011
Showing with 18 additions and 19 deletions.
  1. +9 −17 xbmc/addons/AddonManager.cpp
  2. +9 −2 xbmc/addons/AddonManager.h
View
26 xbmc/addons/AddonManager.cpp
@@ -55,7 +55,6 @@ namespace ADDON
cp_log_severity_t clog_to_cp(int lvl);
void cp_fatalErrorHandler(const char *msg);
void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
-bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path);
/**********************************************************
* CAddonMgr
@@ -149,12 +148,11 @@ bool CAddonMgr::CheckUserDirs(const cp_cfg_element_t *settings)
if (!userdirs)
return false;
- DEQUEELEMENTS elements;
- bool status = GetExtElementDeque(elements, (cp_cfg_element_t *)userdirs, "userdir");
- if (!status)
+ ELEMENTS elements;
+ if (!GetExtElements((cp_cfg_element_t *)userdirs, "userdir", elements))
return false;
- IDEQUEELEMENTS itr = elements.begin();
+ ELEMENTS::iterator itr = elements.begin();
while (itr != elements.end())
{
CStdString path = GetExtValue(*itr++, "@path");
@@ -550,25 +548,19 @@ const cp_cfg_element_t *CAddonMgr::GetExtElement(cp_cfg_element_t *base, const c
return element;
}
-/* Returns all duplicate elements from a base element */
-bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path)
+bool CAddonMgr::GetExtElements(cp_cfg_element_t *base, const char *path, ELEMENTS &elements)
{
- if (!base)
+ if (!base || !path)
return false;
- unsigned int i = 0;
- while (true)
+ for (unsigned int i = 0; i < base->num_children; i++)
{
- if (i >= base->num_children)
- break;
- CStdString temp = (base->children+i)->name;
+ CStdString temp = base->children[i].name;
if (!temp.compare(path))
- elements.push_back(base->children+i);
- i++;
+ elements.push_back(&base->children[i]);
}
- if (elements.empty()) return false;
- return true;
+ return !elements.empty();
}
const cp_extension_t *CAddonMgr::GetExtension(const cp_plugin_info_t *props, const char *extension) const
View
11 xbmc/addons/AddonManager.h
@@ -37,8 +37,7 @@ namespace ADDON
{
typedef std::map<TYPE, VECADDONS> MAPADDONS;
typedef std::map<TYPE, VECADDONS>::iterator IMAPADDONS;
- typedef std::deque<cp_cfg_element_t*> DEQUEELEMENTS;
- typedef std::deque<cp_cfg_element_t*>::iterator IDEQUEELEMENTS;
+ typedef std::vector<cp_cfg_element_t*> ELEMENTS;
const CStdString ADDON_METAFILE = "description.xml";
const CStdString ADDON_VIS_EXT = "*.vis";
@@ -114,6 +113,14 @@ namespace ADDON
/* libcpluff */
CStdString GetExtValue(cp_cfg_element_t *base, const char *path);
+ /*! \brief Retrieve a vector of repeated elements from a given configuration element
+ \param base the base configuration element.
+ \param path the path to the configuration element from the base element.
+ \param result [out] returned list of elements.
+ \return true if the configuration element is present and the list of elements is non-empty
+ */
+ bool GetExtElements(cp_cfg_element_t *base, const char *path, ELEMENTS &result);
+
/*! \brief Retrieve a list of strings from a given configuration element
Assumes the configuration element or attribute contains a whitespace separated list of values (eg xs:list schema).
\param base the base configuration element.

0 comments on commit 6cc382e

Please sign in to comment.
Something went wrong with that request. Please try again.