CharacterStream.php 2.2KB

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