added read_istream() in tmpl/parser.cc

This commit is contained in:
Josh Holtrop 2010-05-05 15:13:57 -04:00
parent bfc4fc59c7
commit 44bf780a42

View File

@ -1,5 +1,6 @@
#include <iostream>
#include <vector>
#include I_HEADER_NAME
@ -9,11 +10,33 @@ using namespace std;
namespace I_NAMESPACE {
#endif
static void read_istream(istream & i, vector<char> & 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<char> buff;
int size;
read_istream(i, buff, size);
if (size <= 0)
return false;
}
#ifdef I_NAMESPACE