summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-2.99/include/efont/afmparse.hh
blob: c29d990ceab1434a4691447c2ced4161c33e110e (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
// -*- related-file-name: "../../libefont/afmparse.cc" -*-
#ifndef EFONT_AFMPARSE_HH
#define EFONT_AFMPARSE_HH
#include <lcdf/slurper.hh>
#include <lcdf/permstr.hh>
#include <stdarg.h>
namespace Efont {

class AfmParser { public:

    AfmParser(Slurper &);

    bool ok() const			{ return _slurper.ok(); }
    operator Landmark() const		{ return _slurper.landmark(); }
    Landmark landmark() const		{ return _slurper.landmark(); }
    unsigned lineno() const		{ return _slurper.lineno(); }
    const Filename &filename() const	{ return _slurper.filename(); }

    bool key_matched() const		{ return _fail_field >= 0; }
    int fail_field() const		{ return _fail_field; }
    PermString message() const		{ return _message; }
    void clear_message()		{ _message = PermString(); }

    PermString keyword() const;
    bool is(const char *, ...);
    bool isall(const char *, ...);

    inline bool next_line();
    void save_line()			{ _slurper.save_line(); }
    void skip_until(unsigned char);

    unsigned char *cur_line() const	{ return _pos; }
    unsigned char first() const		{ return _pos[0]; }
    unsigned char operator[](int i) const { return _pos[i]; }
    bool left() const			{ return *_pos != 0; }

  private:

    Slurper &_slurper;
    bool _save_line;

    unsigned char *_line;
    unsigned char *_pos;
    int _length;

    PermString _message;
    int _fail_field;

    void static_initialize();
    void trim_end();
    unsigned char *vis(const char *, va_list);

};


inline bool AfmParser::next_line()
{
    _pos = _line = (unsigned char *)_slurper.next_line();
    _length = _slurper.cur_line_length();
    return _line != 0;
}

}
#endif