From 24be3228d463d6b2501cbca9368e14e91ab42182 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 6 Feb 2007 16:03:52 +0000 Subject: Tutorial (JPEG) and some formatting cleanup. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@924 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/initfile.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'crawl-ref/source/initfile.h') diff --git a/crawl-ref/source/initfile.h b/crawl-ref/source/initfile.h index f5c05972e0..ae76fda4bc 100644 --- a/crawl-ref/source/initfile.h +++ b/crawl-ref/source/initfile.h @@ -57,22 +57,26 @@ std::string channel_to_str(int ch); int str_to_channel(const std::string &); -class InitLineInput { +class InitLineInput +{ public: virtual ~InitLineInput() { } virtual bool eof() = 0; virtual std::string getline() = 0; }; -class FileLineInput : public InitLineInput { +class FileLineInput : public InitLineInput +{ public: FileLineInput(FILE *f) : file(f) { } - bool eof() { + bool eof() + { return !file || feof(file); } - std::string getline() { + std::string getline() + { char s[256] = ""; if (!eof()) fgets(s, sizeof s, file); @@ -82,15 +86,18 @@ private: FILE *file; }; -class StringLineInput : public InitLineInput { +class StringLineInput : public InitLineInput +{ public: StringLineInput(const std::string &s) : str(s), pos(0) { } - bool eof() { + bool eof() + { return pos >= str.length(); } - std::string getline() { + std::string getline() + { if (eof()) return ""; std::string::size_type newl = str.find("\n", pos); -- cgit v1.2.3-54-g00ecf