summaryrefslogtreecommitdiffhomepage
path: root/FoundationEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-02 19:04:29 +0200
committerAki <please@ignore.pl>2022-04-02 19:15:49 +0200
commitbeb4c7aa02cfe80cdfc6793406823c5f32cb0b74 (patch)
tree2501d9034b7ebc31374394a1c44e16a329f11a64 /FoundationEx
parentd5fe6f541817105955a0cf48331e564c5e2d5692 (diff)
downloadstarshatter-beb4c7aa02cfe80cdfc6793406823c5f32cb0b74.zip
starshatter-beb4c7aa02cfe80cdfc6793406823c5f32cb0b74.tar.gz
starshatter-beb4c7aa02cfe80cdfc6793406823c5f32cb0b74.tar.bz2
Reformatted Reader and updated header includes
Diffstat (limited to 'FoundationEx')
-rw-r--r--FoundationEx/Reader.cpp56
-rw-r--r--FoundationEx/Reader.h23
2 files changed, 46 insertions, 33 deletions
diff --git a/FoundationEx/Reader.cpp b/FoundationEx/Reader.cpp
index 682627d..b39e9bc 100644
--- a/FoundationEx/Reader.cpp
+++ b/FoundationEx/Reader.cpp
@@ -3,21 +3,22 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Implementation of the Reader class
+ OVERVIEW
+ ========
+ Implementation of the Reader class
*/
#include "Reader.h"
-#include <stdio.h>
+
+#include <cctype>
+#include <cstdio>
#include <fstream>
-#include <ctype.h>
+
#include "Utils.h"
-// +-------------------------------------------------------------------+
Text
ConsoleReader::more()
@@ -31,25 +32,29 @@ ConsoleReader::more()
return Text(p);
}
+
void
ConsoleReader::printPrimaryPrompt()
{
- printf("- ");
+ std::printf("- ");
}
+
void
ConsoleReader::fillInputBuffer()
{
- fgets(buffer, 980, stdin);
+ std::fgets(buffer, 980, stdin);
p = buffer;
- while (isspace(*p)) p++;
+ while (std::isspace(*p)) p++;
}
-// +-------------------------------------------------------------------+
-FileReader::FileReader(const char* fname)
- : filename(fname), done(0)
-{ }
+FileReader::FileReader(const char* fname) :
+ filename(fname),
+ done(0)
+{
+}
+
Text
FileReader::more()
@@ -76,15 +81,22 @@ FileReader::more()
return result;
}
-// +-------------------------------------------------------------------+
-BlockReader::BlockReader(const char* block)
- : data((char*) block), done(0), length(0)
-{ }
+BlockReader::BlockReader(const char* block) :
+ data((char*) block),
+ done(0),
+ length(0)
+{
+}
+
+
+BlockReader::BlockReader(const char* block, int len) :
+ data((char*) block),
+ done(0),
+ length(len)
+{
+}
-BlockReader::BlockReader(const char* block, int len)
- : data((char*) block), done(0), length(len)
-{ }
Text
BlockReader::more()
@@ -105,5 +117,3 @@ BlockReader::more()
done = 1;
return Text();
}
-
-
diff --git a/FoundationEx/Reader.h b/FoundationEx/Reader.h
index e1154d1..ed6aebc 100644
--- a/FoundationEx/Reader.h
+++ b/FoundationEx/Reader.h
@@ -3,20 +3,19 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Declaration of the Reader class
+ OVERVIEW
+ ========
+ Declaration of the Reader class
*/
-#ifndef READER_H
-#define READER_H
+#ifndef Reader_h
+#define Reader_h
#include "Text.h"
-// +-------------------------------------------------------------------+
class Reader
{
@@ -27,10 +26,11 @@ public:
virtual Text more() = 0;
};
+
class ConsoleReader : public Reader
{
public:
- virtual Text more();
+ virtual Text more() override;
void printPrimaryPrompt();
void fillInputBuffer();
@@ -40,17 +40,19 @@ private:
char* p;
};
+
class FileReader : public Reader
{
public:
FileReader(const char* fname);
- virtual Text more();
+ virtual Text more() override;
private:
Text filename;
int done;
};
+
class BlockReader : public Reader
{
public:
@@ -64,4 +66,5 @@ private:
int length;
};
-#endif
+
+#endif // Reader_h