CharacterStream.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory);
  30. /**
  31. * Overwrite this character stream using the byte sequence in the byte stream.
  32. *
  33. * @param Swift_OutputByteStream $os output stream to read from
  34. */
  35. public function importByteStream(Swift_OutputByteStream $os);
  36. /**
  37. * Import a string a bytes into this CharacterStream, overwriting any existing
  38. * data in the stream.
  39. *
  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. *
  47. * @param int $length
  48. *
  49. * @return string
  50. */
  51. public function read($length);
  52. /**
  53. * Read $length characters from the stream and return a 1-dimensional array
  54. * containing there octet values.
  55. *
  56. * @param int $length
  57. *
  58. * @return int[]
  59. */
  60. public function readBytes($length);
  61. /**
  62. * Write $chars to the end of the stream.
  63. *
  64. * @param string $chars
  65. */
  66. public function write($chars);
  67. /**
  68. * Move the internal pointer to $charOffset in the stream.
  69. *
  70. * @param int $charOffset
  71. */
  72. public function setPointer($charOffset);
  73. /**
  74. * Empty the stream and reset the internal pointer.
  75. */
  76. public function flushContents();
  77. }