File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -384,6 +384,42 @@ class StdIStream : public simplecpp::TokenList::Stream {
384384 std::istream &istr;
385385};
386386
387+ class StdCharBufStream : public simplecpp ::TokenList::Stream {
388+ public:
389+ // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
390+ StdCharBufStream (const unsigned char * str, std::size_t size)
391+ : str(str)
392+ , size(size)
393+ , pos(0 )
394+ , lastStatus(0 )
395+ {
396+ init ();
397+ }
398+
399+ virtual int get () OVERRIDE {
400+ if (pos >= size)
401+ return lastStatus = EOF;
402+ return str[pos++];
403+ }
404+ virtual int peek () OVERRIDE {
405+ if (pos >= size)
406+ return lastStatus = EOF;
407+ return str[pos];
408+ }
409+ virtual void unget () OVERRIDE {
410+ --pos;
411+ }
412+ virtual bool good () OVERRIDE {
413+ return lastStatus != EOF;
414+ }
415+
416+ private:
417+ const unsigned char *str;
418+ const std::size_t size;
419+ std::size_t pos;
420+ int lastStatus;
421+ };
422+
387423class FileStream : public simplecpp ::TokenList::Stream {
388424public:
389425 // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
You can’t perform that action at this time.
0 commit comments