# Reader

## Attributes

<PyAttributes>

<PyAttribute name="string" value="stream.read()">
</PyAttribute>

<PyAttribute name="position" value="Position.start()">
</PyAttribute>

<PyAttribute name="mark" value="Position.start()">
</PyAttribute>

</PyAttributes>

## Functions

<PyFunction name="__init__" type="(stream) -> None" kind="constructor">

<PySourceCode>

```python
def __init__(self, stream: IO[str]) -> None:
    self.string = stream.read()
    self.position = Position.start()
    self.mark = Position.start()
```

</PySourceCode>

<div>

<PyParameter name="stream" type="IO[str]">
</PyParameter>

</div>

<PyFunctionReturn type="None">
</PyFunctionReturn>

</PyFunction>

<PyFunction name="has_next" type="() -> bool">

<PySourceCode>

```python
def has_next(self) -> bool:
    return self.position.chars < len(self.string)
```

</PySourceCode>

<PyFunctionReturn type="bool">
</PyFunctionReturn>

</PyFunction>

<PyFunction name="set_mark" type="() -> None">

<PySourceCode>

```python
def set_mark(self) -> None:
    self.mark.set(self.position)
```

</PySourceCode>

<PyFunctionReturn type="None">
</PyFunctionReturn>

</PyFunction>

<PyFunction name="get_marked" type="() -> Original">

<PySourceCode>

```python
def get_marked(self) -> Original:
    return Original(
        string=self.string[self.mark.chars : self.position.chars],
        line=self.mark.line,
    )
```

</PySourceCode>

<PyFunctionReturn type="dotenv.parser.Original">
</PyFunctionReturn>

</PyFunction>

<PyFunction name="peek" type="(count) -> str">

<PySourceCode>

```python
def peek(self, count: int) -> str:
    return self.string[self.position.chars : self.position.chars + count]
```

</PySourceCode>

<div>

<PyParameter name="count" type="int">
</PyParameter>

</div>

<PyFunctionReturn type="str">
</PyFunctionReturn>

</PyFunction>

<PyFunction name="read" type="(count) -> str">

<PySourceCode>

```python
def read(self, count: int) -> str:
    result = self.string[self.position.chars : self.position.chars + count]
    if len(result) < count:
        raise Error("read: End of string")
    self.position.advance(result)
    return result
```

</PySourceCode>

<div>

<PyParameter name="count" type="int">
</PyParameter>

</div>

<PyFunctionReturn type="str">
</PyFunctionReturn>

</PyFunction>

<PyFunction name="read_regex" type="(regex) -> Sequence[str]">

<PySourceCode>

```python
def read_regex(self, regex: Pattern[str]) -> Sequence[str]:
    match = regex.match(self.string, self.position.chars)
    if match is None:
        raise Error("read_regex: Pattern not found")
    self.position.advance(self.string[match.start() : match.end()])
    return match.groups()
```

</PySourceCode>

<div>

<PyParameter name="regex" type="Pattern[str]">
</PyParameter>

</div>

<PyFunctionReturn type="typing.Sequence[str]">
</PyFunctionReturn>

</PyFunction>
