pb_input_reader.php 832 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Abstract class for an input reader
  4. */
  5. abstract class PBInputReader
  6. {
  7. protected $base128;
  8. protected $pointer = 0;
  9. protected $string = '';
  10. public function __construct()
  11. {
  12. $this->base128 = new base128varint(1);
  13. }
  14. /**
  15. * Gets the acutal position of the point
  16. * @return int the pointer
  17. */
  18. public function get_pointer()
  19. {
  20. return $this->pointer;
  21. }
  22. /**
  23. * Add add to the pointer
  24. * @param int $add - int to add to the pointer
  25. */
  26. public function add_pointer($add)
  27. {
  28. $this->pointer += $add;
  29. }
  30. /**
  31. * Get the message from from to actual pointer
  32. * @param from
  33. */
  34. public function get_message_from($from)
  35. {
  36. return substr($this->string, $from, $this->pointer - $from);
  37. }
  38. /**
  39. * Getting the next varint as decimal number
  40. * @return varint
  41. */
  42. public abstract function next();
  43. }
  44. ?>