summaryrefslogtreecommitdiff
path: root/src/importer.cpp
blob: f46b7d29aacac2b867a534aedaadedcf225b0e7f (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
#include "importer.hpp"


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Texo Importer
 */
TexoImporter::TexoImporter(TexoProducer &producer):
    producer(producer), ok(true)
{}

TexoImporter::~TexoImporter()
{
    End();
}


bool TexoImporter::End()
{
    return ok = ok && TrueEnd();
}

bool TexoImporter::Put(char c)
{
    return ok = ok && TruePut(c);
}

bool TexoImporter::Put(const char *s)
{
    return ok = ok && TruePut(s);
}

bool TexoImporter::Put(FILE *f)
{
    return ok = ok && TruePut(f);
}


bool TexoImporter::TrueEnd()
{
    return producer.End();
}

bool TexoImporter::TruePut(const char *str)
{
    while (*str) {
        ok = TruePut(*str);
        ++str;
    }
    return ok;
}

bool TexoImporter::TruePut(FILE *file)
{
    if (file) {
        for (int c = fgetc(file); ok && c != EOF; c = fgetc(file)) {
            ok = TruePut(c);
        }
    }
    return ok;
}