diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2019-11-08 19:49:40 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2019-11-08 19:49:40 +0300 |
commit | ed7a63015c1583d5544ac18bbaccaedc95f3e5e3 (patch) | |
tree | 9648d5a74bae9cbd90670a8bfa0af47189e4536f /src/importer.cpp | |
parent | c6419eed96f2832b1de2b94d711552efaa9b172d (diff) | |
download | texo-ed7a63015c1583d5544ac18bbaccaedc95f3e5e3.tar texo-ed7a63015c1583d5544ac18bbaccaedc95f3e5e3.tar.xz texo-ed7a63015c1583d5544ac18bbaccaedc95f3e5e3.zip |
[texo] Full rewrite of inner representation.
Diffstat (limited to 'src/importer.cpp')
-rw-r--r-- | src/importer.cpp | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/importer.cpp b/src/importer.cpp index af475a5..73ff060 100644 --- a/src/importer.cpp +++ b/src/importer.cpp @@ -1,27 +1,58 @@ #include "importer.hpp" -TexoImporter::TexoImporter(TexoProducer &producer): producer(producer) +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Texo Importer + */ +TexoImporter::TexoImporter(TexoProducer &producer): + producer(producer), ok(true) {} -void TexoImporter::End() +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) { - producer.End(); + return ok = ok && TruePut(s); } -void TexoImporter::Put(const ScriptVariable &str) +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; i < len; ++i) { - Put(str[i]); + for (int i = 0; ok && i < len; ++i) { + ok = TruePut(str[i]); } + return ok; } -void TexoImporter::Put(FILE *file) +bool TexoImporter::TruePut(FILE *file) { if (file) { - for (int c = fgetc(file); c != EOF; c = fgetc(file)) { - Put(c); + for (int c = fgetc(file); ok && c != EOF; c = fgetc(file)) { + ok = TruePut(c); } } + return ok; } |