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