Blame view

morfeusz/charset/TextReader.hpp 1.11 KB
Michał Lenart authored
1
/* 
Michał Lenart authored
2
 * File:   TextReader.hpp
Michał Lenart authored
3
4
5
6
7
8
9
10
 * Author: lennyn
 *
 * Created on May 28, 2014, 11:43 AM
 */

#ifndef TEXTREADER_HPP
#define	TEXTREADER_HPP
Michał Lenart authored
11
#include <string>
Michał Lenart authored
12
#include "Environment.hpp"
Michał Lenart authored
13
Michał Lenart authored
14
15
namespace morfeusz {
Michał Lenart authored
16
17
18
19
20
21
22
23
24
25
26
class TextReader {
public:
    TextReader(const char* inputStart, const char* inputEnd, const Environment& env);
    void markWordStartsHere();
    const char* getWordStartPtr() const;
    const char* getCurrPtr() const;
    const char* getNextPtr();
    const char* getEndPtr() const;
    int getCodepointsRead() const;
    bool isAtEnd() const;
    bool isAtWhitespace();
Michał Lenart authored
27
    bool isInsideAWord();
Michał Lenart authored
28
29
30
31
    uint32_t peek();
    uint32_t normalizedPeek();
    uint32_t next();
    void skipWhitespaces();
Michał Lenart authored
32
    std::string readWhitespacesChunk();
Michał Lenart authored
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    void proceedToEnd();
    virtual ~TextReader();
private:
    int codepointsNum;
    const char* wordStartPtr;
    const char* currPtr;
    const char* inputEnd;
    const Environment& env;
    bool knowsAboutWhitespace;
    bool atWhitespace;
    bool peekIsRead;
    uint32_t thePeek;
    uint32_t theNormalizedPeek;
    const char* ptrAfterThePeek;
};
Michał Lenart authored
49
50
}
Michał Lenart authored
51
52
#endif	/* TEXTREADER_HPP */