summaryrefslogtreecommitdiff
path: root/src/plain.hpp
blob: 13a2c0c7f6d6e0f857cd7956b29bc7b7f2a1fbf1 (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
#ifndef TEXO_INCLUDED_PLAIN
#define TEXO_INCLUDED_PLAIN

#include "exporter.hpp"
#include "producer.hpp"
#include "importer.hpp"


class TexoProducerPlain: public TexoProducer {
public:
    TexoProducerPlain(TexoExporter &exporter);

    void End();

    void Put(const Texo &piece);

    void Put(const TexoParagraph &piece);
    void Put(const TexoQuote &piece);

    void Put(const TexoHorizontalRule &piece);

private:
    bool quoted;
    bool newline;
    bool nospace;
};


class TexoImporterPlain: public TexoImporter {
public:
    TexoImporterPlain(TexoProducer &producer);

    void End();

    void Put(char c);
    void Put(const ScriptVariable &str);
    void Put(FILE *file);

private:
    enum State {
        text,
        newline,
        paragraph,
        quote_pre,
        quote,
        quote_newline,
        rule,
        paragraph_rule
    } state;

    void Text(char c);
    void Newline(char c);
    void Paragraph(char c);
    void QuotePre(char c);
    void Quote(char c);
    void QuoteNewline(char c);
    void Rule(char c);
    void ParagraphRule(char c);

    int dash_count;
};


#endif