summaryrefslogtreecommitdiff
path: root/src/importer.cpp
blob: 73ff060f7edbd2ebcb364c300d4ca26abc98ec87 (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
#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 ScriptVariable &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 ScriptVariable &str)
{
    const int len = str.Length();
    for (int i = 0; ok && i < len; ++i) {
        ok = TruePut(str[i]);
    }
    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;
}