From 44bf780a42995f5b437e1ba0c6fd196676f509a5 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 5 May 2010 15:13:57 -0400 Subject: [PATCH] added read_istream() in tmpl/parser.cc --- tmpl/parser.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tmpl/parser.cc b/tmpl/parser.cc index 994fd9e..6d632cd 100644 --- a/tmpl/parser.cc +++ b/tmpl/parser.cc @@ -1,5 +1,6 @@ #include +#include #include I_HEADER_NAME @@ -9,11 +10,33 @@ using namespace std; namespace I_NAMESPACE { #endif +static void read_istream(istream & i, vector & buff, int & size) +{ + size = 0; + int bytes_read; + char read_buff[1000]; + while (!i.eof()) + { + i.read(&read_buff[0], sizeof(read_buff)); + bytes_read = i.gcount(); + size += bytes_read; + for (int j = 0; j < bytes_read; j++) + buff.push_back(read_buff[j]); + } +} + bool I_CLASSNAME::parse(istream & i) { struct { char * name; char * definition; } tokens[] = { I_TOKENLIST }; + + vector buff; + int size; + read_istream(i, buff, size); + + if (size <= 0) + return false; } #ifdef I_NAMESPACE