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
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");
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
{
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";
/* 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.