| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516 |
- <?php
- // Please include the below file before sls_logs.proto.php
- //require('protocolbuffers.inc.php');
- // message Log.Content
- class Log_Content {
- private $_unknown;
- function __construct($in = NULL, &$limit = PHP_INT_MAX) {
- if($in !== NULL) {
- if (is_string($in)) {
- $fp = fopen('php://memory', 'r+b');
- fwrite($fp, $in);
- rewind($fp);
- } else if (is_resource($in)) {
- $fp = $in;
- } else {
- throw new Exception('Invalid in parameter');
- }
- $this->read($fp, $limit);
- }
- }
- function read($fp, &$limit = PHP_INT_MAX) {
- while(!feof($fp) && $limit > 0) {
- $tag = Protobuf::read_varint($fp, $limit);
- if ($tag === false) break;
- $wire = $tag & 0x07;
- $field = $tag >> 3;
- //var_dump("Log_Content: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
- switch($field) {
- case 1:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- if ($len > 0)
- $tmp = fread($fp, $len);
- else
- $tmp = '';
- if ($tmp === false)
- throw new Exception("fread($len) returned false");
- $this->key_ = $tmp;
- $limit-=$len;
- break;
- case 2:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- if ($len > 0)
- $tmp = fread($fp, $len);
- else
- $tmp = '';
- if ($tmp === false)
- throw new Exception("fread($len) returned false");
- $this->value_ = $tmp;
- $limit-=$len;
- break;
- default:
- $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
- }
- }
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- }
- function write($fp) {
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- if (!is_null($this->key_)) {
- fwrite($fp, "\x0a");
- Protobuf::write_varint($fp, strlen($this->key_));
- fwrite($fp, $this->key_);
- }
- if (!is_null($this->value_)) {
- fwrite($fp, "\x12");
- Protobuf::write_varint($fp, strlen($this->value_));
- fwrite($fp, $this->value_);
- }
- }
- public function size() {
- $size = 0;
- if (!is_null($this->key_)) {
- $l = strlen($this->key_);
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- if (!is_null($this->value_)) {
- $l = strlen($this->value_);
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- return $size;
- }
- public function validateRequired() {
- if ($this->key_ === null) return false;
- if ($this->value_ === null) return false;
- return true;
- }
- public function __toString() {
- return ''
- . Protobuf::toString('unknown', $this->_unknown)
- . Protobuf::toString('key_', $this->key_)
- . Protobuf::toString('value_', $this->value_);
- }
- // required string Key = 1;
- private $key_ = null;
- public function clearKey() { $this->key_ = null; }
- public function hasKey() { return $this->key_ !== null; }
- public function getKey() { if($this->key_ === null) return ""; else return $this->key_; }
- public function setKey($value) { $this->key_ = $value; }
- // required string Value = 2;
- private $value_ = null;
- public function clearValue() { $this->value_ = null; }
- public function hasValue() { return $this->value_ !== null; }
- public function getValue() { if($this->value_ === null) return ""; else return $this->value_; }
- public function setValue($value) { $this->value_ = $value; }
- // @@protoc_insertion_point(class_scope:Log.Content)
- }
- // message Log
- class Log {
- private $_unknown;
- function __construct($in = NULL, &$limit = PHP_INT_MAX) {
- if($in !== NULL) {
- if (is_string($in)) {
- $fp = fopen('php://memory', 'r+b');
- fwrite($fp, $in);
- rewind($fp);
- } else if (is_resource($in)) {
- $fp = $in;
- } else {
- throw new Exception('Invalid in parameter');
- }
- $this->read($fp, $limit);
- }
- }
- function read($fp, &$limit = PHP_INT_MAX) {
- while(!feof($fp) && $limit > 0) {
- $tag = Protobuf::read_varint($fp, $limit);
- if ($tag === false) break;
- $wire = $tag & 0x07;
- $field = $tag >> 3;
- //var_dump("Log: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
- switch($field) {
- case 1:
- ASSERT('$wire == 0');
- $tmp = Protobuf::read_varint($fp, $limit);
- if ($tmp === false)
- throw new Exception('Protobuf::read_varint returned false');
- $this->time_ = $tmp;
- break;
- case 2:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- $limit-=$len;
- $this->contents_[] = new Log_Content($fp, $len);
- ASSERT('$len == 0');
- break;
- default:
- $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
- }
- }
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- }
- function write($fp) {
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- if (!is_null($this->time_)) {
- fwrite($fp, "\x08");
- Protobuf::write_varint($fp, $this->time_);
- }
- if (!is_null($this->contents_))
- foreach($this->contents_ as $v) {
- fwrite($fp, "\x12");
- Protobuf::write_varint($fp, $v->size()); // message
- $v->write($fp);
- }
- }
- public function size() {
- $size = 0;
- if (!is_null($this->time_)) {
- $size += 1 + Protobuf::size_varint($this->time_);
- }
- if (!is_null($this->contents_))
- foreach($this->contents_ as $v) {
- $l = $v->size();
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- return $size;
- }
- public function validateRequired() {
- if ($this->time_ === null) return false;
- return true;
- }
- public function __toString() {
- return ''
- . Protobuf::toString('unknown', $this->_unknown)
- . Protobuf::toString('time_', $this->time_)
- . Protobuf::toString('contents_', $this->contents_);
- }
- // required uint32 Time = 1;
- private $time_ = null;
- public function clearTime() { $this->time_ = null; }
- public function hasTime() { return $this->time_ !== null; }
- public function getTime() { if($this->time_ === null) return 0; else return $this->time_; }
- public function setTime($value) { $this->time_ = $value; }
- // repeated .Log.Content Contents = 2;
- private $contents_ = null;
- public function clearContents() { $this->contents_ = null; }
- public function getContentsCount() { if ($this->contents_ === null ) return 0; else return count($this->contents_); }
- public function getContents($index) { return $this->contents_[$index]; }
- public function getContentsArray() { if ($this->contents_ === null ) return array(); else return $this->contents_; }
- public function setContents($index, $value) {$this->contents_[$index] = $value; }
- public function addContents($value) { $this->contents_[] = $value; }
- public function addAllContents(array $values) { foreach($values as $value) {$this->contents_[] = $value;} }
- // @@protoc_insertion_point(class_scope:Log)
- }
- // message LogGroup
- class LogGroup {
- private $_unknown;
- function __construct($in = NULL, &$limit = PHP_INT_MAX) {
- if($in !== NULL) {
- if (is_string($in)) {
- $fp = fopen('php://memory', 'r+b');
- fwrite($fp, $in);
- rewind($fp);
- } else if (is_resource($in)) {
- $fp = $in;
- } else {
- throw new Exception('Invalid in parameter');
- }
- $this->read($fp, $limit);
- }
- }
- function read($fp, &$limit = PHP_INT_MAX) {
- while(!feof($fp) && $limit > 0) {
- $tag = Protobuf::read_varint($fp, $limit);
- if ($tag === false) break;
- $wire = $tag & 0x07;
- $field = $tag >> 3;
- //var_dump("LogGroup: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
- switch($field) {
- case 1:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- $limit-=$len;
- $this->logs_[] = new Log($fp, $len);
- ASSERT('$len == 0');
- break;
- case 2:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- if ($len > 0)
- $tmp = fread($fp, $len);
- else
- $tmp = '';
- if ($tmp === false)
- throw new Exception("fread($len) returned false");
- $this->category_ = $tmp;
- $limit-=$len;
- break;
- case 3:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- if ($len > 0)
- $tmp = fread($fp, $len);
- else
- $tmp = '';
- if ($tmp === false)
- throw new Exception("fread($len) returned false");
- $this->topic_ = $tmp;
- $limit-=$len;
- break;
- case 4:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- if ($len > 0)
- $tmp = fread($fp, $len);
- else
- $tmp = '';
- if ($tmp === false)
- throw new Exception("fread($len) returned false");
- $this->source_ = $tmp;
- $limit-=$len;
- break;
- default:
- $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
- }
- }
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- }
- function write($fp) {
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- if (!is_null($this->logs_))
- foreach($this->logs_ as $v) {
- fwrite($fp, "\x0a");
- Protobuf::write_varint($fp, $v->size()); // message
- $v->write($fp);
- }
- if (!is_null($this->category_)) {
- fwrite($fp, "\x12");
- Protobuf::write_varint($fp, strlen($this->category_));
- fwrite($fp, $this->category_);
- }
- if (!is_null($this->topic_)) {
- fwrite($fp, "\x1a");
- Protobuf::write_varint($fp, strlen($this->topic_));
- fwrite($fp, $this->topic_);
- }
- if (!is_null($this->source_)) {
- fwrite($fp, "\"");
- Protobuf::write_varint($fp, strlen($this->source_));
- fwrite($fp, $this->source_);
- }
- }
- public function size() {
- $size = 0;
- if (!is_null($this->logs_))
- foreach($this->logs_ as $v) {
- $l = $v->size();
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- if (!is_null($this->category_)) {
- $l = strlen($this->category_);
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- if (!is_null($this->topic_)) {
- $l = strlen($this->topic_);
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- if (!is_null($this->source_)) {
- $l = strlen($this->source_);
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- return $size;
- }
- public function validateRequired() {
- return true;
- }
- public function __toString() {
- return ''
- . Protobuf::toString('unknown', $this->_unknown)
- . Protobuf::toString('logs_', $this->logs_)
- . Protobuf::toString('category_', $this->category_)
- . Protobuf::toString('topic_', $this->topic_)
- . Protobuf::toString('source_', $this->source_);
- }
- // repeated .Log Logs = 1;
- private $logs_ = null;
- public function clearLogs() { $this->logs_ = null; }
- public function getLogsCount() { if ($this->logs_ === null ) return 0; else return count($this->logs_); }
- public function getLogs($index) { return $this->logs_[$index]; }
- public function getLogsArray() { if ($this->logs_ === null ) return array(); else return $this->logs_; }
- public function setLogs($index, $value) {$this->logs_[$index] = $value; }
- public function addLogs($value) { $this->logs_[] = $value; }
- public function addAllLogs(array $values) { foreach($values as $value) {$this->logs_[] = $value;} }
- // optional string Category = 2;
- private $category_ = null;
- public function clearCategory() { $this->category_ = null; }
- public function hasCategory() { return $this->category_ !== null; }
- public function getCategory() { if($this->category_ === null) return ""; else return $this->category_; }
- public function setCategory($value) { $this->category_ = $value; }
- // optional string Topic = 3;
- private $topic_ = null;
- public function clearTopic() { $this->topic_ = null; }
- public function hasTopic() { return $this->topic_ !== null; }
- public function getTopic() { if($this->topic_ === null) return ""; else return $this->topic_; }
- public function setTopic($value) { $this->topic_ = $value; }
- // optional string Source = 4;
- private $source_ = null;
- public function clearSource() { $this->source_ = null; }
- public function hasSource() { return $this->source_ !== null; }
- public function getSource() { if($this->source_ === null) return ""; else return $this->source_; }
- public function setSource($value) { $this->source_ = $value; }
- // @@protoc_insertion_point(class_scope:LogGroup)
- }
- // message LogGroupList
- class LogGroupList {
- private $_unknown;
- function __construct($in = NULL, &$limit = PHP_INT_MAX) {
- if($in !== NULL) {
- if (is_string($in)) {
- $fp = fopen('php://memory', 'r+b');
- fwrite($fp, $in);
- rewind($fp);
- } else if (is_resource($in)) {
- $fp = $in;
- } else {
- throw new Exception('Invalid in parameter');
- }
- $this->read($fp, $limit);
- }
- }
- function read($fp, &$limit = PHP_INT_MAX) {
- while(!feof($fp) && $limit > 0) {
- $tag = Protobuf::read_varint($fp, $limit);
- if ($tag === false) break;
- $wire = $tag & 0x07;
- $field = $tag >> 3;
- //var_dump("LogGroupList: Found $field type " . Protobuf::get_wiretype($wire) . " $limit bytes left");
- switch($field) {
- case 1:
- ASSERT('$wire == 2');
- $len = Protobuf::read_varint($fp, $limit);
- if ($len === false)
- throw new Exception('Protobuf::read_varint returned false');
- $limit-=$len;
- $this->logGroupList_[] = new LogGroup($fp, $len);
- ASSERT('$len == 0');
- break;
- default:
- $this->_unknown[$field . '-' . Protobuf::get_wiretype($wire)][] = Protobuf::read_field($fp, $wire, $limit);
- }
- }
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- }
- function write($fp) {
- if (!$this->validateRequired())
- throw new Exception('Required fields are missing');
- if (!is_null($this->logGroupList_))
- foreach($this->logGroupList_ as $v) {
- fwrite($fp, "\x0a");
- Protobuf::write_varint($fp, $v->size()); // message
- $v->write($fp);
- }
- }
- public function size() {
- $size = 0;
- if (!is_null($this->logGroupList_))
- foreach($this->logGroupList_ as $v) {
- $l = $v->size();
- $size += 1 + Protobuf::size_varint($l) + $l;
- }
- return $size;
- }
- public function validateRequired() {
- return true;
- }
- public function __toString() {
- return ''
- . Protobuf::toString('unknown', $this->_unknown)
- . Protobuf::toString('logGroupList_', $this->logGroupList_);
- }
- // repeated .LogGroup logGroupList = 1;
- private $logGroupList_ = null;
- public function clearLogGroupList() { $this->logGroupList_ = null; }
- public function getLogGroupListCount() { if ($this->logGroupList_ === null ) return 0; else return count($this->logGroupList_); }
- public function getLogGroupList($index) { return $this->logGroupList_[$index]; }
- public function getLogGroupListArray() { if ($this->logGroupList_ === null ) return array(); else return $this->logGroupList_; }
- public function setLogGroupList($index, $value) {$this->logGroupList_[$index] = $value; }
- public function addLogGroupList($value) { $this->logGroupList_[] = $value; }
- public function addAllLogGroupList(array $values) { foreach($values as $value) {$this->logGroupList_[] = $value;} }
- // @@protoc_insertion_point(class_scope:LogGroupList)
- }
|