CharacterStream.php 2.2KB

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. 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(
  32. Swift_CharacterReaderFactory $factory);
  33. /**
  34. * Overwrite this character stream using the byte sequence in the byte stream.
  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. * @param string $string
  42. */
  43. public function importString($string);
  44. /**
  45. * Read $length characters from the stream and move the internal pointer
  46. * $length further into the stream.
  47. * @param int $length
  48. * @return string
  49. */
  50. public function read($length);
  51. /**
  52. * Read $length characters from the stream and return a 1-dimensional array
  53. * containing there octet values.
  54. * @param int $length
  55. * @return int[]
  56. */
  57. public function readBytes($length);
  58. /**
  59. * Write $chars to the end of the stream.
  60. * @param string $chars
  61. */
  62. public function write($chars);
  63. /**
  64. * Move the internal pointer to $charOffset in the stream.
  65. * @param int $charOffset
  66. */
  67. public function setPointer($charOffset);
  68. /**
  69. * Empty the stream and reset the internal pointer.
  70. */
  71. public function flushContents();
  72. }