summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp
index b144d34336d..8a62b6b0118 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/InputBuffer.hpp
@@ -27,8 +27,7 @@
#include <string>
#include <ostream>
-struct InputBuffer
-{
+struct InputBuffer {
virtual ~InputBuffer () =default;
virtual int get () =0;
virtual int peek () const =0;
@@ -38,11 +37,10 @@ struct InputBuffer
};
-class StreamInputBuffer : public InputBuffer
-{
+class StreamInputBuffer : public InputBuffer {
public:
- StreamInputBuffer (std::istream &is, size_t bufsize=1024);
- ~StreamInputBuffer ();
+ explicit StreamInputBuffer (std::istream &is, size_t bufsize=1024);
+ ~StreamInputBuffer () override;
int get () override;
int peek () const override;
int peek (size_t n) const override;
@@ -64,24 +62,23 @@ class StreamInputBuffer : public InputBuffer
};
-class StringInputBuffer : public InputBuffer
-{
+class StringInputBuffer : public InputBuffer {
public:
- StringInputBuffer (const std::string &str) : _str(str), _pos(0) {}
- int get () override {return _pos < _str.length() ? _str[_pos++] : -1;}
- int peek () const override {return _pos < _str.length() ? _str[_pos] : -1;}
- int peek (size_t n) const override {return _pos+n < _str.length() ? _str[_pos+n] : -1;}
- bool eof () const override {return _pos >= _str.length();}
- void invalidate () override {_pos = _str.length();}
+ explicit StringInputBuffer (const std::string &str) : _str(&str) {}
+ void assign (const std::string &str) {_str = &str; _pos=0;}
+ int get () override {return _pos < _str->length() ? _str->at(_pos++) : -1;}
+ int peek () const override {return _pos < _str->length() ? _str->at(_pos) : -1;}
+ int peek (size_t n) const override {return _pos+n < _str->length() ? _str->at(_pos+n) : -1;}
+ bool eof () const override {return _pos >= _str->length();}
+ void invalidate () override {_pos = _str->length();}
private:
- const std::string &_str;
- size_t _pos;
+ const std::string *_str;
+ size_t _pos=0;
};
-class CharInputBuffer : public InputBuffer
-{
+class CharInputBuffer : public InputBuffer {
public:
CharInputBuffer (const char *buf, size_t size) : _pos(buf), _size(buf ? size : 0) {}
@@ -112,8 +109,7 @@ class CharInputBuffer : public InputBuffer
};
-class SplittedCharInputBuffer : public InputBuffer
-{
+class SplittedCharInputBuffer : public InputBuffer {
public:
SplittedCharInputBuffer (const char *buf1, size_t s1, const char *buf2, size_t s2);
int get () override;
@@ -129,16 +125,15 @@ class SplittedCharInputBuffer : public InputBuffer
};
-class TextStreamInputBuffer : public StreamInputBuffer
-{
+class TextStreamInputBuffer : public StreamInputBuffer {
public:
- TextStreamInputBuffer (std::istream &is) : StreamInputBuffer(is), _line(1), _col(1) {}
+ explicit TextStreamInputBuffer (std::istream &is) : StreamInputBuffer(is) {}
int get () override;
int line () const {return _line;}
int col () const {return _col;}
private:
- int _line, _col;
+ int _line=1, _col=1;
};
#endif