aboutsummaryrefslogtreecommitdiffstats
path: root/dev/a4-dance/simple_parser.h
blob: b077b4376ff4f5770d22cd013ba6dfafcd55d277 (plain) (blame)
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
#ifndef SIMPLE_PARSER_H_
#define SIMPLE_PARSER_H_

#include <fstream>
#include <string>

/** Helper class for parsing text input. */
class SimpleParser {
public:
    SimpleParser(std::istream *i);

    bool Expect(std::string s);

    bool Peek(std::string s);

    void SwallowWhitespace();

    void SwallowLine();

    bool ReadFloat(float &f);

    bool ReadInt(int &i);

    bool ReadToken(std::string &s);

    bool Good();

    bool ReadLine(std::string &line);

    bool UpcomingInt();

protected:
    bool FloatChar(char c);

    bool IntChar(char c);

    bool TokenChar(char c);

    std::istream *in_;
};

#endif