CharacterStream.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. require_once dirname(__FILE__) . '/OutputByteStream.php';
  10. require_once dirname(__FILE__) . '/CharacterReaderFactory.php';
  11. /**
  12. * An abstract means of reading and writing data in terms of characters as opposed
  13. * to bytes.
  14. * Classes implementing this interface may use a subsystem which requires less
  15. * memory than working with large strings of data.
  16. * @package Swift
  17. * @subpackage CharacterStream
  18. * @author Chris Corbyn
  19. */
  20. interface Swift_CharacterStream
  21. {
  22. /**
  23. * Set the character set used in this CharacterStream.
  24. * @param string $charset
  25. */
  26. public function setCharacterSet($charset);
  27. /**
  28. * Set the CharacterReaderFactory for multi charset support.
  29. * @param Swift_CharacterReaderFactory $factory
  30. */
  31. public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory);
  32. /**
  33. * Overwrite this character stream using the byte sequence in the byte stream.
  34. * @param Swift_OutputByteStream $os output stream to read from
  35. */
  36. public function importByteStream(Swift_OutputByteStream $os);
  37. /**
  38. * Import a string a bytes into this CharacterStream, overwriting any existing
  39. * data in the stream.
  40. * @param string $string
  41. */
  42. public function importString($string);
  43. /**
  44. * Read $length characters from the stream and move the internal pointer
  45. * $length further into the stream.
  46. * @param int $length
  47. * @return string
  48. */
  49. public function read($length);
  50. /**
  51. * Read $length characters from the stream and return a 1-dimensional array
  52. * containing there octet values.
  53. * @param int $length
  54. * @return int[]
  55. */
  56. public function readBytes($length);
  57. /**
  58. * Write $chars to the end of the stream.
  59. * @param string $chars
  60. */
  61. public function write($chars);
  62. /**
  63. * Move the internal pointer to $charOffset in the stream.
  64. * @param int $charOffset
  65. */
  66. public function setPointer($charOffset);
  67. /**
  68. * Empty the stream and reset the internal pointer.
  69. */
  70. public function flushContents();
  71. }