/var/www/hkosl.com/nick/codeigniter/application/vendor/gettext/gettext/src/Utils/StringReader.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

namespace Gettext\Utils;

class 
StringReader
{
    public 
$pos;
    public 
$str;
    public 
$strlen;

    
/**
     * Constructor.
     *
     * @param string $str The string to read
     */
    
public function __construct($str)
    {
        
$this->str $str;
        
$this->strlen strlen($this->str);
    }

    
/**
     * Read and returns a part of the string.
     *
     * @param int $bytes The number of bytes to read
     *
     * @return string
     */
    
public function read($bytes)
    {
        
$data substr($this->str$this->pos$bytes);

        
$this->seekto($this->pos $bytes);

        return 
$data;
    }

    
/**
     * Move the cursor to a specific position.
     *
     * @param int $pos The amount of bytes to move
     *
     * @return int The new position
     */
    
public function seekto($pos)
    {
        
$this->pos = ($this->strlen $pos) ? $this->strlen $pos;

        return 
$this->pos;
    }
}