diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-02-06 16:03:52 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-02-06 16:03:52 +0000 |
commit | 24be3228d463d6b2501cbca9368e14e91ab42182 (patch) | |
tree | 5fd30f60a43e1e69188bce4e30646c3e89e288b2 /crawl-ref/source/initfile.h | |
parent | f878a03c781fd57fea8447caaecee847ab576d8b (diff) | |
download | crawl-ref-24be3228d463d6b2501cbca9368e14e91ab42182.tar.gz crawl-ref-24be3228d463d6b2501cbca9368e14e91ab42182.zip |
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
Diffstat (limited to 'crawl-ref/source/initfile.h')
-rw-r--r-- | crawl-ref/source/initfile.h | 21 |
1 files changed, 14 insertions, 7 deletions
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); |