diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Pdf/FileParserDataSource/String.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Pdf/FileParserDataSource/String.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,128 @@ +_size = strlen($string); + $this->_string = $string; + } + + /** + * Object destructor. + */ + public function __destruct() + { + $this->_string = ''; + } + + /** + * Returns the specified number of raw bytes from the string at the byte + * offset of the current read position. + * + * Advances the read position by the number of bytes read. + * + * Throws an exception if there is insufficient data to completely fulfill + * the request. + * + * @param integer $byteCount Number of bytes to read. + * @return string + * @throws Zend_Pdf_Exception + */ + public function readBytes($byteCount) + { + if (($this->_offset + $byteCount) > $this->_size) { + require_once 'Zend/Pdf/Exception.php'; + throw new Zend_Pdf_Exception("Insufficient data to read $byteCount bytes", + Zend_Pdf_Exception::INSUFFICIENT_DATA); + } + $bytes = substr($this->_string, $this->_offset, $byteCount); + $this->_offset += $byteCount; + return $bytes; + } + + /** + * Returns the entire string. + * + * Preserves the current read position. + * + * @return string + */ + public function readAllBytes() + { + return $this->_string; + } + + + /* Object Magic Methods */ + + /** + * Returns a string containing the parsed string's length. + * + * @return string + */ + public function __toString() + { + return "String ($this->_size bytes)"; + } +}