summaryrefslogtreecommitdiffstats
path: root/thirdparty/embree/common/lexers/stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/embree/common/lexers/stream.h')
-rw-r--r--thirdparty/embree/common/lexers/stream.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/thirdparty/embree/common/lexers/stream.h b/thirdparty/embree/common/lexers/stream.h
index a40c15f8eb..9ad72af4e6 100644
--- a/thirdparty/embree/common/lexers/stream.h
+++ b/thirdparty/embree/common/lexers/stream.h
@@ -6,7 +6,7 @@
#include "../sys/platform.h"
#include "../sys/ref.h"
#include "../sys/filename.h"
-#include "../sys/string.h"
+#include "../sys/estring.h"
#include <vector>
#include <iostream>
@@ -122,17 +122,16 @@ namespace embree
class FileStream : public Stream<int>
{
public:
-
- FileStream (FILE* file, const std::string& name = "file")
- : file(file), lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name))) {}
-
FileStream (const FileName& fileName)
: lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(fileName.str())))
{
- file = fopen(fileName.c_str(),"r");
- if (file == nullptr) THROW_RUNTIME_ERROR("cannot open file " + fileName.str());
+ if (ifs) ifs.close();
+ ifs.open(fileName.str());
+ if (!ifs.is_open()) THROW_RUNTIME_ERROR("cannot open file " + fileName.str());
+ }
+ ~FileStream() {
+ if (ifs) ifs.close();
}
- ~FileStream() { if (file) fclose(file); }
public:
ParseLocation location() {
@@ -140,14 +139,15 @@ namespace embree
}
int next() {
- int c = fgetc(file);
+ int c = ifs.get();
if (c == '\n') { lineNumber++; colNumber = 0; } else if (c != '\r') colNumber++;
charNumber++;
return c;
}
+
private:
- FILE* file;
+ std::ifstream ifs;
ssize_t lineNumber; /// the line number the token is from
ssize_t colNumber; /// the character number in the current line
ssize_t charNumber; /// the character in the file