From 3047ed6100a56a529f26e43ada0a3fc3c3815c3e Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Fri, 8 Nov 2019 19:49:40 +0300 Subject: [texo] Full rewrite of inner representation. --- src/importer.cpp | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'src/importer.cpp') 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; } -- cgit v1.2.3