'; $lib = NULL; $category = NULL; foreach ( $values as $key => $val ) { if ($val['tag'] == 'category' && $val['type'] == 'open' && !$lib && !$category) { $category = isset($val['attributes']) ? $val['attributes'] : array(); } else if($val['tag'] == 'title' && $category) { $category['title'] = isset($val['value']) ? trim($val['value']) : ''; } else if ($val['tag'] == 'category' && $val['type'] == 'close' && $category) { $this->categories[$category['name']] = $category; $category = NULL; } else if ($val['tag'] == 'library' && $val['type'] == 'open') { $lib = array(); } else if ($val['type'] == 'complete') { switch ($val['tag']) { case 'key': case 'name': case 'authors': case 'description': case 'documentation': case 'status': { if (isset($val['value'])) { $lib[$val['tag']] = trim($val['value']); } else { $lib[$val['tag']] = ''; } } break; case 'boost-version': case 'boost-min-version': case 'boost-max-version': { if (isset($val['value'])) { $lib[$val['tag']] = BoostVersion::from($val['value']); } else { $lib[$val['tag']] = ''; } } break; case 'std-proposal': case 'std-tr1': { $value = isset($val['value']) ? trim($val['value']) : false; if($value && $value != 'true' && $value != 'false') { echo 'Invalid value for ',htmlentities($val['tag']), ': ', $value, "\n"; exit(0); } $lib[$val['tag']] = ($value == 'true'); } break; case 'category': { if(isset($val['value'])) { $name = trim($val['value']); $lib['category'][] = $name; } } break; default: echo 'Invalid tag: ', htmlentities($val['tag']), "\n"; exit(0); } } else if ($val['tag'] == 'library' && $val['type'] == 'close' && $lib) { $key_base = $key = $lib['key']; $count = 0; while (isset($this->db[$key])) { $key = $key_base.(++$count); } $this->db[$key] = $lib; $lib = NULL; } } } function get($sort = null, $filter = null) { $libs = $filter ? array_filter($this->db, $filter) : $this->db; // Strip out the array keys, as they shouldn't be used externally. $libs = array_values($libs); if($sort) { uasort($libs, sort_by_field($sort)); } return $libs; } function get_categorized($sort = null, $filter = null) { $libs = $this->get($sort, $filter); $categories = $this->categories; foreach($libs as $key => $library) { foreach($library['category'] as $category) { if(!isset($this->categories[$category])) { echo 'Unknown category: ', htmlentities($category), "\n"; exit(0); } $categories[$category]['libraries'][] = $library; } } return $categories; } function get_categories() { return $this->categories; } } ?>