1.1 --- a/tools/profiler/php/ProfFileParser.class.php Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,73 +0,0 @@
1.4 -<?php
1.5 -
1.6 -class ProfReport
1.7 -{
1.8 - public $time;
1.9 - public $uptime;
1.10 - public $items = array();
1.11 -}
1.12 -
1.13 -class ProfReportParser
1.14 -{
1.15 - private $report;
1.16 - private $curtype;
1.17 - public $last_error;
1.18 -
1.19 - public function Parse($file)
1.20 - {
1.21 - $this->report = FALSE;
1.22 - $this->curtype = FALSE;
1.23 -
1.24 - if (($contents = file_get_contents($file)) === FALSE)
1.25 - {
1.26 - $this->last_error = 'File not found';
1.27 - return FALSE;
1.28 - }
1.29 -
1.30 - $xml = xml_parser_create();
1.31 - xml_set_object($xml, $this);
1.32 - xml_set_element_handler($xml, 'tag_open', 'tag_close');
1.33 - xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, false);
1.34 -
1.35 - if (!xml_parse($xml, $contents))
1.36 - {
1.37 - $this->last_error = 'Line: ' . xml_get_current_line_number($xml) . ' -- ' . xml_error_string(xml_get_error_code($xml));
1.38 - return FALSE;
1.39 - }
1.40 -
1.41 - return $this->report;
1.42 - }
1.43 -
1.44 - public function tag_open($parser, $tag, $attrs)
1.45 - {
1.46 - if ($tag == 'profile')
1.47 - {
1.48 - $this->report = new ProfReport();
1.49 - $this->report->time = $attrs['time'];
1.50 - $this->report->uptime = $attrs['uptime'];
1.51 - }
1.52 - else if ($tag == 'report')
1.53 - {
1.54 - $this->curtype = $attrs['name'];
1.55 - }
1.56 - else if ($tag == 'item')
1.57 - {
1.58 - if ($this->report === FALSE || $this->curtype === FALSE)
1.59 - {
1.60 - return;
1.61 - }
1.62 - $attrs['type'] = $this->curtype;
1.63 - $this->report->items[] = $attrs;
1.64 - }
1.65 - }
1.66 -
1.67 - public function tag_close($parser, $tag)
1.68 - {
1.69 - if ($tag == 'report')
1.70 - {
1.71 - $this->curtype = FALSE;
1.72 - }
1.73 - }
1.74 -}
1.75 -
1.76 -?>