CharacterStream.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /**
  10. * An abstract means of reading and writing data in terms of characters as opposed
  11. * to bytes.
  12. *
  13. * Classes implementing this interface may use a subsystem which requires less
  14. * memory than working with large strings of data.
  15. *
  16. * @author Chris Corbyn
  17. */
  18. interface Swift_CharacterStream
  19. {
  20. /**
  21. * Set the character set used in this CharacterStream.
  22. *
  23. * @param string $charset
  24. */
  25. public function setCharacterSet($charset);
  26. /**
  27. * Set the CharacterReaderFactory for multi charset support.
  28. *
  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. *
  35. * @param Swift_OutputByteStream $os output stream to read from
  36. */
  37. public function importByteStream(Swift_OutputByteStream $os);
  38. /**
  39. * Import a string a bytes into this CharacterStream, overwriting any existing
  40. * data in the stream.
  41. *
  42. * @param string $string
  43. */
  44. public function importString($string);
  45. /**
  46. * Read $length characters from the stream and move the internal pointer
  47. * $length further into the stream.
  48. *
  49. * @param int $length
  50. *
  51. * @return string
  52. */
  53. public function read($length);
  54. /**
  55. * Read $length characters from the stream and return a 1-dimensional array
  56. * containing there octet values.
  57. *
  58. * @param int $length
  59. *
  60. * @return int[]
  61. */
  62. public function readBytes($length);
  63. /**
  64. * Write $chars to the end of the stream.
  65. *
  66. * @param string $chars
  67. */
  68. public function write($chars);
  69. /**
  70. * Move the internal pointer to $charOffset in the stream.
  71. *
  72. * @param int $charOffset
  73. */
  74. public function setPointer($charOffset);
  75. /**
  76. * Empty the stream and reset the internal pointer.
  77. */
  78. public function flushContents();
  79. }