log.proto.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <?php
  2. // Please include the below file before log.proto.php
  3. //require('protocolbuffers.inc.php');
  4. // message Log.Content
  5. class Log_Content {
  6. private $_unknown;
  7. function __construct($in = NULL, &$limit = PHP_INT_MAX) {
  8. if($in !== NULL) {
  9. if (is_string($in)) {
  10. $fp = fopen('php://memory', 'r+b');
  11. fwrite($fp, $in);
  12. rewind($fp);
  13. } else if (is_resource($in)) {
  14. $fp = $in;
  15. } else {
  16. throw new Exception('Invalid in parameter');
  17. }
  18. $this->read($fp, $limit);
  19. }
  20. }
  21. function read($fp, &$limit = PHP_INT_MAX) {
  22. while(!feof($fp) && $limit > 0) {
  23. $tag = Protobuf::read_varint($fp, $limit);
  24. if ($tag === false) break;
  25. $wire = $tag & 0x07;
  26. $field = $tag >> 3;
  27. //var_dump("Log_Content: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
  28. switch($field) {
  29. case 1:
  30. ASSERT('$wire == 2');
  31. $len = Protobuf::read_varint($fp, $limit);
  32. if ($len === false)
  33. throw new Exception('Protobuf::read_varint returned false');
  34. if ($len > 0)
  35. $tmp = fread($fp, $len);
  36. else
  37. $tmp = '';
  38. if ($tmp === false)
  39. throw new Exception("fread($len) returned false");
  40. $this->key_ = $tmp;
  41. $limit-=$len;
  42. break;
  43. case 2:
  44. ASSERT('$wire == 2');
  45. $len = Protobuf::read_varint($fp, $limit);
  46. if ($len === false)
  47. throw new Exception('Protobuf::read_varint returned false');
  48. if ($len > 0)
  49. $tmp = fread($fp, $len);
  50. else
  51. $tmp = '';
  52. if ($tmp === false)
  53. throw new Exception("fread($len) returned false");
  54. $this->value_ = $tmp;
  55. $limit-=$len;
  56. break;
  57. default:
  58. $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
  59. }
  60. }
  61. if (!$this->validateRequired())
  62. throw new Exception('Required fields are missing');
  63. }
  64. function write($fp) {
  65. if (!$this->validateRequired())
  66. throw new Exception('Required fields are missing');
  67. if (!is_null($this->key_)) {
  68. fwrite($fp, "\x0a");
  69. Protobuf::write_varint($fp, strlen($this->key_));
  70. fwrite($fp, $this->key_);
  71. }
  72. if (!is_null($this->value_)) {
  73. fwrite($fp, "\x12");
  74. Protobuf::write_varint($fp, strlen($this->value_));
  75. fwrite($fp, $this->value_);
  76. }
  77. }
  78. public function size() {
  79. $size = 0;
  80. if (!is_null($this->key_)) {
  81. $l = strlen($this->key_);
  82. $size += 1 + Protobuf::size_varint($l) + $l;
  83. }
  84. if (!is_null($this->value_)) {
  85. $l = strlen($this->value_);
  86. $size += 1 + Protobuf::size_varint($l) + $l;
  87. }
  88. return $size;
  89. }
  90. public function validateRequired() {
  91. if ($this->key_ === null) return false;
  92. if ($this->value_ === null) return false;
  93. return true;
  94. }
  95. public function __toString() {
  96. return ''
  97. . Protobuf::toString('unknown', $this->_unknown)
  98. . Protobuf::toString('key_', $this->key_)
  99. . Protobuf::toString('value_', $this->value_);
  100. }
  101. // required string key = 1;
  102. private $key_ = null;
  103. public function clearKey() { $this->key_ = null; }
  104. public function hasKey() { return $this->key_ !== null; }
  105. public function getKey() { if($this->key_ === null) return ""; else return $this->key_; }
  106. public function setKey($value) { $this->key_ = $value; }
  107. // required string value = 2;
  108. private $value_ = null;
  109. public function clearValue() { $this->value_ = null; }
  110. public function hasValue() { return $this->value_ !== null; }
  111. public function getValue() { if($this->value_ === null) return ""; else return $this->value_; }
  112. public function setValue($value) { $this->value_ = $value; }
  113. // @@protoc_insertion_point(class_scope:Log.Content)
  114. }
  115. // message Log
  116. class Log {
  117. private $_unknown;
  118. function __construct($in = NULL, &$limit = PHP_INT_MAX) {
  119. if($in !== NULL) {
  120. if (is_string($in)) {
  121. $fp = fopen('php://memory', 'r+b');
  122. fwrite($fp, $in);
  123. rewind($fp);
  124. } else if (is_resource($in)) {
  125. $fp = $in;
  126. } else {
  127. throw new Exception('Invalid in parameter');
  128. }
  129. $this->read($fp, $limit);
  130. }
  131. }
  132. function read($fp, &$limit = PHP_INT_MAX) {
  133. while(!feof($fp) && $limit > 0) {
  134. $tag = Protobuf::read_varint($fp, $limit);
  135. if ($tag === false) break;
  136. $wire = $tag & 0x07;
  137. $field = $tag >> 3;
  138. //var_dump("Log: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
  139. switch($field) {
  140. case 1:
  141. ASSERT('$wire == 0');
  142. $tmp = Protobuf::read_varint($fp, $limit);
  143. if ($tmp === false)
  144. throw new Exception('Protobuf::read_varint returned false');
  145. $this->time_ = $tmp;
  146. break;
  147. case 2:
  148. ASSERT('$wire == 2');
  149. $len = Protobuf::read_varint($fp, $limit);
  150. if ($len === false)
  151. throw new Exception('Protobuf::read_varint returned false');
  152. $limit-=$len;
  153. $this->contents_[] = new Log_Content($fp, $len);
  154. ASSERT('$len == 0');
  155. break;
  156. default:
  157. $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
  158. }
  159. }
  160. if (!$this->validateRequired())
  161. throw new Exception('Required fields are missing');
  162. }
  163. function write($fp) {
  164. if (!$this->validateRequired())
  165. throw new Exception('Required fields are missing');
  166. if (!is_null($this->time_)) {
  167. fwrite($fp, "\x08");
  168. Protobuf::write_varint($fp, $this->time_);
  169. }
  170. if (!is_null($this->contents_))
  171. foreach($this->contents_ as $v) {
  172. fwrite($fp, "\x12");
  173. Protobuf::write_varint($fp, $v->size()); // message
  174. $v->write($fp);
  175. }
  176. }
  177. public function size() {
  178. $size = 0;
  179. if (!is_null($this->time_)) {
  180. $size += 1 + Protobuf::size_varint($this->time_);
  181. }
  182. if (!is_null($this->contents_))
  183. foreach($this->contents_ as $v) {
  184. $l = $v->size();
  185. $size += 1 + Protobuf::size_varint($l) + $l;
  186. }
  187. return $size;
  188. }
  189. public function validateRequired() {
  190. if ($this->time_ === null) return false;
  191. return true;
  192. }
  193. public function __toString() {
  194. return ''
  195. . Protobuf::toString('unknown', $this->_unknown)
  196. . Protobuf::toString('time_', $this->time_)
  197. . Protobuf::toString('contents_', $this->contents_);
  198. }
  199. // required uint32 time = 1;
  200. private $time_ = null;
  201. public function clearTime() { $this->time_ = null; }
  202. public function hasTime() { return $this->time_ !== null; }
  203. public function getTime() { if($this->time_ === null) return 0; else return $this->time_; }
  204. public function setTime($value) { $this->time_ = $value; }
  205. // repeated .Log.Content contents = 2;
  206. private $contents_ = null;
  207. public function clearContents() { $this->contents_ = null; }
  208. public function getContentsCount() { if ($this->contents_ === null ) return 0; else return count($this->contents_); }
  209. public function getContents($index) { return $this->contents_[$index]; }
  210. public function getContentsArray() { if ($this->contents_ === null ) return array(); else return $this->contents_; }
  211. public function setContents($index, $value) {$this->contents_[$index] = $value; }
  212. public function addContents($value) { $this->contents_[] = $value; }
  213. public function addAllContents(array $values) { foreach($values as $value) {$this->contents_[] = $value;} }
  214. // @@protoc_insertion_point(class_scope:Log)
  215. }
  216. // message LogGroup
  217. class LogGroup {
  218. private $_unknown;
  219. function __construct($in = NULL, &$limit = PHP_INT_MAX) {
  220. if($in !== NULL) {
  221. if (is_string($in)) {
  222. $fp = fopen('php://memory', 'r+b');
  223. fwrite($fp, $in);
  224. rewind($fp);
  225. } else if (is_resource($in)) {
  226. $fp = $in;
  227. } else {
  228. throw new Exception('Invalid in parameter');
  229. }
  230. $this->read($fp, $limit);
  231. }
  232. }
  233. function read($fp, &$limit = PHP_INT_MAX) {
  234. while(!feof($fp) && $limit > 0) {
  235. $tag = Protobuf::read_varint($fp, $limit);
  236. if ($tag === false) break;
  237. $wire = $tag & 0x07;
  238. $field = $tag >> 3;
  239. //var_dump("LogGroup: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
  240. switch($field) {
  241. case 1:
  242. ASSERT('$wire == 2');
  243. $len = Protobuf::read_varint($fp, $limit);
  244. if ($len === false)
  245. throw new Exception('Protobuf::read_varint returned false');
  246. $limit-=$len;
  247. $this->logs_[] = new Log($fp, $len);
  248. ASSERT('$len == 0');
  249. break;
  250. case 2:
  251. ASSERT('$wire == 2');
  252. $len = Protobuf::read_varint($fp, $limit);
  253. if ($len === false)
  254. throw new Exception('Protobuf::read_varint returned false');
  255. if ($len > 0)
  256. $tmp = fread($fp, $len);
  257. else
  258. $tmp = '';
  259. if ($tmp === false)
  260. throw new Exception("fread($len) returned false");
  261. $this->reserved_ = $tmp;
  262. $limit-=$len;
  263. break;
  264. case 3:
  265. ASSERT('$wire == 2');
  266. $len = Protobuf::read_varint($fp, $limit);
  267. if ($len === false)
  268. throw new Exception('Protobuf::read_varint returned false');
  269. if ($len > 0)
  270. $tmp = fread($fp, $len);
  271. else
  272. $tmp = '';
  273. if ($tmp === false)
  274. throw new Exception("fread($len) returned false");
  275. $this->topic_ = $tmp;
  276. $limit-=$len;
  277. break;
  278. case 4:
  279. ASSERT('$wire == 2');
  280. $len = Protobuf::read_varint($fp, $limit);
  281. if ($len === false)
  282. throw new Exception('Protobuf::read_varint returned false');
  283. if ($len > 0)
  284. $tmp = fread($fp, $len);
  285. else
  286. $tmp = '';
  287. if ($tmp === false)
  288. throw new Exception("fread($len) returned false");
  289. $this->source_ = $tmp;
  290. $limit-=$len;
  291. break;
  292. default:
  293. $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
  294. }
  295. }
  296. if (!$this->validateRequired())
  297. throw new Exception('Required fields are missing');
  298. }
  299. function write($fp) {
  300. if (!$this->validateRequired())
  301. throw new Exception('Required fields are missing');
  302. if (!is_null($this->logs_))
  303. foreach($this->logs_ as $v) {
  304. fwrite($fp, "\x0a");
  305. Protobuf::write_varint($fp, $v->size()); // message
  306. $v->write($fp);
  307. }
  308. if (!is_null($this->reserved_)) {
  309. fwrite($fp, "\x12");
  310. Protobuf::write_varint($fp, strlen($this->reserved_));
  311. fwrite($fp, $this->reserved_);
  312. }
  313. if (!is_null($this->topic_)) {
  314. fwrite($fp, "\x1a");
  315. Protobuf::write_varint($fp, strlen($this->topic_));
  316. fwrite($fp, $this->topic_);
  317. }
  318. if (!is_null($this->source_)) {
  319. fwrite($fp, "\"");
  320. Protobuf::write_varint($fp, strlen($this->source_));
  321. fwrite($fp, $this->source_);
  322. }
  323. }
  324. public function size() {
  325. $size = 0;
  326. if (!is_null($this->logs_))
  327. foreach($this->logs_ as $v) {
  328. $l = $v->size();
  329. $size += 1 + Protobuf::size_varint($l) + $l;
  330. }
  331. if (!is_null($this->reserved_)) {
  332. $l = strlen($this->reserved_);
  333. $size += 1 + Protobuf::size_varint($l) + $l;
  334. }
  335. if (!is_null($this->topic_)) {
  336. $l = strlen($this->topic_);
  337. $size += 1 + Protobuf::size_varint($l) + $l;
  338. }
  339. if (!is_null($this->source_)) {
  340. $l = strlen($this->source_);
  341. $size += 1 + Protobuf::size_varint($l) + $l;
  342. }
  343. return $size;
  344. }
  345. public function validateRequired() {
  346. return true;
  347. }
  348. public function __toString() {
  349. return ''
  350. . Protobuf::toString('unknown', $this->_unknown)
  351. . Protobuf::toString('logs_', $this->logs_)
  352. . Protobuf::toString('reserved_', $this->reserved_)
  353. . Protobuf::toString('topic_', $this->topic_)
  354. . Protobuf::toString('source_', $this->source_);
  355. }
  356. // repeated .Log logs = 1;
  357. private $logs_ = null;
  358. public function clearLogs() { $this->logs_ = null; }
  359. public function getLogsCount() { if ($this->logs_ === null ) return 0; else return count($this->logs_); }
  360. public function getLogs($index) { return $this->logs_[$index]; }
  361. public function getLogsArray() { if ($this->logs_ === null ) return array(); else return $this->logs_; }
  362. public function setLogs($index, $value) {$this->logs_[$index] = $value; }
  363. public function addLogs($value) { $this->logs_[] = $value; }
  364. public function addAllLogs(array $values) { foreach($values as $value) {$this->logs_[] = $value;} }
  365. // optional string reserved = 2;
  366. private $reserved_ = null;
  367. public function clearReserved() { $this->reserved_ = null; }
  368. public function hasReserved() { return $this->reserved_ !== null; }
  369. public function getReserved() { if($this->reserved_ === null) return ""; else return $this->reserved_; }
  370. public function setReserved($value) { $this->reserved_ = $value; }
  371. // optional string topic = 3;
  372. private $topic_ = null;
  373. public function clearTopic() { $this->topic_ = null; }
  374. public function hasTopic() { return $this->topic_ !== null; }
  375. public function getTopic() { if($this->topic_ === null) return ""; else return $this->topic_; }
  376. public function setTopic($value) { $this->topic_ = $value; }
  377. // optional string source = 4;
  378. private $source_ = null;
  379. public function clearSource() { $this->source_ = null; }
  380. public function hasSource() { return $this->source_ !== null; }
  381. public function getSource() { if($this->source_ === null) return ""; else return $this->source_; }
  382. public function setSource($value) { $this->source_ = $value; }
  383. // @@protoc_insertion_point(class_scope:LogGroup)
  384. }
  385. // message LogPackage
  386. class LogPackage {
  387. private $_unknown;
  388. function __construct($in = NULL, &$limit = PHP_INT_MAX) {
  389. if($in !== NULL) {
  390. if (is_string($in)) {
  391. $fp = fopen('php://memory', 'r+b');
  392. fwrite($fp, $in);
  393. rewind($fp);
  394. } else if (is_resource($in)) {
  395. $fp = $in;
  396. } else {
  397. throw new Exception('Invalid in parameter');
  398. }
  399. $this->read($fp, $limit);
  400. }
  401. }
  402. function read($fp, &$limit = PHP_INT_MAX) {
  403. while(!feof($fp) && $limit > 0) {
  404. $tag = Protobuf::read_varint($fp, $limit);
  405. if ($tag === false) break;
  406. $wire = $tag & 0x07;
  407. $field = $tag >> 3;
  408. //var_dump("LogPackage: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
  409. switch($field) {
  410. case 1:
  411. ASSERT('$wire == 2');
  412. $len = Protobuf::read_varint($fp, $limit);
  413. if ($len === false)
  414. throw new Exception('Protobuf::read_varint returned false');
  415. if ($len > 0)
  416. $tmp = fread($fp, $len);
  417. else
  418. $tmp = '';
  419. if ($tmp === false)
  420. throw new Exception("fread($len) returned false");
  421. $this->data_ = $tmp;
  422. $limit-=$len;
  423. break;
  424. case 2:
  425. ASSERT('$wire == 0');
  426. $tmp = Protobuf::read_varint($fp, $limit);
  427. if ($tmp === false)
  428. throw new Exception('Protobuf::read_varint returned false');
  429. $this->uncompressSize_ = $tmp;
  430. break;
  431. default:
  432. $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
  433. }
  434. }
  435. if (!$this->validateRequired())
  436. throw new Exception('Required fields are missing');
  437. }
  438. function write($fp) {
  439. if (!$this->validateRequired())
  440. throw new Exception('Required fields are missing');
  441. if (!is_null($this->data_)) {
  442. fwrite($fp, "\x0a");
  443. Protobuf::write_varint($fp, strlen($this->data_));
  444. fwrite($fp, $this->data_);
  445. }
  446. if (!is_null($this->uncompressSize_)) {
  447. fwrite($fp, "\x10");
  448. Protobuf::write_varint($fp, $this->uncompressSize_);
  449. }
  450. }
  451. public function size() {
  452. $size = 0;
  453. if (!is_null($this->data_)) {
  454. $l = strlen($this->data_);
  455. $size += 1 + Protobuf::size_varint($l) + $l;
  456. }
  457. if (!is_null($this->uncompressSize_)) {
  458. $size += 1 + Protobuf::size_varint($this->uncompressSize_);
  459. }
  460. return $size;
  461. }
  462. public function validateRequired() {
  463. if ($this->data_ === null) return false;
  464. return true;
  465. }
  466. public function __toString() {
  467. return ''
  468. . Protobuf::toString('unknown', $this->_unknown)
  469. . Protobuf::toString('data_', $this->data_)
  470. . Protobuf::toString('uncompressSize_', $this->uncompressSize_);
  471. }
  472. // required bytes data = 1;
  473. private $data_ = null;
  474. public function clearData() { $this->data_ = null; }
  475. public function hasData() { return $this->data_ !== null; }
  476. public function getData() { if($this->data_ === null) return ""; else return $this->data_; }
  477. public function setData($value) { $this->data_ = $value; }
  478. // optional int32 uncompress_size = 2;
  479. private $uncompressSize_ = null;
  480. public function clearUncompressSize() { $this->uncompressSize_ = null; }
  481. public function hasUncompressSize() { return $this->uncompressSize_ !== null; }
  482. public function getUncompressSize() { if($this->uncompressSize_ === null) return 0; else return $this->uncompressSize_; }
  483. public function setUncompressSize($value) { $this->uncompressSize_ = $value; }
  484. // @@protoc_insertion_point(class_scope:LogPackage)
  485. }
  486. // message LogPackageList
  487. class LogPackageList {
  488. private $_unknown;
  489. function __construct($in = NULL, &$limit = PHP_INT_MAX) {
  490. if($in !== NULL) {
  491. if (is_string($in)) {
  492. $fp = fopen('php://memory', 'r+b');
  493. fwrite($fp, $in);
  494. rewind($fp);
  495. } else if (is_resource($in)) {
  496. $fp = $in;
  497. } else {
  498. throw new Exception('Invalid in parameter');
  499. }
  500. $this->read($fp, $limit);
  501. }
  502. }
  503. function read($fp, &$limit = PHP_INT_MAX) {
  504. while(!feof($fp) && $limit > 0) {
  505. $tag = Protobuf::read_varint($fp, $limit);
  506. if ($tag === false) break;
  507. $wire = $tag & 0x07;
  508. $field = $tag >> 3;
  509. //var_dump("LogPackageList: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
  510. switch($field) {
  511. case 1:
  512. ASSERT('$wire == 2');
  513. $len = Protobuf::read_varint($fp, $limit);
  514. if ($len === false)
  515. throw new Exception('Protobuf::read_varint returned false');
  516. $limit-=$len;
  517. $this->packages_[] = new LogPackage($fp, $len);
  518. ASSERT('$len == 0');
  519. break;
  520. default:
  521. $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
  522. }
  523. }
  524. if (!$this->validateRequired())
  525. throw new Exception('Required fields are missing');
  526. }
  527. function write($fp) {
  528. if (!$this->validateRequired())
  529. throw new Exception('Required fields are missing');
  530. if (!is_null($this->packages_))
  531. foreach($this->packages_ as $v) {
  532. fwrite($fp, "\x0a");
  533. Protobuf::write_varint($fp, $v->size()); // message
  534. $v->write($fp);
  535. }
  536. }
  537. public function size() {
  538. $size = 0;
  539. if (!is_null($this->packages_))
  540. foreach($this->packages_ as $v) {
  541. $l = $v->size();
  542. $size += 1 + Protobuf::size_varint($l) + $l;
  543. }
  544. return $size;
  545. }
  546. public function validateRequired() {
  547. return true;
  548. }
  549. public function __toString() {
  550. return ''
  551. . Protobuf::toString('unknown', $this->_unknown)
  552. . Protobuf::toString('packages_', $this->packages_);
  553. }
  554. // repeated .LogPackage packages = 1;
  555. private $packages_ = null;
  556. public function clearPackages() { $this->packages_ = null; }
  557. public function getPackagesCount() { if ($this->packages_ === null ) return 0; else return count($this->packages_); }
  558. public function getPackages($index) { return $this->packages_[$index]; }
  559. public function getPackagesArray() { if ($this->packages_ === null ) return array(); else return $this->packages_; }
  560. public function setPackages($index, $value) {$this->packages_[$index] = $value; }
  561. public function addPackages($value) { $this->packages_[] = $value; }
  562. public function addAllPackages(array $values) { foreach($values as $value) {$this->packages_[] = $value;} }
  563. // @@protoc_insertion_point(class_scope:LogPackageList)
  564. }