In.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Hoa
  4. *
  5. *
  6. * @license
  7. *
  8. * New BSD License
  9. *
  10. * Copyright © 2007-2017, Hoa community. All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. * * Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * * Neither the name of the Hoa nor the names of its contributors may be
  20. * used to endorse or promote products derived from this software without
  21. * specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. namespace Hoa\Stream\IStream;
  36. /**
  37. * Interface \Hoa\Stream\IStream\In.
  38. *
  39. * Interface for input.
  40. *
  41. * @copyright Copyright © 2007-2017 Hoa community
  42. * @license New BSD License
  43. */
  44. interface In extends Stream
  45. {
  46. /**
  47. * Test for end-of-stream.
  48. *
  49. * @return bool
  50. */
  51. public function eof();
  52. /**
  53. * Read n characters.
  54. *
  55. * @param int $length Length.
  56. * @return string
  57. */
  58. public function read($length);
  59. /**
  60. * Alias of $this->read().
  61. *
  62. * @param int $length Length.
  63. * @return string
  64. */
  65. public function readString($length);
  66. /**
  67. * Read a character.
  68. * It could be equivalent to $this->read(1).
  69. *
  70. * @return string
  71. */
  72. public function readCharacter();
  73. /**
  74. * Read a boolean.
  75. *
  76. * @return bool
  77. */
  78. public function readBoolean();
  79. /**
  80. * Read an integer.
  81. *
  82. * @param int $length Length.
  83. * @return int
  84. */
  85. public function readInteger($length = 1);
  86. /**
  87. * Read a float.
  88. *
  89. * @param int $length Length.
  90. * @return float
  91. */
  92. public function readFloat($length = 1);
  93. /**
  94. * Read an array.
  95. * In most cases, it could be an alias to the $this->scanf() method.
  96. *
  97. * @param mixed $argument Argument (because the behavior is very
  98. * different according to the implementation).
  99. * @return array
  100. */
  101. public function readArray($argument = null);
  102. /**
  103. * Read a line.
  104. *
  105. * @return string
  106. */
  107. public function readLine();
  108. /**
  109. * Read all, i.e. read as much as possible.
  110. *
  111. * @param int $offset Offset.
  112. * @return string
  113. */
  114. public function readAll($offset = 0);
  115. /**
  116. * Parse input from a stream according to a format.
  117. *
  118. * @param string $format Format (see printf's formats).
  119. * @return array
  120. */
  121. public function scanf($format);
  122. }