summaryrefslogtreecommitdiff
path: root/core/variant/variant_parser.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-12 17:30:16 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-12 17:30:16 +0100
commitba4bd7f00971a94c20d90e7d2c665d5eb0ae1b90 (patch)
tree0fa58e29f475274ba149e38290f3c9b027f37dec /core/variant/variant_parser.h
parent8ab653c7eaebcbf404c203152c855fa2f15a2517 (diff)
parent491594ef0f56dcafd9a1aaba7b66ec23c9f18af4 (diff)
Merge pull request #69961 from lawnjelly/variant_parser_optional_readahead
VariantParser make readahead optional
Diffstat (limited to 'core/variant/variant_parser.h')
-rw-r--r--core/variant/variant_parser.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/variant/variant_parser.h b/core/variant/variant_parser.h
index 6b1d095ab5..fdea355c4b 100644
--- a/core/variant/variant_parser.h
+++ b/core/variant/variant_parser.h
@@ -46,14 +46,16 @@ public:
bool eof = false;
protected:
+ bool readahead_enabled = true;
virtual uint32_t _read_buffer(char32_t *p_buffer, uint32_t p_num_chars) = 0;
+ virtual bool _is_eof() const = 0;
public:
char32_t saved = 0;
char32_t get_char();
virtual bool is_utf8() const = 0;
- bool is_eof() const { return eof; }
+ bool is_eof() const;
Stream() {}
virtual ~Stream() {}
@@ -62,13 +64,14 @@ public:
struct StreamFile : public Stream {
protected:
virtual uint32_t _read_buffer(char32_t *p_buffer, uint32_t p_num_chars) override;
+ virtual bool _is_eof() const override;
public:
Ref<FileAccess> f;
virtual bool is_utf8() const override;
- StreamFile() {}
+ StreamFile(bool p_readahead_enabled = true) { readahead_enabled = p_readahead_enabled; }
};
struct StreamString : public Stream {
@@ -79,10 +82,11 @@ public:
protected:
virtual uint32_t _read_buffer(char32_t *p_buffer, uint32_t p_num_chars) override;
+ virtual bool _is_eof() const override;
public:
virtual bool is_utf8() const override;
- StreamString() {}
+ StreamString(bool p_readahead_enabled = true) { readahead_enabled = p_readahead_enabled; }
};
typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str);