<?php // just create from the proto file a pb_prot[NAME].php file require_once '../../parser/pb_parser.php'; $test = new PBParser(); $test->parse('./primitive.proto'); var_dump('File parsing done!');
<?php require_once 'parser/pb_parser.php'; $test = new PBParser(); $test->parse('kiteq.proto');
<?php /** * Run with drush scr */ // just create from the proto file a pb_prot[NAME].php file $pb4php_path = libraries_get_path('pb4php') . '/parser/pb_parser.php'; print "pb4php path: {$pb4php_path}\n"; if (!file_exists($pb4php_path)) { die('Could not find pb4php'); } require_once $pb4php_path; $tzbase_path = drupal_get_path('module', 'tzbase'); $pbfilename = $tzbase_path . '/pb_proto_tzbase.php'; print "tzbase path: {$tzbase_path}\n"; $parser = new PBParser(); $parser->parse($tzbase_path . '/tzbase.proto', $pbfilename); print "Output written to: {$pbfilename}\n";
<?php require_once __DIR__ . '/parser/pb_parser.php'; $rdbProtocolParser = new \PBParser(); $rdbProtocolParser->parse(__DIR__ . '/ql2.proto', 'r\\ProtocolBuffer', __DIR__ . '/../rdb/ProtocolBuffer');
/** * Parses the message * @param String $string the proton file as string */ private function _parse_message_type(&$string, $m_name, $path = '') { $myarray = array(); $string = trim($string); if ($string == '') { return; } //var_dump($m_name); while (strlen($string) > 0) { $next = $this->_next($string); if (strtolower($next) == 'message') { $string = trim(substr($string, strlen($next))); $name = $this->_next($string); $offset = $this->_get_begin_end($string, "{", "}"); // now extract the content and call parse_message again $content = trim(substr($string, $offset['begin'] + 1, $offset['end'] - $offset['begin'] - 2)); $this->_parse_message_type($content, $name, trim($path . '.' . $name, '.')); $string = '' . trim(substr($string, $offset['end'])); } else { if (strtolower($next) == 'enum') { $string = trim(substr($string, strlen($next))); $name = $this->_next($string); $offset = $this->_get_begin_end($string, "{", "}"); // now extract the content and call parse_message again $content = trim(substr($string, $offset['begin'] + 1, $offset['end'] - $offset['begin'] - 2)); // now adding all to myarray $newName = trim($path . '.' . $name, '.'); $this->m_types[$newName] = array('name' => $newName, 'type' => 'enum', 'value' => $this->_parse_enum($content)); // removing it from string $string = '' . trim(substr($string, $offset['end'])); } else { if (strtolower($next) == 'package') { $string = trim(substr($string, strlen($next))); $name = $this->_next($string); // Use namespace only if php 5.3 or newer if ($this->isPHP5_3) { $this->namespace = str_replace(".", "\\\\", trim($name, ";")); } //ignoring // removing it from string $offset = strlen($name); $string = '' . trim(substr($string, $offset)); } else { if (strtolower($next) == 'import') { $name = $this->_next($string); $match = preg_match('/"([^"]+)";*\\s?/', $string, $matches, PREG_OFFSET_CAPTURE); if (!$match) { throw new Exception('Malformed include / look at your import statement:' . $string); } $fn = $matches[1][0]; if (!file_exists($fn)) { throw new Exception("Included file '{$fn}' does not exist"); } $string = trim(substr($string, $matches[0][1] + strlen($matches[0][0]))); // parse the imported file $pbp = new PBParser(); $pbp->parse($fn); // ad the parser to parser array $this->parsers[] = $pbp; // add imported message types so PBParser knows about them $this->m_types_imported = array_merge($this->m_types_imported, $pbp->m_types); $this->requires[] = $pbp->created_php_file_name; } else { // now a normal field $match = preg_match('/(.*);\\s?/', $string, $matches, PREG_OFFSET_CAPTURE); if (!$match) { throw new Exception('Proto file missformed'); } $myarray[] = array('type' => 'field', 'value' => $this->_parse_field($matches[0][0], $myarray, $path)); $string = trim(substr($string, $matches[0][1] + strlen($matches[0][0]))); } } } } } // now adding myarray to array $this->m_types[$path] = array('name' => $path, 'type' => 'message', 'value' => $myarray); }
<?php // just create from the proto file a pb_prot[NAME].php file require_once '../../parser/pb_parser.php'; $test = new PBParser(); $test->parse('./nested.proto'); var_dump('File parsing done!');
<?php // just create from the proto file a pb_prot[NAME].php file require_once '../parser/pb_parser.php'; $test = new PBParser(); $test->parse('./test.proto'); $test = new PBParser(); $test->parse('./test_new.proto'); var_dump('File parsing done!');
<?php require_once "./pb_parser.php"; $parser = new PBParser(); $parser->parse("../copiesonly/weibousers_protos.proto"); echo "done\n";
<?php // just create from the proto file a pb_prot[NAME].php file require_once '../../../parser/pb_parser.php'; $test = new PBParser(); $test->parse('./userdata.proto'); var_dump('File parsing done!');
<?php require_once '../pb4php/parser/pb_parser.php'; $rdbProtocolParser = new \PBParser(); $rdbProtocolParser->parse('../rdb/ql2.proto', 'r\\pb');
<?php /** * Created by PhpStorm. * User: Administrator * Date: 15-6-3 * Time: 下午10:07 */ require_once '../parser/pb_parser.php'; $test = new PBParser(); $test->parse('./performance.proto');
function asset_admin_proto_to_class($proto_file = NULL) { require_once 'libraries/protocolbuf/parser/pb_parser.php'; if (!isset($proto_file)) { $proto_file = func_arg(0); } $proto_file = "user_generated_data/proto/" . $proto_file; $test = new PBParser(); if (file_exists($proto_file)) { $test->parse($proto_file, 'user_generated_data/proto/'); echo 'File parsing done!'; } else { echo 'Stupid'; } }
<?php // just create from the proto file a pb_prot[NAME].php file require_once '../parser/pb_parser.php'; $test = new PBParser(); //$test->parse('./StoryRequest.proto'); //$test = new PBParser(); //$test->parse('./StoryResponse.proto'); // $test->parse('./Kroto.proto'); $proto_file = $_REQUEST['proto']; if ($proto_file) { $test->parse($proto_file); var_dump('File parsing done!'); } else { echo 'Stupid'; }
<?php // just create from the proto file a pb_prot[NAME].php file require_once __DIR__ . '/../parser/pb_parser.php'; array_shift($argv); $test = new PBParser(); while ($filename = array_shift($argv)) { echo $filename, "\n"; $test->parse($filename); echo "parsing {$filename} ...\n"; } echo "File parsing done!\n";