fs/io/Reader: use C++ exceptions instead of class Error

This commit is contained in:
Max Kellermann
2015-12-16 11:05:33 +01:00
parent fe60c52c70
commit e6e7d6dbd6
33 changed files with 192 additions and 334 deletions

View File

@@ -23,10 +23,7 @@
#include "check.h"
#include "Compiler.h"
#include <stddef.h>
class Path;
class Error;
class FileReader;
class AutoGunzipReader;
class BufferedReader;
@@ -41,32 +38,20 @@ class TextFile {
BufferedReader *const buffered_reader;
public:
TextFile(Path path_fs, Error &error);
TextFile(Path path_fs);
TextFile(const TextFile &other) = delete;
~TextFile();
bool HasFailed() const {
return gcc_unlikely(buffered_reader == nullptr);
}
/**
* Reads a line from the input file, and strips trailing
* space. There is a reasonable maximum line length, only to
* prevent denial of service.
*
* Use Check() after nullptr has been returned to check
* whether an error occurred or end-of-file has been reached.
*
* @return a pointer to the line, or nullptr on end-of-file or error
* @return a pointer to the line, or nullptr on end-of-file
*/
char *ReadLine();
/**
* Check whether a ReadLine() call has thrown an error.
*/
bool Check(Error &error) const;
};
#endif