POMO_Reader

The WordPress Core POMO Reader class.

Defined (1)

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

/wp-includes/pomo/streams.php  
  1. class POMO_Reader { 
  2.  
  3. var $endian = 'little'; 
  4. var $_post = ''; 
  5.  
  6. /** 
  7. * PHP5 constructor. 
  8. */ 
  9. function __construct() { 
  10. $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr'); 
  11. $this->_pos = 0; 
  12.  
  13. /** 
  14. * PHP4 constructor. 
  15. */ 
  16. public function POMO_Reader() { 
  17. self::__construct(); 
  18.  
  19. /** 
  20. * Sets the endianness of the file. 
  21. * @param $endian string 'big' or 'little' 
  22. */ 
  23. function setEndian($endian) { 
  24. $this->endian = $endian; 
  25.  
  26. /** 
  27. * Reads a 32bit Integer from the Stream 
  28. * @return mixed The integer, corresponding to the next 32 bits from 
  29. * the stream of false if there are not enough bytes or on error 
  30. */ 
  31. function readint32() { 
  32. $bytes = $this->read(4); 
  33. if (4 != $this->strlen($bytes)) 
  34. return false; 
  35. $endian_letter = ('big' == $this->endian)? 'N' : 'V'; 
  36. $int = unpack($endian_letter, $bytes); 
  37. return reset( $int ); 
  38.  
  39. /** 
  40. * Reads an array of 32-bit Integers from the Stream 
  41. * @param integer count How many elements should be read 
  42. * @return mixed Array of integers or false if there isn't 
  43. * enough data or on error 
  44. */ 
  45. function readint32array($count) { 
  46. $bytes = $this->read(4 * $count); 
  47. if (4*$count != $this->strlen($bytes)) 
  48. return false; 
  49. $endian_letter = ('big' == $this->endian)? 'N' : 'V'; 
  50. return unpack($endian_letter.$count, $bytes); 
  51.  
  52. /** 
  53. * @param string $string 
  54. * @param int $start 
  55. * @param int $length 
  56. * @return string 
  57. */ 
  58. function substr($string, $start, $length) { 
  59. if ($this->is_overloaded) { 
  60. return mb_substr($string, $start, $length, 'ascii'); 
  61. } else { 
  62. return substr($string, $start, $length); 
  63.  
  64. /** 
  65. * @param string $string 
  66. * @return int 
  67. */ 
  68. function strlen($string) { 
  69. if ($this->is_overloaded) { 
  70. return mb_strlen($string, 'ascii'); 
  71. } else { 
  72. return strlen($string); 
  73.  
  74. /** 
  75. * @param string $string 
  76. * @param int $chunk_size 
  77. * @return array 
  78. */ 
  79. function str_split($string, $chunk_size) { 
  80. if (!function_exists('str_split')) { 
  81. $length = $this->strlen($string); 
  82. $out = array(); 
  83. for ($i = 0; $i < $length; $i += $chunk_size) 
  84. $out[] = $this->substr($string, $i, $chunk_size); 
  85. return $out; 
  86. } else { 
  87. return str_split( $string, $chunk_size ); 
  88.  
  89. /** 
  90. * @return int 
  91. */ 
  92. function pos() { 
  93. return $this->_pos; 
  94.  
  95. /** 
  96. * @return true 
  97. */ 
  98. function is_resource() { 
  99. return true; 
  100.  
  101. /** 
  102. * @return true 
  103. */ 
  104. function close() { 
  105. return true;