sls.proto.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <?php
  2. // Please include the below file before sls_logs.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->category_ = $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->category_)) {
  309. fwrite($fp, "\x12");
  310. Protobuf::write_varint($fp, strlen($this->category_));
  311. fwrite($fp, $this->category_);
  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->category_)) {
  332. $l = strlen($this->category_);
  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('category_', $this->category_)
  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 Category = 2;
  366. private $category_ = null;
  367. public function clearCategory() { $this->category_ = null; }
  368. public function hasCategory() { return $this->category_ !== null; }
  369. public function getCategory() { if($this->category_ === null) return ""; else return $this->category_; }
  370. public function setCategory($value) { $this->category_ = $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 LogGroupList
  386. class LogGroupList {
  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("LogGroupList: 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. $limit-=$len;
  416. $this->logGroupList_[] = new LogGroup($fp, $len);
  417. ASSERT('$len == 0');
  418. break;
  419. default:
  420. $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
  421. }
  422. }
  423. if (!$this->validateRequired())
  424. throw new Exception('Required fields are missing');
  425. }
  426. function write($fp) {
  427. if (!$this->validateRequired())
  428. throw new Exception('Required fields are missing');
  429. if (!is_null($this->logGroupList_))
  430. foreach($this->logGroupList_ as $v) {
  431. fwrite($fp, "\x0a");
  432. Protobuf::write_varint($fp, $v->size()); // message
  433. $v->write($fp);
  434. }
  435. }
  436. public function size() {
  437. $size = 0;
  438. if (!is_null($this->logGroupList_))
  439. foreach($this->logGroupList_ as $v) {
  440. $l = $v->size();
  441. $size += 1 + Protobuf::size_varint($l) + $l;
  442. }
  443. return $size;
  444. }
  445. public function validateRequired() {
  446. return true;
  447. }
  448. public function __toString() {
  449. return ''
  450. . Protobuf::toString('unknown', $this->_unknown)
  451. . Protobuf::toString('logGroupList_', $this->logGroupList_);
  452. }
  453. // repeated .LogGroup logGroupList = 1;
  454. private $logGroupList_ = null;
  455. public function clearLogGroupList() { $this->logGroupList_ = null; }
  456. public function getLogGroupListCount() { if ($this->logGroupList_ === null ) return 0; else return count($this->logGroupList_); }
  457. public function getLogGroupList($index) { return $this->logGroupList_[$index]; }
  458. public function getLogGroupListArray() { if ($this->logGroupList_ === null ) return array(); else return $this->logGroupList_; }
  459. public function setLogGroupList($index, $value) {$this->logGroupList_[$index] = $value; }
  460. public function addLogGroupList($value) { $this->logGroupList_[] = $value; }
  461. public function addAllLogGroupList(array $values) { foreach($values as $value) {$this->logGroupList_[] = $value;} }
  462. // @@protoc_insertion_point(class_scope:LogGroupList)
  463. }