POMO_StringReader

Provides file-like methods for manipulating a string instead of a physical file.

Defined (1)

The class is defined in the following location(s).

/wp-includes/pomo/streams.php  
  1. class POMO_StringReader extends POMO_Reader { 
  2.  
  3. var $_str = ''; 
  4.  
  5. /** 
  6. * PHP5 constructor. 
  7. */ 
  8. function __construct( $str = '' ) { 
  9. parent::POMO_Reader(); 
  10. $this->_str = $str; 
  11. $this->_pos = 0; 
  12.  
  13. /** 
  14. * PHP4 constructor. 
  15. */ 
  16. public function POMO_StringReader( $str = '' ) { 
  17. self::__construct( $str ); 
  18.  
  19. /** 
  20. * @param string $bytes 
  21. * @return string 
  22. */ 
  23. function read($bytes) { 
  24. $data = $this->substr($this->_str, $this->_pos, $bytes); 
  25. $this->_pos += $bytes; 
  26. if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str); 
  27. return $data; 
  28.  
  29. /** 
  30. * @param int $pos 
  31. * @return int 
  32. */ 
  33. function seekto($pos) { 
  34. $this->_pos = $pos; 
  35. if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str); 
  36. return $this->_pos; 
  37.  
  38. /** 
  39. * @return int 
  40. */ 
  41. function length() { 
  42. return $this->strlen($this->_str); 
  43.  
  44. /** 
  45. * @return string 
  46. */ 
  47. function read_all() { 
  48. return $this->substr($this->_str, $this->_pos, $this->strlen($this->_str)); 
  49.